mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 10:58:43 +00:00
chore: server hooks
This commit is contained in:
parent
0526e4ff1f
commit
85ab936c4c
@ -1,13 +1,5 @@
|
||||
import { MagicAttributeModel } from '@nocobase/database';
|
||||
import { HookType } from './server-hooks';
|
||||
|
||||
class UiSchemaModel extends MagicAttributeModel {
|
||||
getListenServerHooks(type: HookType) {
|
||||
const hooks = this.get('x-server-hooks') || [];
|
||||
return hooks.filter((hook) => {
|
||||
hook.type = '';
|
||||
});
|
||||
}
|
||||
}
|
||||
class UiSchemaModel extends MagicAttributeModel {}
|
||||
|
||||
export { UiSchemaModel };
|
||||
|
@ -2,7 +2,7 @@ import { Database } from '@nocobase/database';
|
||||
import { ServerHookModel } from './model';
|
||||
|
||||
export type HookType =
|
||||
| 'onSchemaDestroy'
|
||||
| 'onSelfDestroy'
|
||||
| 'onCollectionDestroy'
|
||||
| 'onCollectionFieldDestroy'
|
||||
| 'onAnyCollectionFieldDestroy'
|
||||
@ -82,16 +82,16 @@ export class ServerHooks {
|
||||
);
|
||||
}
|
||||
|
||||
protected async onUiSchemaCreate(uiSchemaModel, options) {
|
||||
protected async onUiSchemaCreate(schemaInstance, options) {
|
||||
const { transaction } = options;
|
||||
|
||||
await this.findHooksAndCall(
|
||||
{
|
||||
type: 'onSelfCreate',
|
||||
uid: uiSchemaModel.schema['x-uid'],
|
||||
uid: schemaInstance.schema['x-uid'],
|
||||
},
|
||||
{
|
||||
uiSchemaModel,
|
||||
schemaInstance,
|
||||
options,
|
||||
},
|
||||
transaction,
|
||||
|
Loading…
Reference in New Issue
Block a user