@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 CHANGED
@@ -17,6 +17,7 @@ const actions = [
17
17
  "batch",
18
18
  "count",
19
19
  "search",
20
+ "listActivity",
20
21
  ];
21
22
 
22
23
  function getAction(action: string) {
package/app/hono.ts CHANGED
@@ -210,7 +210,11 @@ function HonoInstance(): typeof app {
210
210
  return await next();
211
211
  }
212
212
 
213
- if (col && (col?.access?.allAction || col?.access?.hasOwnProperty("*"))) {
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,
@@ -85,7 +85,7 @@ class useRest {
85
85
  */
86
86
  db: Tenant["database"]["db"];
87
87
  activity: {
88
- save?: (activity: {
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?: (filter?: {
108
- $match: {};
109
- $limit?: number;
110
- $sort?: {};
111
- $skip?: number;
112
- }) => Promise<Array<any>>;
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
- activityFilter
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, activityFilter || {})
171
+ .list(this.#tenant, params || {})
161
172
  .then((e) => e)
162
173
  .catch((err) => []);
163
174
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.54.2",
3
+ "version": "0.54.3",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {
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 = {