SDK Reference
This page lists the public exports of @forgeportal/plugin-sdk and @forgeportal/plugin-sdk/react: types, interfaces, hooks, and the main SDK objects. Use it as a quick reference while writing plugins.
Package entry pointsβ
@forgeportal/plugin-sdkβ Types,PluginRegistry,BackendPluginRegistry,SDK_VERSION, and backend types.@forgeportal/plugin-sdk/reactβ React context providers, hooksuseEntity,useConfig,useApi.
Types (main package)β
Entity and draftsβ
| Type | Description |
|---|---|
Entity | Subset of a catalog entity: id, kind, namespace, name, title?, description?, tags?, links?, owner_ref?, lifecycle?, spec?. |
EntityDraft | Used by catalog providers: same as Entity but without id; may include relations?, sources?. |
UI capabilitiesβ
| Type | Description |
|---|---|
EntityTabAppliesTo | { kinds?: string[]; lifecycle?: string[] }. Optional filter for which entities show the tab. |
EntityTab | id, title, component (React component receiving entity), appliesTo?. |
EntityCard | id, title, component (React component receiving entity), appliesTo?.kinds?. |
Route | path, component, navLabel?, icon?. |
Action provider and contextβ
| Type | Description |
|---|---|
JsonSchema | Minimal JSON Schema: type, title?, description?, properties?, required?, items?, enum?, default?, x-secret?. |
JsonSchemaType | `'string' |
ActionResult | `status: 'success' |
ActionLogger | info, warn, error (message + optional meta). |
ActionScmAccessor | getFile(repoUrl, path, ref?), listFiles(repoUrl, prefix?). |
ActionDbAccessor | query(sql, params?) (read-only, returns array of rows). |
ActionConfigAccessor | get(key) returns `T |
ActionContext | config, logger, scm, db, acquireRepoLock(repoUrl), log(level, message). |
ActionProvider | id, version, schema: { input, output? }, handler(ctx, input). |
Catalog providerβ
| Type | Description |
|---|---|
CatalogProviderContext | logger, config. |
CatalogProvider | id, ingest(ctx): AsyncIterable<EntityDraft>. |
SDK interfacesβ
| Type | Description |
|---|---|
ForgePluginSDK | UI SDK: registerEntityTab, registerEntityCard, registerRoute, registerActionProvider, registerCatalogProvider. |
BackendRoute | path, handler: (fastify: FastifyInstance) => Promise<void>. |
ForgeBackendPluginSDK | config, logger, registerActionProvider, registerCatalogProvider, registerBackendRoute. |
Manifestβ
| Type | Description |
|---|---|
PluginConfigFieldSchema | type, description?, required?, secret?, default?. |
PluginCapabilities | ui?: { entityTabs?, entityCards?, routes? }, backend?: { routes?, actionProviders?, catalogProviders? }. |
PluginManifest | name, version, forgeportal: { engineVersion, type, capabilities, permissions?, config? }. |
Exports (main package)β
| Export | Description |
|---|---|
PluginRegistry | Class implementing ForgePluginSDK; in-memory registry for UI plugins. |
globalRegistry | Singleton PluginRegistry used by the app shell. |
BackendPluginRegistry | Class implementing ForgeBackendPluginSDK; used by the API plugin loader. |
SDK_VERSION | String (e.g. '1.0.0') for engine version checks. |
React package (@forgeportal/plugin-sdk/react)β
Context providers (for app shell)β
| Export | Description |
|---|---|
EntityProvider | Provides the current entity to children. Used by the entity detail page when rendering tabs/cards. |
EntityContext | React context for the entity. |
PluginConfigProvider | Provides plugin config (key β value) to children. |
PluginConfigContext | React context for plugin config. |
Hooksβ
| Hook | Signature | Description |
|---|---|---|
useEntity() | (): { entity: Entity } | Returns the current entity. Must be used inside a component rendered as an EntityTab or EntityCard (inside EntityProvider). Throws if used outside. |
useConfig (generic) | (key: string): T | undefined | Returns the plugin-scoped config value for key. Config comes from forgeportal.yaml under plugins.[pluginId].config. |
useApi (generic) | (path, options?) β UseQueryResult<T, Error> | Fetches path (same origin, credentials included) and returns a TanStack Query result. Use for calling your pluginβs backend routes or other API endpoints. |
Example: UI tab using hooksβ
import { useEntity, useConfig, useApi } from '@forgeportal/plugin-sdk/react';
function MyTab() {
const { entity } = useEntity();
const apiUrl = useConfig<string>('apiEndpoint');
const { data, isPending, error } = useApi<{ items: unknown[] }>(
`/api/v1/plugins/myplugin/data/${entity.id}`,
);
if (isPending) return <span>Loadingβ¦</span>;
if (error) return <span>Error: {error.message}</span>;
return <pre>{JSON.stringify(data?.items ?? [], null, 2)}</pre>;
}
Example: action handler using contextβ
import type { ActionProvider } from '@forgeportal/plugin-sdk';
const myAction: ActionProvider = {
id: 'myplugin.doIt',
version: 'v1',
schema: { input: { type: 'object', properties: {}, required: [] } },
async handler(ctx, input) {
const endpoint = ctx.config.get<string>('apiEndpoint');
await ctx.log('info', 'Startingβ¦');
ctx.logger.info('Running', { endpoint });
return { status: 'success', outputs: {} };
},
};
For full manifest field reference, see Plugin Manifest.