@dnax/core 0.77.9 → 0.78.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/app/hono.ts +5 -3
- package/app/index.ts +2 -1
- package/driver/mongo/rest.ts +162 -7
- package/index.ts +1 -2
- package/lib/asyncLocalStorage.ts +22 -3
- package/lib/media/sftp.ts +686 -103
- package/lib/media/sftp_.txt +120 -0
- package/package.json +3 -4
package/app/hono.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { serveStatic, getConnInfo } from "hono/bun";
|
|
|
14
14
|
import { consola } from "consola";
|
|
15
15
|
|
|
16
16
|
import { cors } from "hono/cors";
|
|
17
|
-
import { asyncLocalStorage, sessionStorage } from "../lib/asyncLocalStorage";
|
|
17
|
+
import { asyncLocalStorage, sessionStorage, requestStorage } from "../lib/asyncLocalStorage";
|
|
18
18
|
import { crypt } from "../lib/crypto";
|
|
19
19
|
import { plugins } from "../lib/plugins";
|
|
20
20
|
import {
|
|
@@ -102,6 +102,8 @@ function HonoInstance(): typeof app {
|
|
|
102
102
|
// Middlewares Injection
|
|
103
103
|
app.use(async (c, next) => {
|
|
104
104
|
return asyncLocalStorage.run(new Map(), async () => {
|
|
105
|
+
let requestId = v4();
|
|
106
|
+
requestStorage().set("uuid", requestId);
|
|
105
107
|
let cookie = getCookie(c);
|
|
106
108
|
let session = sessionStorage();
|
|
107
109
|
var token =
|
|
@@ -303,7 +305,7 @@ function HonoInstance(): typeof app {
|
|
|
303
305
|
?.get("content-type")
|
|
304
306
|
?.match(/(multipart\/form-data)/) ||
|
|
305
307
|
c.req?.raw?.headers.get("content-type") ==
|
|
306
|
-
|
|
308
|
+
"application/x-www-form-urlencoded"
|
|
307
309
|
) {
|
|
308
310
|
parseBody =
|
|
309
311
|
(await c?.req.parseBody({
|
|
@@ -816,7 +818,7 @@ function HonoInstance(): typeof app {
|
|
|
816
818
|
if (Cfg?.api?.onError && typeof Cfg?.api?.onError == "function") {
|
|
817
819
|
try {
|
|
818
820
|
await Cfg?.api?.onError(errorFormated, err);
|
|
819
|
-
} catch (e) {}
|
|
821
|
+
} catch (e) { }
|
|
820
822
|
}
|
|
821
823
|
return c.json(errorFormated);
|
|
822
824
|
}
|
package/app/index.ts
CHANGED
|
@@ -78,7 +78,7 @@ async function runApp(config?: configRunApp, clb?: Function): Promise<Server> {
|
|
|
78
78
|
await sleep(150);
|
|
79
79
|
let info = "";
|
|
80
80
|
|
|
81
|
-
info += `${serverName}`.gray.underline.bold
|
|
81
|
+
info += `${serverName}`.gray.underline.bold + ` (PID: ${process.pid})`;
|
|
82
82
|
info += `\n`;
|
|
83
83
|
info += `\n`;
|
|
84
84
|
info += `Env: ${envName}`.green.bold + "\n";
|
|
@@ -92,6 +92,7 @@ async function runApp(config?: configRunApp, clb?: Function): Promise<Server> {
|
|
|
92
92
|
});
|
|
93
93
|
info += `\n\n`;
|
|
94
94
|
info += `🔄 ${new Date().toLocaleString()}`.gray;
|
|
95
|
+
|
|
95
96
|
if (clb) clb();
|
|
96
97
|
|
|
97
98
|
console.log();
|
package/driver/mongo/rest.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import moment from "moment";
|
|
2
|
-
import { sessionStorage } from "../../lib/asyncLocalStorage";
|
|
2
|
+
import { sessionStorage,restStorage,requestStorage } from "../../lib/asyncLocalStorage";
|
|
3
3
|
import { getCollection, getKeyFields } from "../../lib/collection";
|
|
4
4
|
import { getTenant } from "../../lib/tenant";
|
|
5
5
|
import type { Actions, Collection, Q, Tenant } from "./../../types/index";
|
|
6
6
|
import { isArray } from "radash";
|
|
7
|
+
import { v4 } from "uuid";
|
|
7
8
|
import { omit } from "../../utils";
|
|
8
9
|
import {
|
|
9
10
|
AggregationCursor,
|
|
@@ -51,6 +52,7 @@ type options = {
|
|
|
51
52
|
useHook?: boolean;
|
|
52
53
|
useCustomApi?: boolean;
|
|
53
54
|
session?: ClientSession | undefined | null;
|
|
55
|
+
restId?:string|null;
|
|
54
56
|
};
|
|
55
57
|
|
|
56
58
|
type optionCb = {
|
|
@@ -126,6 +128,8 @@ class useRest {
|
|
|
126
128
|
#session: ClientSession | null | undefined;
|
|
127
129
|
#useCustomApi: boolean = true;
|
|
128
130
|
#events: Array<any> = [];
|
|
131
|
+
#requestId?: string;
|
|
132
|
+
#restId?: string;
|
|
129
133
|
/**
|
|
130
134
|
Direct Api Mongo , use it with caution
|
|
131
135
|
*/
|
|
@@ -153,7 +157,6 @@ class useRest {
|
|
|
153
157
|
this.#tenant = getTenant(this.#tenant_id);
|
|
154
158
|
this.#useHook = options?.useHook ?? true;
|
|
155
159
|
this.db = this.#tenant.database.db;
|
|
156
|
-
|
|
157
160
|
this.activity = {
|
|
158
161
|
aggregate: async (
|
|
159
162
|
pipeline: Array<object>,
|
|
@@ -208,6 +211,29 @@ class useRest {
|
|
|
208
211
|
},
|
|
209
212
|
};
|
|
210
213
|
|
|
214
|
+
// Get requestId for trace
|
|
215
|
+
|
|
216
|
+
if(requestStorage()?.isSet()){
|
|
217
|
+
this.#requestId = requestStorage()?.get('uuid');
|
|
218
|
+
if(!restStorage()?.isSet() && !this.#restId){
|
|
219
|
+
restStorage().set('uuid', this.#requestId);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if(restStorage()?.isSet()){
|
|
223
|
+
this.#restId=restStorage().get('uuid');
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if(!this.#restId){
|
|
227
|
+
this.#restId = options?.restId|| v4();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
// set uuid for Trace
|
|
232
|
+
/* if(!restStorage().get('uuid')){
|
|
233
|
+
this.#restId = v4();
|
|
234
|
+
restStorage().set('uuid', this.#restId);
|
|
235
|
+
} */
|
|
236
|
+
|
|
211
237
|
/* if (options?.useHook == undefined || options?.useHook == null) {
|
|
212
238
|
this.#useHook = true;
|
|
213
239
|
} else {
|
|
@@ -359,7 +385,10 @@ class useRest {
|
|
|
359
385
|
action: "aggregate",
|
|
360
386
|
session: sessionStorage(),
|
|
361
387
|
rest: new useRest({
|
|
388
|
+
session: this.#session,
|
|
389
|
+
restId: this.#restId,
|
|
362
390
|
useHook: false,
|
|
391
|
+
useCustomApi:false,
|
|
363
392
|
tenant_id: this.#tenant_id,
|
|
364
393
|
}),
|
|
365
394
|
});
|
|
@@ -376,6 +405,9 @@ class useRest {
|
|
|
376
405
|
action: "aggregate",
|
|
377
406
|
session: sessionStorage(),
|
|
378
407
|
rest: new useRest({
|
|
408
|
+
session: this.#session,
|
|
409
|
+
restId: this.#restId,
|
|
410
|
+
useCustomApi:false,
|
|
379
411
|
useHook: false,
|
|
380
412
|
tenant_id: this.#tenant_id,
|
|
381
413
|
}),
|
|
@@ -389,7 +421,10 @@ class useRest {
|
|
|
389
421
|
session: sessionStorage(),
|
|
390
422
|
pipeline: toJson(pipeline),
|
|
391
423
|
rest: new useRest({
|
|
424
|
+
restId: this.#restId,
|
|
425
|
+
session: this.#session,
|
|
392
426
|
useHook: false,
|
|
427
|
+
|
|
393
428
|
tenant_id: this.#tenant_id,
|
|
394
429
|
useCustomApi: false,
|
|
395
430
|
}),
|
|
@@ -416,6 +451,9 @@ class useRest {
|
|
|
416
451
|
session: sessionStorage(),
|
|
417
452
|
result: result.docs,
|
|
418
453
|
rest: new useRest({
|
|
454
|
+
restId: this.#restId,
|
|
455
|
+
useCustomApi:false,
|
|
456
|
+
session: this.#session,
|
|
419
457
|
useHook: false,
|
|
420
458
|
tenant_id: this.#tenant_id,
|
|
421
459
|
}),
|
|
@@ -433,6 +471,9 @@ class useRest {
|
|
|
433
471
|
session: sessionStorage(),
|
|
434
472
|
result: result.docs,
|
|
435
473
|
rest: new useRest({
|
|
474
|
+
restId: this.#restId,
|
|
475
|
+
session: this.#session,
|
|
476
|
+
useCustomApi:false,
|
|
436
477
|
useHook: false,
|
|
437
478
|
tenant_id: this.#tenant_id,
|
|
438
479
|
}),
|
|
@@ -509,6 +550,7 @@ class useRest {
|
|
|
509
550
|
action: "insertOne",
|
|
510
551
|
session: sessionStorage(),
|
|
511
552
|
rest: new useRest({
|
|
553
|
+
restId: this.#restId,
|
|
512
554
|
useCustomApi: false,
|
|
513
555
|
session: this.#session,
|
|
514
556
|
useHook: false,
|
|
@@ -529,6 +571,7 @@ class useRest {
|
|
|
529
571
|
action: "insertOne",
|
|
530
572
|
session: sessionStorage(),
|
|
531
573
|
rest: new useRest({
|
|
574
|
+
restId: this.#restId,
|
|
532
575
|
useCustomApi: false,
|
|
533
576
|
session: this.#session,
|
|
534
577
|
useHook: false,
|
|
@@ -544,6 +587,7 @@ class useRest {
|
|
|
544
587
|
session: sessionStorage(),
|
|
545
588
|
data: toJson(data),
|
|
546
589
|
rest: new useRest({
|
|
590
|
+
restId: this.#restId,
|
|
547
591
|
session: this.#session,
|
|
548
592
|
useHook: false,
|
|
549
593
|
tenant_id: this.#tenant_id,
|
|
@@ -597,6 +641,7 @@ class useRest {
|
|
|
597
641
|
action: "insertOne",
|
|
598
642
|
session: sessionStorage(),
|
|
599
643
|
rest: new useRest({
|
|
644
|
+
restId: this.#restId,
|
|
600
645
|
useCustomApi: false,
|
|
601
646
|
session: this.#session,
|
|
602
647
|
useHook: false,
|
|
@@ -617,6 +662,7 @@ class useRest {
|
|
|
617
662
|
action: "insertOne",
|
|
618
663
|
session: sessionStorage(),
|
|
619
664
|
rest: new useRest({
|
|
665
|
+
restId: this.#restId,
|
|
620
666
|
useCustomApi: false,
|
|
621
667
|
session: this.#session,
|
|
622
668
|
useHook: false,
|
|
@@ -660,6 +706,7 @@ class useRest {
|
|
|
660
706
|
col.cache.invalidate({
|
|
661
707
|
operationType: "insert",
|
|
662
708
|
rest: new useRest({
|
|
709
|
+
restId: this.#restId,
|
|
663
710
|
useCustomApi: false,
|
|
664
711
|
session: this.#session,
|
|
665
712
|
useHook: false,
|
|
@@ -706,6 +753,7 @@ class useRest {
|
|
|
706
753
|
action: "insertMany",
|
|
707
754
|
session: sessionStorage(),
|
|
708
755
|
rest: new useRest({
|
|
756
|
+
restId: this.#restId,
|
|
709
757
|
useHook: false,
|
|
710
758
|
tenant_id: this.#tenant_id,
|
|
711
759
|
session: this.#session,
|
|
@@ -725,6 +773,7 @@ class useRest {
|
|
|
725
773
|
action: "insertMany",
|
|
726
774
|
session: sessionStorage(),
|
|
727
775
|
rest: new useRest({
|
|
776
|
+
restId: this.#restId,
|
|
728
777
|
useHook: false,
|
|
729
778
|
tenant_id: this.#tenant_id,
|
|
730
779
|
session: this.#session,
|
|
@@ -740,6 +789,7 @@ class useRest {
|
|
|
740
789
|
session: sessionStorage(),
|
|
741
790
|
data: toJson(data),
|
|
742
791
|
rest: new useRest({
|
|
792
|
+
restId: this.#restId,
|
|
743
793
|
useHook: false,
|
|
744
794
|
tenant_id: this.#tenant_id,
|
|
745
795
|
useCustomApi: false,
|
|
@@ -792,6 +842,7 @@ class useRest {
|
|
|
792
842
|
result: toJson(data),
|
|
793
843
|
session: sessionStorage(),
|
|
794
844
|
rest: new useRest({
|
|
845
|
+
restId: this.#restId,
|
|
795
846
|
session: this.#session,
|
|
796
847
|
useCustomApi: false,
|
|
797
848
|
useHook: false,
|
|
@@ -812,6 +863,7 @@ class useRest {
|
|
|
812
863
|
result: toJson(data),
|
|
813
864
|
session: sessionStorage(),
|
|
814
865
|
rest: new useRest({
|
|
866
|
+
restId: this.#restId,
|
|
815
867
|
session: this.#session,
|
|
816
868
|
useCustomApi: false,
|
|
817
869
|
useHook: false,
|
|
@@ -873,6 +925,7 @@ class useRest {
|
|
|
873
925
|
col.cache.invalidate({
|
|
874
926
|
operationType: "insert",
|
|
875
927
|
rest: new useRest({
|
|
928
|
+
restId: this.#restId,
|
|
876
929
|
useCustomApi: false,
|
|
877
930
|
session: this.#session,
|
|
878
931
|
useHook: false,
|
|
@@ -924,6 +977,9 @@ class useRest {
|
|
|
924
977
|
if (useCacheBool && col?.cache?.fetch) {
|
|
925
978
|
let cacheResult = await col.cache.fetch({
|
|
926
979
|
rest: new useRest({
|
|
980
|
+
restId: this.#restId,
|
|
981
|
+
session: this.#session,
|
|
982
|
+
useCustomApi:false,
|
|
927
983
|
useHook: false,
|
|
928
984
|
tenant_id: this.#tenant_id,
|
|
929
985
|
}),
|
|
@@ -943,6 +999,9 @@ class useRest {
|
|
|
943
999
|
params: params,
|
|
944
1000
|
session: sessionStorage(),
|
|
945
1001
|
rest: new useRest({
|
|
1002
|
+
restId: this.#restId,
|
|
1003
|
+
session: this.#session,
|
|
1004
|
+
useCustomApi:false,
|
|
946
1005
|
useHook: false,
|
|
947
1006
|
tenant_id: this.#tenant_id,
|
|
948
1007
|
}),
|
|
@@ -960,6 +1019,9 @@ class useRest {
|
|
|
960
1019
|
params: params,
|
|
961
1020
|
session: sessionStorage(),
|
|
962
1021
|
rest: new useRest({
|
|
1022
|
+
restId: this.#restId,
|
|
1023
|
+
session: this.#session,
|
|
1024
|
+
useCustomApi:false,
|
|
963
1025
|
useHook: false,
|
|
964
1026
|
tenant_id: this.#tenant_id,
|
|
965
1027
|
}),
|
|
@@ -973,9 +1035,12 @@ class useRest {
|
|
|
973
1035
|
session: sessionStorage(),
|
|
974
1036
|
params: params,
|
|
975
1037
|
rest: new useRest({
|
|
1038
|
+
restId: this.#restId,
|
|
1039
|
+
session: this.#session,
|
|
1040
|
+
useCustomApi:false,
|
|
976
1041
|
useHook: false,
|
|
977
1042
|
tenant_id: this.#tenant_id,
|
|
978
|
-
|
|
1043
|
+
|
|
979
1044
|
}),
|
|
980
1045
|
})) as any;
|
|
981
1046
|
return resolve(result);
|
|
@@ -1004,6 +1069,9 @@ class useRest {
|
|
|
1004
1069
|
session: sessionStorage(),
|
|
1005
1070
|
result: result.docs,
|
|
1006
1071
|
rest: new useRest({
|
|
1072
|
+
restId: this.#restId,
|
|
1073
|
+
session: this.#session,
|
|
1074
|
+
useCustomApi:false,
|
|
1007
1075
|
useHook: false,
|
|
1008
1076
|
tenant_id: this.#tenant_id,
|
|
1009
1077
|
}),
|
|
@@ -1024,6 +1092,9 @@ class useRest {
|
|
|
1024
1092
|
session: sessionStorage(),
|
|
1025
1093
|
result: result.docs,
|
|
1026
1094
|
rest: new useRest({
|
|
1095
|
+
restId: this.#restId,
|
|
1096
|
+
session: this.#session,
|
|
1097
|
+
useCustomApi:false,
|
|
1027
1098
|
useHook: false,
|
|
1028
1099
|
tenant_id: this.#tenant_id,
|
|
1029
1100
|
}),
|
|
@@ -1079,6 +1150,9 @@ class useRest {
|
|
|
1079
1150
|
params: params,
|
|
1080
1151
|
session: sessionStorage(),
|
|
1081
1152
|
rest: new useRest({
|
|
1153
|
+
restId: this.#restId,
|
|
1154
|
+
session: this.#session,
|
|
1155
|
+
useCustomApi:false,
|
|
1082
1156
|
useHook: false,
|
|
1083
1157
|
tenant_id: this.#tenant_id,
|
|
1084
1158
|
}),
|
|
@@ -1096,6 +1170,9 @@ class useRest {
|
|
|
1096
1170
|
params: params,
|
|
1097
1171
|
session: sessionStorage(),
|
|
1098
1172
|
rest: new useRest({
|
|
1173
|
+
restId: this.#restId,
|
|
1174
|
+
session: this.#session,
|
|
1175
|
+
useCustomApi:false,
|
|
1099
1176
|
useHook: false,
|
|
1100
1177
|
tenant_id: this.#tenant_id,
|
|
1101
1178
|
}),
|
|
@@ -1109,9 +1186,12 @@ class useRest {
|
|
|
1109
1186
|
session: sessionStorage(),
|
|
1110
1187
|
params: params,
|
|
1111
1188
|
rest: new useRest({
|
|
1189
|
+
restId: this.#restId,
|
|
1190
|
+
session: this.#session,
|
|
1191
|
+
useCustomApi:false,
|
|
1112
1192
|
useHook: false,
|
|
1113
1193
|
tenant_id: this.#tenant_id,
|
|
1114
|
-
|
|
1194
|
+
|
|
1115
1195
|
}),
|
|
1116
1196
|
})) as any;
|
|
1117
1197
|
// Temp dexecution en ms
|
|
@@ -1146,6 +1226,9 @@ class useRest {
|
|
|
1146
1226
|
session: sessionStorage(),
|
|
1147
1227
|
result: result.docs,
|
|
1148
1228
|
rest: new useRest({
|
|
1229
|
+
restId: this.#restId,
|
|
1230
|
+
session: this.#session,
|
|
1231
|
+
useCustomApi:false,
|
|
1149
1232
|
useHook: false,
|
|
1150
1233
|
tenant_id: this.#tenant_id,
|
|
1151
1234
|
}),
|
|
@@ -1225,6 +1308,9 @@ class useRest {
|
|
|
1225
1308
|
params: params,
|
|
1226
1309
|
session: sessionStorage(),
|
|
1227
1310
|
rest: new useRest({
|
|
1311
|
+
restId: this.#restId,
|
|
1312
|
+
session: this.#session,
|
|
1313
|
+
useCustomApi:false,
|
|
1228
1314
|
useHook: false,
|
|
1229
1315
|
tenant_id: this.#tenant_id,
|
|
1230
1316
|
}),
|
|
@@ -1242,6 +1328,9 @@ class useRest {
|
|
|
1242
1328
|
params: params,
|
|
1243
1329
|
session: sessionStorage(),
|
|
1244
1330
|
rest: new useRest({
|
|
1331
|
+
restId: this.#restId,
|
|
1332
|
+
session: this.#session,
|
|
1333
|
+
useCustomApi:false,
|
|
1245
1334
|
useHook: false,
|
|
1246
1335
|
tenant_id: this.#tenant_id,
|
|
1247
1336
|
}),
|
|
@@ -1255,9 +1344,12 @@ class useRest {
|
|
|
1255
1344
|
session: sessionStorage(),
|
|
1256
1345
|
params: params,
|
|
1257
1346
|
rest: new useRest({
|
|
1347
|
+
restId: this.#restId,
|
|
1348
|
+
session: this.#session,
|
|
1349
|
+
useCustomApi:false,
|
|
1258
1350
|
useHook: false,
|
|
1259
1351
|
tenant_id: this.#tenant_id,
|
|
1260
|
-
|
|
1352
|
+
|
|
1261
1353
|
}),
|
|
1262
1354
|
})) as any;
|
|
1263
1355
|
return resolve(result);
|
|
@@ -1290,6 +1382,9 @@ class useRest {
|
|
|
1290
1382
|
result: result.docs,
|
|
1291
1383
|
count: result?.docs?.length || 0,
|
|
1292
1384
|
rest: new useRest({
|
|
1385
|
+
restId: this.#restId,
|
|
1386
|
+
session: this.#session,
|
|
1387
|
+
useCustomApi:false,
|
|
1293
1388
|
useHook: false,
|
|
1294
1389
|
tenant_id: this.#tenant_id,
|
|
1295
1390
|
}),
|
|
@@ -1309,6 +1404,9 @@ class useRest {
|
|
|
1309
1404
|
result: result.docs,
|
|
1310
1405
|
count: result?.docs?.length || 0,
|
|
1311
1406
|
rest: new useRest({
|
|
1407
|
+
restId: this.#restId,
|
|
1408
|
+
session: this.#session,
|
|
1409
|
+
useCustomApi:false,
|
|
1312
1410
|
useHook: false,
|
|
1313
1411
|
tenant_id: this.#tenant_id,
|
|
1314
1412
|
}),
|
|
@@ -1367,6 +1465,9 @@ class useRest {
|
|
|
1367
1465
|
params: params,
|
|
1368
1466
|
session: sessionStorage(),
|
|
1369
1467
|
rest: new useRest({
|
|
1468
|
+
restId: this.#restId,
|
|
1469
|
+
session: this.#session,
|
|
1470
|
+
useCustomApi:false,
|
|
1370
1471
|
useHook: false,
|
|
1371
1472
|
tenant_id: this.#tenant_id,
|
|
1372
1473
|
}),
|
|
@@ -1384,6 +1485,9 @@ class useRest {
|
|
|
1384
1485
|
params: params,
|
|
1385
1486
|
session: sessionStorage(),
|
|
1386
1487
|
rest: new useRest({
|
|
1488
|
+
restId: this.#restId,
|
|
1489
|
+
session: this.#session,
|
|
1490
|
+
useCustomApi:false,
|
|
1387
1491
|
useHook: false,
|
|
1388
1492
|
tenant_id: this.#tenant_id,
|
|
1389
1493
|
}),
|
|
@@ -1398,9 +1502,12 @@ class useRest {
|
|
|
1398
1502
|
id: id,
|
|
1399
1503
|
params: params,
|
|
1400
1504
|
rest: new useRest({
|
|
1505
|
+
restId: this.#restId,
|
|
1506
|
+
session: this.#session,
|
|
1507
|
+
useCustomApi:false,
|
|
1401
1508
|
useHook: false,
|
|
1402
1509
|
tenant_id: this.#tenant_id,
|
|
1403
|
-
|
|
1510
|
+
|
|
1404
1511
|
}),
|
|
1405
1512
|
});
|
|
1406
1513
|
return resolve(result);
|
|
@@ -1441,6 +1548,9 @@ class useRest {
|
|
|
1441
1548
|
session: sessionStorage(),
|
|
1442
1549
|
result: docs,
|
|
1443
1550
|
rest: new useRest({
|
|
1551
|
+
restId: this.#restId,
|
|
1552
|
+
session: this.#session,
|
|
1553
|
+
useCustomApi:false,
|
|
1444
1554
|
useHook: false,
|
|
1445
1555
|
tenant_id: this.#tenant_id,
|
|
1446
1556
|
}),
|
|
@@ -1459,6 +1569,9 @@ class useRest {
|
|
|
1459
1569
|
session: sessionStorage(),
|
|
1460
1570
|
result: docs,
|
|
1461
1571
|
rest: new useRest({
|
|
1572
|
+
restId: this.#restId,
|
|
1573
|
+
session: this.#session,
|
|
1574
|
+
useCustomApi:false,
|
|
1462
1575
|
useHook: false,
|
|
1463
1576
|
tenant_id: this.#tenant_id,
|
|
1464
1577
|
}),
|
|
@@ -1514,6 +1627,7 @@ class useRest {
|
|
|
1514
1627
|
|
|
1515
1628
|
session: sessionStorage(),
|
|
1516
1629
|
rest: new useRest({
|
|
1630
|
+
restId: this.#restId,
|
|
1517
1631
|
useCustomApi: false,
|
|
1518
1632
|
session: this.#session,
|
|
1519
1633
|
useHook: false,
|
|
@@ -1535,6 +1649,7 @@ class useRest {
|
|
|
1535
1649
|
update: update,
|
|
1536
1650
|
session: sessionStorage(),
|
|
1537
1651
|
rest: new useRest({
|
|
1652
|
+
restId: this.#restId,
|
|
1538
1653
|
useCustomApi: false,
|
|
1539
1654
|
session: this.#session,
|
|
1540
1655
|
useHook: false,
|
|
@@ -1551,6 +1666,7 @@ class useRest {
|
|
|
1551
1666
|
update: update,
|
|
1552
1667
|
id: id,
|
|
1553
1668
|
rest: new useRest({
|
|
1669
|
+
restId: this.#restId,
|
|
1554
1670
|
session: this.#session,
|
|
1555
1671
|
useHook: false,
|
|
1556
1672
|
tenant_id: this.#tenant_id,
|
|
@@ -1641,6 +1757,7 @@ class useRest {
|
|
|
1641
1757
|
session: sessionStorage(),
|
|
1642
1758
|
result: toJson(result?.doc),
|
|
1643
1759
|
rest: new useRest({
|
|
1760
|
+
restId: this.#restId,
|
|
1644
1761
|
useCustomApi: false,
|
|
1645
1762
|
session: this.#session,
|
|
1646
1763
|
useHook: false,
|
|
@@ -1662,6 +1779,7 @@ class useRest {
|
|
|
1662
1779
|
session: sessionStorage(),
|
|
1663
1780
|
result: toJson(result.doc),
|
|
1664
1781
|
rest: new useRest({
|
|
1782
|
+
restId: this.#restId,
|
|
1665
1783
|
useCustomApi: false,
|
|
1666
1784
|
session: this.#session,
|
|
1667
1785
|
useHook: false,
|
|
@@ -1725,6 +1843,7 @@ class useRest {
|
|
|
1725
1843
|
col.cache.invalidate({
|
|
1726
1844
|
operationType: "update",
|
|
1727
1845
|
rest: new useRest({
|
|
1846
|
+
restId: this.#restId,
|
|
1728
1847
|
useCustomApi: false,
|
|
1729
1848
|
session: this.#session,
|
|
1730
1849
|
useHook: false,
|
|
@@ -1880,6 +1999,7 @@ class useRest {
|
|
|
1880
1999
|
col.cache.invalidate({
|
|
1881
2000
|
operationType: "update",
|
|
1882
2001
|
rest: new useRest({
|
|
2002
|
+
restId: this.#restId,
|
|
1883
2003
|
useCustomApi: false,
|
|
1884
2004
|
session: this.#session,
|
|
1885
2005
|
useHook: false,
|
|
@@ -2036,6 +2156,7 @@ class useRest {
|
|
|
2036
2156
|
col.cache.invalidate({
|
|
2037
2157
|
operationType: "update",
|
|
2038
2158
|
rest: new useRest({
|
|
2159
|
+
restId: this.#restId,
|
|
2039
2160
|
useCustomApi: false,
|
|
2040
2161
|
session: this.#session,
|
|
2041
2162
|
useHook: false,
|
|
@@ -2394,6 +2515,7 @@ class useRest {
|
|
|
2394
2515
|
update: update,
|
|
2395
2516
|
session: sessionStorage(),
|
|
2396
2517
|
rest: new useRest({
|
|
2518
|
+
restId: this.#restId,
|
|
2397
2519
|
session: this.#session,
|
|
2398
2520
|
useCustomApi: false,
|
|
2399
2521
|
useHook: false,
|
|
@@ -2414,6 +2536,7 @@ class useRest {
|
|
|
2414
2536
|
update: update,
|
|
2415
2537
|
session: sessionStorage(),
|
|
2416
2538
|
rest: new useRest({
|
|
2539
|
+
restId: this.#restId,
|
|
2417
2540
|
session: this.#session,
|
|
2418
2541
|
useCustomApi: false,
|
|
2419
2542
|
useHook: false,
|
|
@@ -2430,6 +2553,7 @@ class useRest {
|
|
|
2430
2553
|
update: update,
|
|
2431
2554
|
ids: ids,
|
|
2432
2555
|
rest: new useRest({
|
|
2556
|
+
restId: this.#restId,
|
|
2433
2557
|
session: this.#session,
|
|
2434
2558
|
useHook: false,
|
|
2435
2559
|
tenant_id: this.#tenant_id,
|
|
@@ -2522,6 +2646,7 @@ class useRest {
|
|
|
2522
2646
|
result: toJson(result.docs),
|
|
2523
2647
|
io: Cfg.io,
|
|
2524
2648
|
rest: new useRest({
|
|
2649
|
+
restId: this.#restId,
|
|
2525
2650
|
session: this.#session,
|
|
2526
2651
|
useCustomApi: false,
|
|
2527
2652
|
useHook: false,
|
|
@@ -2543,6 +2668,7 @@ class useRest {
|
|
|
2543
2668
|
result: toJson(result.docs),
|
|
2544
2669
|
io: Cfg.io,
|
|
2545
2670
|
rest: new useRest({
|
|
2671
|
+
restId: this.#restId,
|
|
2546
2672
|
session: this.#session,
|
|
2547
2673
|
useCustomApi: false,
|
|
2548
2674
|
useHook: false,
|
|
@@ -2604,6 +2730,7 @@ class useRest {
|
|
|
2604
2730
|
col.cache.invalidate({
|
|
2605
2731
|
operationType: "update",
|
|
2606
2732
|
rest: new useRest({
|
|
2733
|
+
restId: this.#restId,
|
|
2607
2734
|
useCustomApi: false,
|
|
2608
2735
|
session: this.#session,
|
|
2609
2736
|
useHook: false,
|
|
@@ -2648,6 +2775,7 @@ class useRest {
|
|
|
2648
2775
|
action: "deleteOne",
|
|
2649
2776
|
session: sessionStorage(),
|
|
2650
2777
|
rest: new useRest({
|
|
2778
|
+
restId: this.#restId,
|
|
2651
2779
|
session: this.#session,
|
|
2652
2780
|
useCustomApi: false,
|
|
2653
2781
|
useHook: false,
|
|
@@ -2667,6 +2795,7 @@ class useRest {
|
|
|
2667
2795
|
action: "deleteOne",
|
|
2668
2796
|
session: sessionStorage(),
|
|
2669
2797
|
rest: new useRest({
|
|
2798
|
+
restId: this.#restId,
|
|
2670
2799
|
session: this.#session,
|
|
2671
2800
|
useCustomApi: false,
|
|
2672
2801
|
useHook: false,
|
|
@@ -2682,6 +2811,7 @@ class useRest {
|
|
|
2682
2811
|
session: sessionStorage(),
|
|
2683
2812
|
id: id,
|
|
2684
2813
|
rest: new useRest({
|
|
2814
|
+
restId: this.#restId,
|
|
2685
2815
|
session: this.#session,
|
|
2686
2816
|
useHook: false,
|
|
2687
2817
|
tenant_id: this.#tenant_id,
|
|
@@ -2719,6 +2849,7 @@ class useRest {
|
|
|
2719
2849
|
io: Cfg.io,
|
|
2720
2850
|
session: sessionStorage(),
|
|
2721
2851
|
rest: new useRest({
|
|
2852
|
+
restId: this.#restId,
|
|
2722
2853
|
session: this.#session,
|
|
2723
2854
|
useCustomApi: false,
|
|
2724
2855
|
useHook: false,
|
|
@@ -2738,6 +2869,7 @@ class useRest {
|
|
|
2738
2869
|
io: Cfg.io,
|
|
2739
2870
|
session: sessionStorage(),
|
|
2740
2871
|
rest: new useRest({
|
|
2872
|
+
restId: this.#restId,
|
|
2741
2873
|
session: this.#session,
|
|
2742
2874
|
useCustomApi: false,
|
|
2743
2875
|
useHook: false,
|
|
@@ -2801,6 +2933,7 @@ class useRest {
|
|
|
2801
2933
|
col.cache.invalidate({
|
|
2802
2934
|
operationType: "delete",
|
|
2803
2935
|
rest: new useRest({
|
|
2936
|
+
restId: this.#restId,
|
|
2804
2937
|
useCustomApi: false,
|
|
2805
2938
|
session: this.#session,
|
|
2806
2939
|
useHook: false,
|
|
@@ -2841,6 +2974,7 @@ class useRest {
|
|
|
2841
2974
|
session: sessionStorage(),
|
|
2842
2975
|
data: toJson(data),
|
|
2843
2976
|
rest: new useRest({
|
|
2977
|
+
restId: this.#restId,
|
|
2844
2978
|
session: this.#session,
|
|
2845
2979
|
useHook: false,
|
|
2846
2980
|
tenant_id: this.#tenant_id,
|
|
@@ -2882,6 +3016,7 @@ class useRest {
|
|
|
2882
3016
|
action: "deleteMany",
|
|
2883
3017
|
session: sessionStorage(),
|
|
2884
3018
|
rest: new useRest({
|
|
3019
|
+
restId: this.#restId,
|
|
2885
3020
|
session: this.#session,
|
|
2886
3021
|
useCustomApi: false,
|
|
2887
3022
|
useHook: false,
|
|
@@ -2901,6 +3036,7 @@ class useRest {
|
|
|
2901
3036
|
action: "deleteMany",
|
|
2902
3037
|
session: sessionStorage(),
|
|
2903
3038
|
rest: new useRest({
|
|
3039
|
+
restId: this.#restId,
|
|
2904
3040
|
session: this.#session,
|
|
2905
3041
|
useCustomApi: false,
|
|
2906
3042
|
useHook: false,
|
|
@@ -2916,6 +3052,7 @@ class useRest {
|
|
|
2916
3052
|
session: sessionStorage(),
|
|
2917
3053
|
ids: ids,
|
|
2918
3054
|
rest: new useRest({
|
|
3055
|
+
restId: this.#restId,
|
|
2919
3056
|
session: this.#session,
|
|
2920
3057
|
useHook: false,
|
|
2921
3058
|
tenant_id: this.#tenant_id,
|
|
@@ -2964,6 +3101,7 @@ class useRest {
|
|
|
2964
3101
|
result: contentIds,
|
|
2965
3102
|
session: sessionStorage(),
|
|
2966
3103
|
rest: new useRest({
|
|
3104
|
+
restId: this.#restId,
|
|
2967
3105
|
session: this.#session,
|
|
2968
3106
|
useCustomApi: false,
|
|
2969
3107
|
useHook: false,
|
|
@@ -2984,6 +3122,7 @@ class useRest {
|
|
|
2984
3122
|
result: contentIds,
|
|
2985
3123
|
session: sessionStorage(),
|
|
2986
3124
|
rest: new useRest({
|
|
3125
|
+
restId: this.#restId,
|
|
2987
3126
|
session: this.#session,
|
|
2988
3127
|
useCustomApi: false,
|
|
2989
3128
|
useHook: false,
|
|
@@ -3044,6 +3183,7 @@ class useRest {
|
|
|
3044
3183
|
col.cache.invalidate({
|
|
3045
3184
|
operationType: "delete",
|
|
3046
3185
|
rest: new useRest({
|
|
3186
|
+
restId: this.#restId,
|
|
3047
3187
|
useCustomApi: false,
|
|
3048
3188
|
session: this.#session,
|
|
3049
3189
|
useHook: false,
|
|
@@ -3121,6 +3261,14 @@ class useRest {
|
|
|
3121
3261
|
.dropIndex(indexName);
|
|
3122
3262
|
}
|
|
3123
3263
|
|
|
3264
|
+
|
|
3265
|
+
startSession(): ClientSession {
|
|
3266
|
+
this.#session = this.#tenant.database.client?.startSession()!;
|
|
3267
|
+
return this.#session!;
|
|
3268
|
+
}
|
|
3269
|
+
|
|
3270
|
+
|
|
3271
|
+
|
|
3124
3272
|
startTransaction(options?: { forceNew?: boolean; silent?: boolean }) {
|
|
3125
3273
|
try {
|
|
3126
3274
|
if (options?.forceNew) {
|
|
@@ -3139,11 +3287,18 @@ class useRest {
|
|
|
3139
3287
|
}
|
|
3140
3288
|
}
|
|
3141
3289
|
|
|
3142
|
-
async abortTransaction(options?: {
|
|
3290
|
+
async abortTransaction(options?: {
|
|
3291
|
+
silent?: boolean;
|
|
3292
|
+
closeSession?: boolean;
|
|
3293
|
+
}) {
|
|
3143
3294
|
return new Promise(async (resolve, reject) => {
|
|
3144
3295
|
try {
|
|
3145
3296
|
if (this.#session) {
|
|
3146
3297
|
await this.#session?.abortTransaction();
|
|
3298
|
+
if (options?.closeSession) {
|
|
3299
|
+
this.#session?.endSession();
|
|
3300
|
+
this.#session = null;
|
|
3301
|
+
}
|
|
3147
3302
|
return resolve(true);
|
|
3148
3303
|
}
|
|
3149
3304
|
} catch (err: any) {
|