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