@dnax/core 0.70.7 → 0.71.0
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 +40 -16
- package/driver/mongo/rest.ts +14 -0
- package/package.json +1 -1
package/app/hono.ts
CHANGED
|
@@ -385,15 +385,26 @@ function HonoInstance(): typeof app {
|
|
|
385
385
|
responseAuth
|
|
386
386
|
) {
|
|
387
387
|
rest.activity.save({
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
388
|
+
operation: {
|
|
389
|
+
status: "done",
|
|
390
|
+
type: "authCollection",
|
|
391
|
+
target: collection,
|
|
392
|
+
user: sessionStorage().get().state?.user,
|
|
393
|
+
role: sessionStorage().get().role,
|
|
394
|
+
state: sessionStorage().get().state,
|
|
395
|
+
transaction: false,
|
|
396
|
+
internal: false,
|
|
397
|
+
uuid: sessionStorage().get()?.uuid || "",
|
|
398
|
+
payload: {
|
|
399
|
+
input: body,
|
|
400
|
+
data: body,
|
|
401
|
+
},
|
|
402
|
+
auth: true,
|
|
403
|
+
performedBy: {
|
|
404
|
+
user: sessionStorage().get().state?.user,
|
|
405
|
+
role: sessionStorage().get()?.role || "",
|
|
406
|
+
},
|
|
391
407
|
},
|
|
392
|
-
action: "authCollection",
|
|
393
|
-
auth: true,
|
|
394
|
-
transaction: false,
|
|
395
|
-
role: sessionStorage().get().role || null,
|
|
396
|
-
user: sessionStorage().get().state?.user,
|
|
397
408
|
state: sessionStorage().get().state,
|
|
398
409
|
uuid: sessionStorage().get().uuid,
|
|
399
410
|
ip:
|
|
@@ -410,16 +421,29 @@ function HonoInstance(): typeof app {
|
|
|
410
421
|
});
|
|
411
422
|
} else {
|
|
412
423
|
rest.activity.save({
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
424
|
+
operation: {
|
|
425
|
+
status: "failed",
|
|
426
|
+
type: "authCollection",
|
|
427
|
+
target: collection,
|
|
428
|
+
user: sessionStorage().get().state?.user,
|
|
429
|
+
role: sessionStorage().get().role,
|
|
430
|
+
state: sessionStorage().get().state,
|
|
431
|
+
transaction: false,
|
|
432
|
+
internal: false,
|
|
433
|
+
uuid: sessionStorage().get()?.uuid || "",
|
|
434
|
+
payload: {
|
|
435
|
+
input: body,
|
|
436
|
+
data: body,
|
|
437
|
+
},
|
|
438
|
+
auth: true,
|
|
439
|
+
performedBy: {
|
|
440
|
+
user: sessionStorage().get().state?.user,
|
|
441
|
+
role: sessionStorage().get()?.role || "",
|
|
442
|
+
},
|
|
416
443
|
},
|
|
417
|
-
|
|
418
|
-
action: "authCollection",
|
|
419
|
-
auth: false,
|
|
420
|
-
user: sessionStorage().get().state?.user,
|
|
444
|
+
|
|
421
445
|
state: sessionStorage().get().state,
|
|
422
|
-
|
|
446
|
+
|
|
423
447
|
uuid: sessionStorage().get().uuid,
|
|
424
448
|
ip:
|
|
425
449
|
c.req.raw.headers?.get("CF-Connecting-IP") ||
|
package/driver/mongo/rest.ts
CHANGED
|
@@ -83,6 +83,7 @@ const omitUpdate = [
|
|
|
83
83
|
type activityInput = {
|
|
84
84
|
collection?: string;
|
|
85
85
|
operation: {
|
|
86
|
+
status?: "done" | "failed";
|
|
86
87
|
uuid: string;
|
|
87
88
|
type: string;
|
|
88
89
|
auth?: boolean;
|
|
@@ -127,6 +128,7 @@ class useRest {
|
|
|
127
128
|
db: Tenant["database"]["db"];
|
|
128
129
|
activity: {
|
|
129
130
|
save: (activity: activityInput) => Promise<any>;
|
|
131
|
+
aggregate: (pipeline: Array<object>) => Promise<Array<any>>;
|
|
130
132
|
list: (
|
|
131
133
|
collection: string,
|
|
132
134
|
filter?: {
|
|
@@ -154,6 +156,9 @@ class useRest {
|
|
|
154
156
|
client: this.#tenant.searchEngine?.meilisearch?.client!,
|
|
155
157
|
};
|
|
156
158
|
this.activity = {
|
|
159
|
+
aggregate: async (pipeline: Array<object>) => {
|
|
160
|
+
return await restActivity.aggregate(this.#tenant, pipeline);
|
|
161
|
+
},
|
|
157
162
|
save: async (activityInput: activityInput) => {
|
|
158
163
|
return await restActivity.save(this.#tenant, activityInput);
|
|
159
164
|
},
|
|
@@ -292,6 +297,7 @@ class useRest {
|
|
|
292
297
|
let useHook = options?.useHook ?? this.#useHook;
|
|
293
298
|
let sharedData = {};
|
|
294
299
|
let col = getCollection(collection, this.#tenant_id);
|
|
300
|
+
|
|
295
301
|
if (!col) return fn.error(`Collection ${collection} not found`, 404);
|
|
296
302
|
|
|
297
303
|
if (col?.hooks?.beforeOperation && useHook) {
|
|
@@ -2607,6 +2613,14 @@ const restActivity = {
|
|
|
2607
2613
|
$skip?: number;
|
|
2608
2614
|
}
|
|
2609
2615
|
) => {},
|
|
2616
|
+
aggregate: async (tenant: Tenant, pipeline: Array<object>): Promise<any> => {
|
|
2617
|
+
return await tenant.database.db
|
|
2618
|
+
?.collection("_activity_")
|
|
2619
|
+
.aggregate(toBson(pipeline), {
|
|
2620
|
+
allowDiskUse: true,
|
|
2621
|
+
})
|
|
2622
|
+
.toArray();
|
|
2623
|
+
},
|
|
2610
2624
|
save: async (tenant: Tenant, activity: activityInput) => {
|
|
2611
2625
|
return await tenant.database.db
|
|
2612
2626
|
?.collection("_activity_")
|