@dnax/core 0.75.5 → 0.76.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 CHANGED
@@ -321,6 +321,7 @@ function HonoInstance(): typeof app {
321
321
  const col = getCollection(collection, c.var["tenant-id"]);
322
322
 
323
323
  // Controlle des actions à mener
324
+
324
325
  if (!getAction(action) && !col?.actions?.hasOwnProperty(action)) {
325
326
  throw new ContextError(
326
327
  `Action ${action} not found on ${collection}`,
@@ -364,7 +365,7 @@ function HonoInstance(): typeof app {
364
365
  // if action and collection
365
366
  //getCollection(collection, c.var["tenant-id"]
366
367
  if (
367
- getAction(action) &&
368
+ (getAction(action) || col?.actions?.hasOwnProperty(action)) &&
368
369
  getCollection(collection, c.var["tenant-id"]) &&
369
370
  collection
370
371
  ) {
@@ -660,6 +661,8 @@ function HonoInstance(): typeof app {
660
661
  response = await rest.insertOne(collection, body?.data || {});
661
662
  }
662
663
 
664
+ // perform Actions
665
+
663
666
  if (!getAction(action) && col?.actions?.hasOwnProperty(action)) {
664
667
  response = await rest.runAction(collection, action, body?.data || {});
665
668
  }
@@ -2361,7 +2361,9 @@ class useRest {
2361
2361
  try {
2362
2362
  let col = getCollection(collection, this.#tenant_id);
2363
2363
  if (!col) return fn.error(`Collection ${collection} not found`, 404);
2364
- if (col?.customApi?.[action]) {
2364
+ if (!col?.actions?.hasOwnProperty(action))
2365
+ return fn.error(`Action ${action} not found on ${collection}`, 404);
2366
+ if (col?.actions?.[action]) {
2365
2367
  let result = await col?.actions?.[action]({
2366
2368
  error: fn.error,
2367
2369
  io: Cfg.io,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.75.5",
3
+ "version": "0.76.0",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {},
package/types/index.ts CHANGED
@@ -174,7 +174,7 @@ export type cronConfig = {
174
174
 
175
175
  export type middlewareCtx = (ctx: {
176
176
  token?: string;
177
- action?: Actions;
177
+ action?: Actions & string;
178
178
  c?: Context;
179
179
  isAuth: boolean;
180
180
  rest: InstanceType<typeof useRest>;