@dnax/core 0.76.7 → 0.76.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/driver/mongo/rest.ts +184 -0
- package/package.json +1 -1
- package/types/index.ts +2 -0
package/driver/mongo/rest.ts
CHANGED
|
@@ -378,6 +378,22 @@ class useRest {
|
|
|
378
378
|
}),
|
|
379
379
|
});
|
|
380
380
|
}
|
|
381
|
+
if (col?.hooks?.afterOperation && useHook) {
|
|
382
|
+
await col.hooks.afterOperation({
|
|
383
|
+
io: Cfg.io,
|
|
384
|
+
sharedData: sharedData,
|
|
385
|
+
docs: result.docs,
|
|
386
|
+
c: this.#c,
|
|
387
|
+
driver: "mongodb",
|
|
388
|
+
action: "aggregate",
|
|
389
|
+
session: sessionStorage(),
|
|
390
|
+
result: result.docs,
|
|
391
|
+
rest: new useRest({
|
|
392
|
+
useHook: false,
|
|
393
|
+
tenant_id: this.#tenant_id,
|
|
394
|
+
}),
|
|
395
|
+
});
|
|
396
|
+
}
|
|
381
397
|
|
|
382
398
|
return resolve(toJson(result.docs));
|
|
383
399
|
} catch (err) {
|
|
@@ -543,6 +559,25 @@ class useRest {
|
|
|
543
559
|
});
|
|
544
560
|
}
|
|
545
561
|
|
|
562
|
+
if (col?.hooks?.afterOperation && useHook) {
|
|
563
|
+
await col.hooks.afterOperation({
|
|
564
|
+
sharedData: sharedData,
|
|
565
|
+
data: toJson(data),
|
|
566
|
+
c: this.#c,
|
|
567
|
+
io: Cfg.io,
|
|
568
|
+
driver: "mongodb",
|
|
569
|
+
result: toJson(data),
|
|
570
|
+
action: "insertOne",
|
|
571
|
+
session: sessionStorage(),
|
|
572
|
+
rest: new useRest({
|
|
573
|
+
useCustomApi: false,
|
|
574
|
+
session: this.#session,
|
|
575
|
+
useHook: false,
|
|
576
|
+
tenant_id: this.#tenant_id,
|
|
577
|
+
}),
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
|
|
546
581
|
// if action done
|
|
547
582
|
restActivity.save(this.#tenant, {
|
|
548
583
|
operation: {
|
|
@@ -725,6 +760,25 @@ class useRest {
|
|
|
725
760
|
});
|
|
726
761
|
}
|
|
727
762
|
|
|
763
|
+
if (col?.hooks?.afterOperation && useHook) {
|
|
764
|
+
await col.hooks.afterOperation({
|
|
765
|
+
sharedData: sharedData,
|
|
766
|
+
data: toJson(data),
|
|
767
|
+
c: this.#c,
|
|
768
|
+
io: Cfg.io,
|
|
769
|
+
driver: "mongodb",
|
|
770
|
+
action: "insertMany",
|
|
771
|
+
result: toJson(data),
|
|
772
|
+
session: sessionStorage(),
|
|
773
|
+
rest: new useRest({
|
|
774
|
+
session: this.#session,
|
|
775
|
+
useCustomApi: false,
|
|
776
|
+
useHook: false,
|
|
777
|
+
tenant_id: this.#tenant_id,
|
|
778
|
+
}),
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
|
|
728
782
|
// if insertMany done
|
|
729
783
|
restActivity.save(this.#tenant, {
|
|
730
784
|
uuid: sessionStorage()?.get()?.uuid,
|
|
@@ -943,6 +997,25 @@ class useRest {
|
|
|
943
997
|
});
|
|
944
998
|
}
|
|
945
999
|
|
|
1000
|
+
if (col?.hooks?.afterOperation && useHook) {
|
|
1001
|
+
await col.hooks.afterOperation({
|
|
1002
|
+
sharedData: sharedData,
|
|
1003
|
+
c: this.#c,
|
|
1004
|
+
io: Cfg.io,
|
|
1005
|
+
driver: "mongodb",
|
|
1006
|
+
action: "find",
|
|
1007
|
+
meta: {},
|
|
1008
|
+
count: result?.docs?.length || 0,
|
|
1009
|
+
params: toJson(params),
|
|
1010
|
+
session: sessionStorage(),
|
|
1011
|
+
result: result.docs,
|
|
1012
|
+
rest: new useRest({
|
|
1013
|
+
useHook: false,
|
|
1014
|
+
tenant_id: this.#tenant_id,
|
|
1015
|
+
}),
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
|
|
946
1019
|
let resultDocs = toJson([...(result?.docs || [])]);
|
|
947
1020
|
|
|
948
1021
|
if (typeof options?.elementAt == "number" && options?.elementAt) {
|
|
@@ -1205,6 +1278,24 @@ class useRest {
|
|
|
1205
1278
|
});
|
|
1206
1279
|
}
|
|
1207
1280
|
|
|
1281
|
+
if (col?.hooks?.afterOperation && useHook) {
|
|
1282
|
+
await col.hooks.afterOperation({
|
|
1283
|
+
sharedData: sharedData,
|
|
1284
|
+
c: this.#c,
|
|
1285
|
+
io: Cfg.io,
|
|
1286
|
+
driver: "mongodb",
|
|
1287
|
+
action: "find",
|
|
1288
|
+
params: params,
|
|
1289
|
+
session: sessionStorage(),
|
|
1290
|
+
result: result.docs,
|
|
1291
|
+
count: result?.docs?.length || 0,
|
|
1292
|
+
rest: new useRest({
|
|
1293
|
+
useHook: false,
|
|
1294
|
+
tenant_id: this.#tenant_id,
|
|
1295
|
+
}),
|
|
1296
|
+
});
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1208
1299
|
let resultDocs = toJson([...(result?.docs || [])]);
|
|
1209
1300
|
return resolve(resultDocs?.length);
|
|
1210
1301
|
} catch (err) {
|
|
@@ -1335,6 +1426,23 @@ class useRest {
|
|
|
1335
1426
|
});
|
|
1336
1427
|
}
|
|
1337
1428
|
|
|
1429
|
+
if (col?.hooks?.afterOperation && useHook) {
|
|
1430
|
+
await col.hooks.afterOperation({
|
|
1431
|
+
sharedData: sharedData,
|
|
1432
|
+
c: this.#c,
|
|
1433
|
+
io: Cfg.io,
|
|
1434
|
+
driver: "mongodb",
|
|
1435
|
+
action: "findOne",
|
|
1436
|
+
params: params,
|
|
1437
|
+
session: sessionStorage(),
|
|
1438
|
+
result: docs,
|
|
1439
|
+
rest: new useRest({
|
|
1440
|
+
useHook: false,
|
|
1441
|
+
tenant_id: this.#tenant_id,
|
|
1442
|
+
}),
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1338
1446
|
return resolve(docs?.length ? toJson(docs[0]) : null);
|
|
1339
1447
|
} catch (err) {
|
|
1340
1448
|
return reject(err);
|
|
@@ -1516,6 +1624,25 @@ class useRest {
|
|
|
1516
1624
|
}),
|
|
1517
1625
|
});
|
|
1518
1626
|
}
|
|
1627
|
+
if (col?.hooks?.afterOperation && useHook) {
|
|
1628
|
+
await col.hooks.afterOperation({
|
|
1629
|
+
sharedData: sharedData,
|
|
1630
|
+
c: this.#c,
|
|
1631
|
+
driver: "mongodb",
|
|
1632
|
+
id: id,
|
|
1633
|
+
io: Cfg.io,
|
|
1634
|
+
action: "updateOne",
|
|
1635
|
+
update: update,
|
|
1636
|
+
session: sessionStorage(),
|
|
1637
|
+
result: toJson(result.doc),
|
|
1638
|
+
rest: new useRest({
|
|
1639
|
+
useCustomApi: false,
|
|
1640
|
+
session: this.#session,
|
|
1641
|
+
useHook: false,
|
|
1642
|
+
tenant_id: this.#tenant_id,
|
|
1643
|
+
}),
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1519
1646
|
|
|
1520
1647
|
if (
|
|
1521
1648
|
this.#tenant?.searchEngine?.meilisearch?.enabled &&
|
|
@@ -2100,6 +2227,26 @@ class useRest {
|
|
|
2100
2227
|
});
|
|
2101
2228
|
}
|
|
2102
2229
|
|
|
2230
|
+
if (col?.hooks?.afterOperation && useHook) {
|
|
2231
|
+
await col.hooks.afterOperation({
|
|
2232
|
+
sharedData: sharedData,
|
|
2233
|
+
c: this.#c,
|
|
2234
|
+
driver: "mongodb",
|
|
2235
|
+
ids: ids,
|
|
2236
|
+
action: "updateMany",
|
|
2237
|
+
update: update,
|
|
2238
|
+
session: sessionStorage(),
|
|
2239
|
+
result: toJson(result.docs),
|
|
2240
|
+
io: Cfg.io,
|
|
2241
|
+
rest: new useRest({
|
|
2242
|
+
session: this.#session,
|
|
2243
|
+
useCustomApi: false,
|
|
2244
|
+
useHook: false,
|
|
2245
|
+
tenant_id: this.#tenant_id,
|
|
2246
|
+
}),
|
|
2247
|
+
});
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2103
2250
|
if (
|
|
2104
2251
|
this.#tenant?.searchEngine?.meilisearch?.enabled &&
|
|
2105
2252
|
col?.searchEngine?.meilisearch?.dispatchAction == "auto"
|
|
@@ -2273,6 +2420,24 @@ class useRest {
|
|
|
2273
2420
|
}),
|
|
2274
2421
|
});
|
|
2275
2422
|
}
|
|
2423
|
+
if (col?.hooks?.afterOperation && useHook) {
|
|
2424
|
+
await col.hooks.afterOperation({
|
|
2425
|
+
sharedData: sharedData,
|
|
2426
|
+
id: id,
|
|
2427
|
+
c: this.#c,
|
|
2428
|
+
driver: "mongodb",
|
|
2429
|
+
action: "deleteOne",
|
|
2430
|
+
result: toJson(doc),
|
|
2431
|
+
io: Cfg.io,
|
|
2432
|
+
session: sessionStorage(),
|
|
2433
|
+
rest: new useRest({
|
|
2434
|
+
session: this.#session,
|
|
2435
|
+
useCustomApi: false,
|
|
2436
|
+
useHook: false,
|
|
2437
|
+
tenant_id: this.#tenant_id,
|
|
2438
|
+
}),
|
|
2439
|
+
});
|
|
2440
|
+
}
|
|
2276
2441
|
|
|
2277
2442
|
if (
|
|
2278
2443
|
this.#tenant?.searchEngine?.meilisearch?.enabled &&
|
|
@@ -2491,6 +2656,25 @@ class useRest {
|
|
|
2491
2656
|
});
|
|
2492
2657
|
}
|
|
2493
2658
|
|
|
2659
|
+
if (col?.hooks?.afterOperation && useHook) {
|
|
2660
|
+
await col.hooks.afterOperation({
|
|
2661
|
+
sharedData: sharedData,
|
|
2662
|
+
ids: ids,
|
|
2663
|
+
c: this.#c,
|
|
2664
|
+
driver: "mongodb",
|
|
2665
|
+
io: Cfg.io,
|
|
2666
|
+
action: "deleteMany",
|
|
2667
|
+
result: deletedIds,
|
|
2668
|
+
session: sessionStorage(),
|
|
2669
|
+
rest: new useRest({
|
|
2670
|
+
session: this.#session,
|
|
2671
|
+
useCustomApi: false,
|
|
2672
|
+
useHook: false,
|
|
2673
|
+
tenant_id: this.#tenant_id,
|
|
2674
|
+
}),
|
|
2675
|
+
});
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2494
2678
|
if (
|
|
2495
2679
|
this.#tenant?.searchEngine?.meilisearch?.enabled &&
|
|
2496
2680
|
col?.searchEngine?.meilisearch?.dispatchAction == "auto"
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -377,6 +377,7 @@ export type Collection = {
|
|
|
377
377
|
afterSearch?: hooksCtx;
|
|
378
378
|
beforeListActivity?: hooksCtx;
|
|
379
379
|
afterListActivity?: hooksCtx;
|
|
380
|
+
afterOperation?: hooksCtx;
|
|
380
381
|
};
|
|
381
382
|
access?:{
|
|
382
383
|
[key:string]:accessCtx;
|
|
@@ -499,6 +500,7 @@ export type TimeSeriesCollection = Collection &{
|
|
|
499
500
|
afterSearch?: hooksCtx;
|
|
500
501
|
beforeListActivity?: hooksCtx;
|
|
501
502
|
afterListActivity?: hooksCtx;
|
|
503
|
+
afterOperation?: hooksCtx;
|
|
502
504
|
};
|
|
503
505
|
access?: {
|
|
504
506
|
"*"?: accessCtx;
|