diff --git a/packages/plugin-ui-schema-storage/src/server-hooks/hooks/removeSchema.ts b/packages/plugin-ui-schema-storage/src/server-hooks/hooks/removeSchema.ts new file mode 100644 index 0000000000..4a43219842 --- /dev/null +++ b/packages/plugin-ui-schema-storage/src/server-hooks/hooks/removeSchema.ts @@ -0,0 +1,18 @@ +import { hookFactory } from './factory'; +import { UiSchemaRepository } from '@nocobase/plugin-ui-schema-storage'; + +export async function removeSchema({ schemaInstance, options, db, params }) { + const { transaction } = options; + const uiSchemaRepository: UiSchemaRepository = db.getRepository('ui_schemas'); + const uid = schemaInstance.get('uid') as string; + + if (params?.removeEmptyParents) { + await uiSchemaRepository.removeEmptyParents({ + uid, + breakComponent: params['breakComponent'], + transaction, + }); + } else { + await uiSchemaRepository.remove(uid); + } +}