Skip to main content

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, hooks useEntity, useConfig, useApi.

Types (main package)​

Entity and drafts​

TypeDescription
EntitySubset of a catalog entity: id, kind, namespace, name, title?, description?, tags?, links?, owner_ref?, lifecycle?, spec?.
EntityDraftUsed by catalog providers: same as Entity but without id; may include relations?, sources?.

UI capabilities​

TypeDescription
EntityTabAppliesTo{ kinds?: string[]; lifecycle?: string[] }. Optional filter for which entities show the tab.
EntityTabid, title, component (React component receiving entity), appliesTo?.
EntityCardid, title, component (React component receiving entity), appliesTo?.kinds?.
Routepath, component, navLabel?, icon?.

Action provider and context​

TypeDescription
JsonSchemaMinimal JSON Schema: type, title?, description?, properties?, required?, items?, enum?, default?, x-secret?.
JsonSchemaType`'string'
ActionResult`status: 'success'
ActionLoggerinfo, warn, error (message + optional meta).
ActionScmAccessorgetFile(repoUrl, path, ref?), listFiles(repoUrl, prefix?).
ActionDbAccessorquery(sql, params?) (read-only, returns array of rows).
ActionConfigAccessorget(key) returns `T
ActionContextconfig, logger, scm, db, acquireRepoLock(repoUrl), log(level, message).
ActionProviderid, version, schema: { input, output? }, handler(ctx, input).

Catalog provider​

TypeDescription
CatalogProviderContextlogger, config.
CatalogProviderid, ingest(ctx): AsyncIterable<EntityDraft>.

SDK interfaces​

TypeDescription
ForgePluginSDKUI SDK: registerEntityTab, registerEntityCard, registerRoute, registerActionProvider, registerCatalogProvider.
BackendRoutepath, handler: (fastify: FastifyInstance) => Promise<void>.
ForgeBackendPluginSDKconfig, logger, registerActionProvider, registerCatalogProvider, registerBackendRoute.

Manifest​

TypeDescription
PluginConfigFieldSchematype, description?, required?, secret?, default?.
PluginCapabilitiesui?: { entityTabs?, entityCards?, routes? }, backend?: { routes?, actionProviders?, catalogProviders? }.
PluginManifestname, version, forgeportal: { engineVersion, type, capabilities, permissions?, config? }.

Exports (main package)​

ExportDescription
PluginRegistryClass implementing ForgePluginSDK; in-memory registry for UI plugins.
globalRegistrySingleton PluginRegistry used by the app shell.
BackendPluginRegistryClass implementing ForgeBackendPluginSDK; used by the API plugin loader.
SDK_VERSIONString (e.g. '1.0.0') for engine version checks.

React package (@forgeportal/plugin-sdk/react)​

Context providers (for app shell)​

ExportDescription
EntityProviderProvides the current entity to children. Used by the entity detail page when rendering tabs/cards.
EntityContextReact context for the entity.
PluginConfigProviderProvides plugin config (key β†’ value) to children.
PluginConfigContextReact context for plugin config.

Hooks​

HookSignatureDescription
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 | undefinedReturns 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.