@dnax/core 0.54.1 → 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,
@@ -368,11 +372,14 @@ function HonoInstance(): typeof app {
368
372
  rest.activity.save({
369
373
  collection: collection,
370
374
  data: {
371
- input: body,
375
+ data: body,
372
376
  },
373
377
  action: "authCollection",
374
378
  auth: true,
379
+ transaction: false,
380
+ role: sessionStorage().get().role || null,
375
381
  user: sessionStorage().get().state?.user,
382
+ state: sessionStorage().get().state,
376
383
  ip:
377
384
  c.req.raw.headers?.get("CF-Connecting-IP") ||
378
385
  c.req.raw.headers?.get("x-forwarded-for") ||
@@ -389,11 +396,14 @@ function HonoInstance(): typeof app {
389
396
  rest.activity.save({
390
397
  collection: collection,
391
398
  data: {
392
- input: body,
399
+ data: body,
393
400
  },
401
+ transaction: false,
394
402
  action: "authCollection",
395
403
  auth: false,
396
404
  user: sessionStorage().get().state?.user,
405
+ state: sessionStorage().get().state,
406
+ role: sessionStorage().get().role || null,
397
407
  ip:
398
408
  c.req.raw.headers?.get("CF-Connecting-IP") ||
399
409
  c.req.raw.headers?.get("x-forwarded-for") ||
@@ -572,6 +582,38 @@ function HonoInstance(): typeof app {
572
582
  });
573
583
  }
574
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
+ }
575
617
  if (action == "findOne") {
576
618
  response = await rest.findOne(
577
619
  collection,
@@ -85,21 +85,34 @@ 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
- input: any;
91
+ update?: any;
92
+ data?: any;
93
+ input?: any;
94
+ filter?: any;
95
+ ids?: string[];
96
+ id?: string;
92
97
  };
93
98
  action: string;
94
99
  ip?: string;
95
100
  user?: object;
101
+ state?: object;
102
+ transaction?: boolean;
103
+ internal?: boolean;
104
+ auth?: boolean;
105
+ role?: string | null | undefined;
96
106
  }) => Promise<any>;
97
- list?: (filter?: {
98
- $match: {};
99
- $limit?: number;
100
- $sort?: {};
101
- $skip?: number;
102
- }) => 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>>;
103
116
  };
104
117
  meilisearch: {
105
118
  client: InstanceType<typeof MeiliSearch>;
@@ -121,7 +134,8 @@ class useRest {
121
134
  return await restActivity.save(this.#tenant, activityInput);
122
135
  },
123
136
  list: async (
124
- activityFilter
137
+ collection: string,
138
+ params?: findParam
125
139
  ): Promise<
126
140
  {
127
141
  [key: string]: any;
@@ -146,8 +160,15 @@ class useRest {
146
160
  };
147
161
  }[]
148
162
  > => {
163
+ params = {
164
+ ...params,
165
+ $match: {
166
+ ...(params?.$match || {}),
167
+ collection: collection,
168
+ },
169
+ };
149
170
  return await restActivity
150
- .list(this.#tenant, activityFilter || {})
171
+ .list(this.#tenant, params || {})
151
172
  .then((e) => e)
152
173
  .catch((err) => []);
153
174
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.54.1",
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 = {