@dnax/core 0.54.2 → 0.54.3
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/ctrl.ts +1 -0
- package/app/hono.ts +37 -1
- package/driver/mongo/rest.ts +20 -9
- package/package.json +1 -1
- package/types/index.ts +6 -1
package/app/ctrl.ts
CHANGED
package/app/hono.ts
CHANGED
|
@@ -210,7 +210,11 @@ function HonoInstance(): typeof app {
|
|
|
210
210
|
return await next();
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
if (
|
|
213
|
+
if (
|
|
214
|
+
col &&
|
|
215
|
+
(col?.access?.allAction || col?.access?.hasOwnProperty("*")) &&
|
|
216
|
+
!col?.access?.hasOwnProperty(action)
|
|
217
|
+
) {
|
|
214
218
|
let accesFx = col?.access?.allAction || col?.access?.["*"];
|
|
215
219
|
nextLifecyle = await accesFx({
|
|
216
220
|
token: c.var["token"] || null,
|
|
@@ -578,6 +582,38 @@ function HonoInstance(): typeof app {
|
|
|
578
582
|
});
|
|
579
583
|
}
|
|
580
584
|
}
|
|
585
|
+
|
|
586
|
+
if (action == "listActivity") {
|
|
587
|
+
if (col?.hooks?.beforeListActivity) {
|
|
588
|
+
await col?.hooks?.beforeListActivity({
|
|
589
|
+
io: Cfg.io,
|
|
590
|
+
data: body,
|
|
591
|
+
c: c,
|
|
592
|
+
rest: rest,
|
|
593
|
+
action: "listActivity",
|
|
594
|
+
params: body?.params,
|
|
595
|
+
session: sessionStorage(),
|
|
596
|
+
error: fn.error,
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
response = await rest.activity.list(collection, {
|
|
600
|
+
...body?.params,
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
if (col?.hooks?.afterListActivity) {
|
|
604
|
+
await col?.hooks?.afterListActivity({
|
|
605
|
+
io: Cfg.io,
|
|
606
|
+
data: body,
|
|
607
|
+
c: c,
|
|
608
|
+
rest: rest,
|
|
609
|
+
action: "listActivity",
|
|
610
|
+
params: body?.params,
|
|
611
|
+
session: sessionStorage(),
|
|
612
|
+
error: fn.error,
|
|
613
|
+
result: response,
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
}
|
|
581
617
|
if (action == "findOne") {
|
|
582
618
|
response = await rest.findOne(
|
|
583
619
|
collection,
|
package/driver/mongo/rest.ts
CHANGED
|
@@ -85,7 +85,7 @@ class useRest {
|
|
|
85
85
|
*/
|
|
86
86
|
db: Tenant["database"]["db"];
|
|
87
87
|
activity: {
|
|
88
|
-
save
|
|
88
|
+
save: (activity: {
|
|
89
89
|
collection?: string;
|
|
90
90
|
data: {
|
|
91
91
|
update?: any;
|
|
@@ -104,12 +104,15 @@ class useRest {
|
|
|
104
104
|
auth?: boolean;
|
|
105
105
|
role?: string | null | undefined;
|
|
106
106
|
}) => Promise<any>;
|
|
107
|
-
list
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
list: (
|
|
108
|
+
collection: string,
|
|
109
|
+
filter?: {
|
|
110
|
+
$match: {};
|
|
111
|
+
$limit?: number;
|
|
112
|
+
$sort?: {};
|
|
113
|
+
$skip?: number;
|
|
114
|
+
}
|
|
115
|
+
) => Promise<Array<any>>;
|
|
113
116
|
};
|
|
114
117
|
meilisearch: {
|
|
115
118
|
client: InstanceType<typeof MeiliSearch>;
|
|
@@ -131,7 +134,8 @@ class useRest {
|
|
|
131
134
|
return await restActivity.save(this.#tenant, activityInput);
|
|
132
135
|
},
|
|
133
136
|
list: async (
|
|
134
|
-
|
|
137
|
+
collection: string,
|
|
138
|
+
params?: findParam
|
|
135
139
|
): Promise<
|
|
136
140
|
{
|
|
137
141
|
[key: string]: any;
|
|
@@ -156,8 +160,15 @@ class useRest {
|
|
|
156
160
|
};
|
|
157
161
|
}[]
|
|
158
162
|
> => {
|
|
163
|
+
params = {
|
|
164
|
+
...params,
|
|
165
|
+
$match: {
|
|
166
|
+
...(params?.$match || {}),
|
|
167
|
+
collection: collection,
|
|
168
|
+
},
|
|
169
|
+
};
|
|
159
170
|
return await restActivity
|
|
160
|
-
.list(this.#tenant,
|
|
171
|
+
.list(this.#tenant, params || {})
|
|
161
172
|
.then((e) => e)
|
|
162
173
|
.catch((err) => []);
|
|
163
174
|
},
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -65,6 +65,7 @@ export type Actions =
|
|
|
65
65
|
| "authCollection"
|
|
66
66
|
| "aggregate"
|
|
67
67
|
| "upload"
|
|
68
|
+
| "listActivity"
|
|
68
69
|
| "search";
|
|
69
70
|
|
|
70
71
|
type omitWhenType = "insertOne" | "insertMany" | "updateOne" | "updateMany";
|
|
@@ -399,6 +400,8 @@ export type Collection = {
|
|
|
399
400
|
afterUpload?: hooksCtx;
|
|
400
401
|
beforeSearch?: hooksCtx;
|
|
401
402
|
afterSearch?: hooksCtx;
|
|
403
|
+
beforeListActivity?: hooksCtx;
|
|
404
|
+
afterListActivity?: hooksCtx;
|
|
402
405
|
};
|
|
403
406
|
access?: {
|
|
404
407
|
"*"?: accessCtx;
|
|
@@ -417,6 +420,7 @@ export type Collection = {
|
|
|
417
420
|
upload?: accessCtx;
|
|
418
421
|
count?: accessCtx;
|
|
419
422
|
search?: accessCtx;
|
|
423
|
+
activity?: accessCtx;
|
|
420
424
|
};
|
|
421
425
|
tenant_id?: string;
|
|
422
426
|
slug: string;
|
|
@@ -604,7 +608,8 @@ export type Q = {
|
|
|
604
608
|
| "batch"
|
|
605
609
|
| "count"
|
|
606
610
|
| "execToolkit"
|
|
607
|
-
| "search"
|
|
611
|
+
| "search"
|
|
612
|
+
| "listActivity";
|
|
608
613
|
};
|
|
609
614
|
|
|
610
615
|
export type routeOption = {
|