Skip to content
MSO CloudDocumentation

Plugin development

On this page

An optional feature or connector is a plugin: a declarative manifest plus the code it describes, gating a page, a menu item and a data route.

The plugin contract#

Identity, tenancy, RLS, roles, warehouse, i18n and audit are always on; everything optional is a plugin in one compiled catalog, never loaded dynamically.

Artifact Lives in
Manifest packages/plugin-host/src/registry.ts
tRPC router apps/web/src/server/routers/<feature>.ts
Pages apps/web/src/app/(dashboard)/<feature>/
API routes apps/web/src/app/api/<feature>/
Tables and RLS packages/schema/src/tables/
Copy packages/i18n/src/messages/{vi,en}.ts
Pure logic, shared UI a workspace package (optional)

Manifest fields

The schema in packages/plugin-host/src/manifest.ts is strict and parsed at module load, so an unknown key fails the build.

Field Required Meaning
id yes Stable kebab-case id, also the persisted installation key; never renamed
version yes Manifest version, written on each installation row
nameKey, descriptionKey yes Catalog card copy; must resolve in Vietnamese and English
category yes ai_decision, analytics, growth, operations, market_intelligence or data_source (connectors)
navItemIds yes Menu ids the plugin owns, hidden while it is off; [] when headless
replacesNavItemIds no Generic menu ids hidden while this plugin is on; hides from the menu only
providesPillars features only Metric pillars it owns; one owner per pillar, asserted at load; ecom has none
providesCapabilities connectors only Organization capabilities an active credential of this connector is evidence for
defaultEnabled yes On where the shape runs a home domain; true without one fails the build
legacyOrgFlag yes null for every new plugin
prerequisite yes ai_config (the organization needs a saved AI key) or none
dependsOn no Plugins that must be on first, transitively; the graph must be acyclic
kind no (default feature) feature, connector, satellite or shared_feed (entitlement-only plugin over a platform-synced dataset)
connectorFamily connectors only marketplace, marketing, dataset, market_intel or content_intel; the family is the data plane
transport connectors only api, file or both
vertical, servesDomains connectors only The catalog heading and every domain one credential can serve
thirdPartyData connectors only The data describes the market rather than the organization; renders the third-party badge
providerId connectors only The worker connector registry id or parser id that implements it
clientId satellites only The OIDC client id the app is registered under in the issuer
launchUrl satellites only An https URL on the app's own origin; the launcher opens it. An environment variable named after the client id (<CLIENTID>_URL) overrides it
scopes satellites only Platform API scopes the app may request, platform:<plane>.<verb>
planIds satellites only Plan ids an installation may carry

Gate API

From @yng/plugin-host, inside the caller's tenant scope; the caller owns the super-admin bypass and role checks.

Function Returns
isPluginEnabledForOrg(orgId, id) Whether one plugin is on for one organization
getEnabledPluginIdsForOrg(orgId) The whole enabled set, one query
getDisabledNavItemsForOrg(orgId) Menu ids to hide because their plugin is off
getReplacedNavItemsForOrg(orgId) Generic menu ids hidden by an active tailored pack
orgHasConnectorFamily(orgId, family) Whether the org has a live credential in a family

The installation row decides: no row means off (only the legacy chatAssistantEnabled flag is read when the row is missing), a row counts only while enabled, active, active or trial status and before validTo (installBlockReason, packages/plugin-host/src/resolve.ts), and a plugin is also off while anything in dependsOn is off. A reconcile derives each organization's rows from its shape on blueprint apply, domain activation and every deploy, never overriding a super admin's manual row.

Where entitlement is enforced

OnOff, or no rowDependency offSuper admin, plugin offPage (requirePlugin)rendersnot-found in shellnot-found in shellrendersMenu (layout)item shownitem hiddenitem hiddenhidden; reach by URLData (dedicated procedure)answersFORBIDDENFORBIDDENanswersOff: the installation row is disabled or inactive, or there is no row (a missing row is not an entitlement).Dependency off: a plugin in dependsOn is off, transitively; the gate derives this at read time and writes nothing.Super admin: the guard and the procedure return before reading the row; the caller owns that bypass, never the gate.
What each layer does per state. Hiding a menu item is never the gate: the page guard and the dedicated procedure are, and both let a super admin through.

A dedicated page, deep links included, calls requirePlugin('<id>') first; a console page uses requireAdminTenantPlugin. A new plugin gets its own router on a dedicated procedure, like chatProcedure. Routers core pages also read stay on orgProcedure, so a plugin turned off cannot break a core surface.

How to#

Add a plugin

The step-by-step checklist is Add an optional feature (plugin); a connector follows Add a data source and a satellite Connect a satellite app.

Verify#

pnpm tsx scripts/audit/plugin-manifest-validity.ts
pnpm run typecheck && pnpm run lint
pnpm run audit:all
pnpm --filter @yng/web build

A cached typecheck can pass on stale output, so run the build. Then toggle the plugin for a test organization at /admin/orgs/<slug>/plugins and confirm the menu item and the not-found page follow.

Troubleshoot#

Symptom Cause Fix
Build fails at module load with a manifest parse error An unknown key, or a field on the wrong kind Check the cross-field rules above
The plugin is on in the catalog but its menu item never shows The organization's hidden-menu list hides it, or a dependency is off Un-hide the item, or enable the dependency
A gate read returns off for every organization in a script The script did not open a tenant scope Pin each organization before reading installation rows
A toggle is blocked in the admin catalog The plugin needs a saved AI key, or a dependsOn plugin is off Enable the dependency first; enabling never cascades
  • Never rename a plugin id; add a new plugin and bump version for changes.
  • org_plugin_installations.config is reserved; a plugin's settings belong in its own tables or settings page.