function
defineAdminPlugin
Package a Go plugin’s field editors, pages, and other admin components into one export that applications can install.
Example
import {
defineAdminPlugin,
definePluginField
} from '@riducms/plugin/authoring/v1';
import ColorField from './color-field.svelte';
import { decodeColor } from './value';
export const colorAdminPlugin = defineAdminPlugin({
key: 'color',
pairingVersion: 1,
fields: {
color: definePluginField({
component: ColorField,
decodeValue: decodeColor
})
}
});Arguments
| Argument | Description |
|---|---|
plugin | Required object with key and pairingVersion, plus any field editors or other admin components the plugin provides. Do not supply apiVersion; the versioned import adds it. |
Plugin options
| Property | Type | Description |
|---|---|---|
key | string | Required. Match the Go plugin’s Key(), for example color or editorial-tools. Use a lowercase key with hyphens between words. |
pairingVersion | number | Required positive integer. Match Admin.PairingVersion in the Go descriptor. Increase it when an older Go or admin package would no longer work with the other. |
fields | AdminPlugin["fields"] | Optional. Map Go field-type keys to definePluginField results. These become the default editors for those new field types; the keys match PluginFieldType.Key in Go. |
fieldEditors | AdminPlugin["fieldEditors"] | Optional. Map component names to defineFieldComponent results. Go chooses an alternative editor with field.PluginComponent(pluginKey, componentName). |
rowLabels | readonly RowLabelPlugin[] | Optional. Row headings made with defineRowLabelPlugin. Go selects them with field.PluginComponent in Admin.RowLabel. |
messages | PluginMessageCatalog | Optional. Translations bundled with the plugin, created with defineAdminMessages. |
assets | readonly string[] | Optional. Package-relative modules or styles imported during the admin build. Keep the list and order identical to Admin.Assets in the Go descriptor. |
routes | readonly AdminRoute[] | Optional. Add pages inside the admin, each with a relative path, component, and optional navigation link. Plugin routes must also appear in the Go descriptor. |
dashboardPanels | readonly AdminDashboardPanel[] | Optional. Add panels before or after the dashboard, or replace it. Each entry names a key, component, and position; the default position is after. |
listCellRenderers | readonly AdminListCellRenderer[] | Optional. Change how a field appears in a collection table. Each entry selects a collection, field path, and component. |
listResultsRenderers | readonly AdminListResultsRenderer[] | Optional. Replace a collection's results layout while keeping its queries, search, filters, pagination, and selection. Cannot target a collection with a whole-list view replacement. |
documentViews | readonly AdminDocumentView[] | Optional. Add tabs beside Edit and API on saved documents or globals. Each entry includes a key, label, and component; collection can limit where it appears. |
documentActions | readonly AdminDocumentAction[] | Optional. Add buttons to saved collection documents. A component implements the action; an optional requires permission hides it when the user lacks that permission. |
coreViews | readonly AdminCoreView[] | Optional. Wrap or replace collection lists, create/edit forms, global editors, or the not-found page. The component can render defaultView to keep the built-in screen. |
branding | readonly AdminBrandComponent[] | Optional. Replace the login logo, navigation logo, or account avatar. Each location accepts one replacement. |
navigation | readonly AdminNavigationComponent[] | Optional. Add content around the navigation links or replace navigation. Use routes for a new page with its own navigation link. |
login | readonly AdminLoginComponent[] | Optional. Add content before or after sign-in, or replace the screen. A replacement can render defaultView to retain the login form. |
account | readonly AdminAccountComponent[] | Optional. Add content to or replace the profile or security screen, selected by surface. |
logoutButton | AdminLogoutButton | Optional. Replace the account menu’s sign-out control. The component receives host.logout() to end the session. |
shellSlots | readonly AdminShellSlot[] | Optional. Add a component to the header, global actions, or account settings menu. |
providers | readonly AdminProvider[] | Optional. Share context between components by wrapping the admin. The first provider is outermost; every provider must render defaultView. |
Returns
A frozen copy of the plugin with apiVersion: 1. Its fields and fieldEditors maps are also copied and frozen. TypeScript retains each field’s inferred value and input types. Export this result using the name declared by Go Admin.Export.
Plugin & { readonly apiVersion: 1; }How it works
Import from @riducms/plugin/authoring/v1 in the plugin’s JavaScript package. The Go descriptor identifies that package with Admin.Package and its named export with Admin.Export.
Use defineAdmin for components that belong directly to an application. Use defineAdminPlugin when publishing admin behavior alongside a Go plugin, even if that plugin only contributes UI.
fields provides default editors for new field types declared by Go. components provides alternative editors that an application explicitly selects on an existing field. One plugin may provide several of each.
The helper validates metadata and registrations immediately. It does not install the Go package or mount UI. Applications install both packages and load the generated registration through defineAdmin({ plugins: generatedAdminPlugins }).
key and pairingVersion must agree with Go. Do not set apiVersion yourself or spread a previously registered plugin into this helper. Run ridu check in an application to check the connection to its Go descriptor.
The example exports colorAdminPlugin. The field-plugin guide contains ColorField, decodeColor, the Go descriptor, and installation steps.
Full signature
function defineAdminPlugin<const Plugin extends Omit<AdminPlugin, "apiVersion">>(
plugin: Plugin & { apiVersion?: never; },
): Plugin & { readonly apiVersion: 1; }Related types
AdminPluginA Go plugin’s exported collection of admin field editors, pages, and other components.
RowLabelPluginOne exact plugin-owned component available to array and blocks row headings.
PluginMessageCatalogA validated plugin-owned fallback catalog and its language catalogs.
AdminRouteA plugin route mounted beneath the authenticated admin layout.
AdminDashboardPanelA component composed around or replacing the framework dashboard overview.
AdminListCellRendererA renderer for one exact collection and field pair.
AdminListResultsRendererCollection-specific results layout. Trash retains its framework restore/delete controls.
AdminDocumentViewA read-only or operational view rendered beside Edit and API.
AdminDocumentActionAn action rendered beside framework document actions.
AdminCoreViewA replacement or wrapper for collection, global, or not-found routes.
AdminBrandComponentA replacement graphic at an exact branding surface.
AdminNavigationComponentA component inserted into or replacing framework navigation.
AdminLoginComponentA component composed around or replacing sign-in.
AdminAccountComponentA component composed around or replacing profile or security.
AdminLogoutButtonThe single optional replacement for the account-menu sign-out control.
AdminShellSlotA component inserted at a global shell position.
AdminProviderA Svelte context provider wrapping the remaining provider stack and admin.