Adapter hooks
An adapter hook receives the final Adapter getter and the previous implementation. It returns a method with the original signature:
import type { OberonAdapter, OberonPluginAdapter } from "@oberoncms/core"
type Hook<Key extends keyof OberonPluginAdapter> = (context: {
getAdapter: () => Omit<OberonAdapter, Key>
next: OberonPluginAdapter[Key]
}) => OberonPluginAdapter[Key]The exported OberonPluginAdapterHooks type makes each method optional. Supply only the methods
your plugin implements or wraps.
Middleware
Use next to call the previous implementation. Later plugins wrap earlier plugins. For
[database, tailwind, framework], a page update enters the framework hook first and the database
method last.
import type { OberonPlugin } from "@oberoncms/core"
export const plugin: OberonPlugin = () => ({
name: "page-log",
adapter: {
updatePageData:
({ next }) =>
async (page) => {
await next(page)
console.info("Page updated", page.key)
},
},
})Call getAdapter() only from the returned method. It throws during factory initialization. Its
static return type omits the current method to discourage self-recursion. A provider can ignore
next to replace an earlier method.
Method groups
Use the exported types for exact signatures. Methods with input receive one object. Methods without input take no arguments.
| Type | Methods |
|---|---|
OberonDatabaseAdapter | addPage, deletePage, getAllPages, getPageData, updatePageData, addImage, deleteImage, getAllImages, getSite, updateSite, getKV, putKV, deleteKV, addUser, deleteUser, getAllUsers, changeRole |
OberonCanAdapter | getCurrentUser, hasPermission, signIn, signOut |
OberonAuthAdapter | getAuthDatabase, getAuthPlugins |
OberonRoutingAdapter | redirect, notFound, getRequestHeaders |
OberonSendAdapter | sendVerificationRequest |
hasPermission returns a boolean synchronously. The final Adapter also supplies permission helpers,
route dispatch, and component migration. See Authentication for access checks.
Bootstrap
Use a top-level bootstrap task for migrations or initial data, not an adapter hook. See Plugin shape for its no-argument callback and Adapter access.