Docs/API Reference/Plugins

Actions and models

@veap/plugins/actions exposes the Server Actions the client widgets call, and @veap/plugins/models exposes the persistence models the plugin system uses.

2 min read

@veap/plugins/actions exposes the Server Actions the client widgets call, and @veap/plugins/models exposes the persistence models the plugin system uses.

Server Actions#

plugin.actions.ts ("use server") filters by the current session user before returning plugin-provided UI state:

ActionSignatureBehavior
getPluginExtensionsAction(target, point, includeDisabled = false)returns extension descriptorsResolves extensions with the user's roles/permissions.
getPluginWidgetsAction(area)returns widgetsResolves widgets with the user's roles/permissions.
getUserWidgetsState(slot)WidgetState[] | nullThe saved widget layout for the current user and slot, or null when signed out.
saveUserWidgetsState(slot, state){ success: true }Persists the layout; throws AppError.Unauthorized when signed out.

These back the client hooks/components; see Client hooks and components.

Models#

SystemPlugin (plugins table)#

Persists plugin status.

  • static table = "plugins", autoUuid = false, timestamps = ["updated_at"].
  • Attributes: id, enabled, installed, deleted, system, config?, lastStep?/last_step?, updatedAt/updated_at.
  • Casts: enabled, installed, deleted, system as booleans; the timestamps as datetimes.

The default ActiveRecordPluginRepository reads/writes this table; see Registry.

SystemUserWidget (system_user_widgets table)#

Stores a user's saved widget layout per slot.

  • static table = "system_user_widgets", primaryKey = "user_id", autoUuid = false, timestamps = false.
  • Attributes: userId/user_id, slot, state.
  • Casts: state as JSON.
  • user() — belongsTo(User, "user_id").

The stored state is the array of { id, enabled, colSpan, rowSpan? } entries the client composer produces; the composer also creates spacer-* entries with no backing widget.

Migrations#

The plugin tables are created by the package's migrations (exported from @veap/plugins/migrations and run by PluginsServiceProvider/runPluginMigrations). They are not created by these models automatically.

veap
Preparing0%