import { Entity, User } from "@rebasepro/types"; import { RebaseContext, AdminCollection } from "@rebasepro/cms-types"; import { RebaseData } from "@rebasepro/types"; /** * @group Hooks and utilities */ export type DeleteEntityWithCallbacksProps, USER extends User = User> = { entity: Entity; collection?: AdminCollection; onDeleteSuccess?: (entity: Entity) => void; onDeleteFailure?: (entity: Entity, e: Error) => void; }; /** * This function is in charge of deleting a entity. * * It runs the collection's **`admin.browserCallbacks`** around the delete — * `beforeDelete`, then `afterDelete`. Not `callbacks`: that block belongs to * the server, which runs it inside the delete it serves, and its bodies are * stripped from this bundle entirely. * * Which matters most for a collection on a `direct`/`custom` transport, where * the panel talks to the store itself and no server sees the delete at all — * before this ran them, such a collection had no delete callbacks anywhere. * This function has been named `deleteEntityWithCallbacks` since it was written * and did not run any; it even took a `callbacks` prop and ignored it. * * A `beforeDelete` that throws blocks the delete, exactly as the server's does: * nothing is sent, and `onDeleteFailure` hears about it. * * @param data * @param entity * @param collection * @param onDeleteSuccess * @param onDeleteFailure * @param context * @group Hooks and utilities */ export declare function deleteEntityWithCallbacks, USER extends User>({ data, entity, collection, onDeleteSuccess, onDeleteFailure, context }: DeleteEntityWithCallbacksProps & { collection: AdminCollection; data: RebaseData; context: RebaseContext; }): Promise;