@dnax/core 0.75.0 → 0.75.5
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 +7 -4
- package/driver/mongo/rest.ts +3 -2
- package/package.json +1 -1
- package/types/index.ts +3 -0
package/app/hono.ts
CHANGED
|
@@ -321,8 +321,11 @@ function HonoInstance(): typeof app {
|
|
|
321
321
|
const col = getCollection(collection, c.var["tenant-id"]);
|
|
322
322
|
|
|
323
323
|
// Controlle des actions à mener
|
|
324
|
-
if (!getAction(action) && !col?.
|
|
325
|
-
throw new ContextError(
|
|
324
|
+
if (!getAction(action) && !col?.actions?.hasOwnProperty(action)) {
|
|
325
|
+
throw new ContextError(
|
|
326
|
+
`Action ${action} not found on ${collection}`,
|
|
327
|
+
400
|
|
328
|
+
);
|
|
326
329
|
}
|
|
327
330
|
|
|
328
331
|
useCache = stringToBoolean(useCache, false);
|
|
@@ -657,8 +660,8 @@ function HonoInstance(): typeof app {
|
|
|
657
660
|
response = await rest.insertOne(collection, body?.data || {});
|
|
658
661
|
}
|
|
659
662
|
|
|
660
|
-
if (!getAction(action) && col?.
|
|
661
|
-
response = await rest.
|
|
663
|
+
if (!getAction(action) && col?.actions?.hasOwnProperty(action)) {
|
|
664
|
+
response = await rest.runAction(collection, action, body?.data || {});
|
|
662
665
|
}
|
|
663
666
|
|
|
664
667
|
if (action == "insertMany") {
|
package/driver/mongo/rest.ts
CHANGED
|
@@ -2355,13 +2355,14 @@ class useRest {
|
|
|
2355
2355
|
* @param data
|
|
2356
2356
|
* @returns
|
|
2357
2357
|
*/
|
|
2358
|
-
async
|
|
2358
|
+
async runAction(collection: string, actionName: string, data: any) {
|
|
2359
|
+
let action = actionName;
|
|
2359
2360
|
return new Promise(async (resolve, reject) => {
|
|
2360
2361
|
try {
|
|
2361
2362
|
let col = getCollection(collection, this.#tenant_id);
|
|
2362
2363
|
if (!col) return fn.error(`Collection ${collection} not found`, 404);
|
|
2363
2364
|
if (col?.customApi?.[action]) {
|
|
2364
|
-
let result = await col?.
|
|
2365
|
+
let result = await col?.actions?.[action]({
|
|
2365
2366
|
error: fn.error,
|
|
2366
2367
|
io: Cfg.io,
|
|
2367
2368
|
session: sessionStorage(),
|
package/package.json
CHANGED
package/types/index.ts
CHANGED