2021-09-09 22:38:39 +08:00
|
|
|
import Koa from 'koa';
|
2021-12-06 21:23:34 +08:00
|
|
|
import { Database } from '@nocobase/database';
|
|
|
|
import { Action } from '@nocobase/resourcer';
|
2022-10-10 15:37:47 +08:00
|
|
|
import { Cache } from '@nocobase/cache';
|
2021-12-16 16:46:54 +08:00
|
|
|
import lodash from 'lodash';
|
|
|
|
import * as actions from './actions';
|
2021-09-09 22:38:39 +08:00
|
|
|
|
2022-03-27 15:51:48 +08:00
|
|
|
export * as utils from './utils';
|
|
|
|
|
2021-09-09 22:38:39 +08:00
|
|
|
export type Next = () => Promise<any>;
|
|
|
|
|
|
|
|
export interface Context extends Koa.Context {
|
|
|
|
db: Database;
|
2022-10-10 15:37:47 +08:00
|
|
|
cache: Cache;
|
2021-09-09 22:38:39 +08:00
|
|
|
action: Action;
|
|
|
|
body: any;
|
2022-04-09 14:54:46 +08:00
|
|
|
app: any;
|
2022-10-10 15:37:47 +08:00
|
|
|
|
2021-12-06 21:23:34 +08:00
|
|
|
[key: string]: any;
|
2021-09-09 22:38:39 +08:00
|
|
|
}
|
|
|
|
|
2021-12-16 16:46:54 +08:00
|
|
|
export function registerActions(api: any) {
|
|
|
|
api.actions(
|
2023-06-06 11:36:18 +08:00
|
|
|
lodash.pick(actions, [
|
|
|
|
'add',
|
|
|
|
'create',
|
|
|
|
'destroy',
|
|
|
|
'get',
|
|
|
|
'list',
|
|
|
|
'remove',
|
|
|
|
'set',
|
|
|
|
'toggle',
|
|
|
|
'update',
|
|
|
|
'move',
|
|
|
|
'firstOrCreate',
|
|
|
|
'updateOrCreate',
|
|
|
|
]),
|
2021-12-16 16:46:54 +08:00
|
|
|
);
|
|
|
|
}
|
2021-09-09 22:38:39 +08:00
|
|
|
|
2022-01-18 16:38:03 +08:00
|
|
|
export default actions;
|