Skip to main content

IPluginContext

Plugin Docs


Interface: IPluginContext<TDb, TConfig>

Defined in: plugins/types.ts:62

Plugin context provided to all lifecycle hooks Contains database, logger, and other shared resources

Property Availability

PropertyAvailabilityNotes
dbOptional - provided when db access is neededGuard for undefined; throw PluginError if required but missing
loggerRequired - guaranteed in all hooksAlways present; use context.logger.info()
configGuaranteed after onInstallMay be undefined in onInstall; always present in other hooks
  • If db is undefined when required, throw a descriptive error
  • If config is missing, use sensible defaults or throw during onActivate

Example

onActivate: async (context: IPluginContext<MyDb, MyConfig>) => {
if (!context.db) {
throw new Error('Database connection required for Razorpay plugin');
}
context.logger.info('Razorpay plugin activated');
}

Type Parameters

TDb

TDb = unknown

Type for the database connection (e.g., DrizzleORM instance)

TConfig

TConfig = PluginConfig

Type for plugin configuration (defaults to PluginConfig)

Properties

config?

optional config: TConfig

Defined in: plugins/types.ts:85

Plugin configuration from manifest

Remarks

Guaranteed after onInstall; may be undefined during initial onInstall call


db?

optional db: TDb

Defined in: plugins/types.ts:67

Database connection for plugin data access

Remarks

May be undefined if the host system doesn't provide db access for this hook


graphql?

optional graphql: IPluginGraphQL

Defined in: plugins/types.ts:97

GraphQL instance for plugin schema registration and execution

Remarks

Optional - provided when GraphQL access is needed


isActive?

optional isActive: boolean

Defined in: plugins/types.ts:91

Current plugin activation state (for idempotency checks)

Remarks

Plugins should check this before performing activation-only tasks


logger

logger: object

Defined in: plugins/types.ts:74

Logger instance for plugin logging (use instead of console.*)

debug()

debug: (...args) => void

Parameters
args

...JsonValue[]

Returns

void

error()

error: (...args) => void

Parameters
args

...JsonValue[]

Returns

void

info()

info: (...args) => void

Parameters
args

...JsonValue[]

Returns

void

warn()

warn: (...args) => void

Parameters
args

...JsonValue[]

Returns

void

Remarks

Guaranteed to be present by the plugin host in all lifecycle hooks. This property is required and always available.


pubsub?

optional pubsub: IPluginPubSub

Defined in: plugins/types.ts:103

PubSub instance for plugin real-time events

Remarks

Optional - provided when PubSub access is needed