ObjectStackObjectStack

Plugin Lifecycle Events

Plugin Lifecycle Events protocol schemas

Plugin Lifecycle Events Protocol

Zod schemas for plugin lifecycle event data structures.

These schemas align with the IPluginLifecycleEvents contract interface.

Following ObjectStack "Zod First" principle - all data structures

must have Zod schemas for runtime validation and JSON Schema generation.

Source: packages/spec/src/kernel/plugin-lifecycle-events.zod.ts

TypeScript Usage

import { EventPhase, HookRegisteredEvent, HookTriggeredEvent, KernelEventBase, KernelReadyEvent, KernelShutdownEvent, PluginErrorEvent, PluginEventBase, PluginLifecycleEventType, PluginLifecyclePhaseEvent, PluginRegisteredEvent, ServiceRegisteredEvent, ServiceUnregisteredEvent } from '@objectstack/spec/kernel';
import type { EventPhase, HookRegisteredEvent, HookTriggeredEvent, KernelEventBase, KernelReadyEvent, KernelShutdownEvent, PluginErrorEvent, PluginEventBase, PluginLifecycleEventType, PluginLifecyclePhaseEvent, PluginRegisteredEvent, ServiceRegisteredEvent, ServiceUnregisteredEvent } from '@objectstack/spec/kernel';

// Validate data
const result = EventPhase.parse(data);

EventPhase

Plugin lifecycle phase

Allowed Values

  • init
  • start
  • destroy

HookRegisteredEvent

Properties

PropertyTypeRequiredDescription
hookNamestringName of the hook
timestampintegerUnix timestamp in milliseconds
handlerCountintegerNumber of handlers registered for this hook

HookTriggeredEvent

Properties

PropertyTypeRequiredDescription
hookNamestringName of the hook
timestampintegerUnix timestamp in milliseconds
argsany[]Arguments passed to the hook handlers
handlerCountintegeroptionalNumber of handlers that will handle this event

KernelEventBase

Properties

PropertyTypeRequiredDescription
timestampintegerUnix timestamp in milliseconds

KernelReadyEvent

Properties

PropertyTypeRequiredDescription
timestampintegerUnix timestamp in milliseconds
durationnumberoptionalTotal initialization duration in milliseconds
pluginCountintegeroptionalNumber of plugins initialized

KernelShutdownEvent

Properties

PropertyTypeRequiredDescription
timestampintegerUnix timestamp in milliseconds
reasonstringoptionalReason for kernel shutdown

PluginErrorEvent

Properties

PropertyTypeRequiredDescription
pluginNamestringName of the plugin
timestampintegerUnix timestamp in milliseconds when event occurred
errorObjectSerializable error representation
phaseEnum<'init' | 'start' | 'destroy'>Lifecycle phase where error occurred
errorMessagestringoptionalError message
errorStackstringoptionalError stack trace

PluginEventBase

Properties

PropertyTypeRequiredDescription
pluginNamestringName of the plugin
timestampintegerUnix timestamp in milliseconds when event occurred

PluginLifecycleEventType

Plugin lifecycle event type

Allowed Values

  • kernel:ready
  • kernel:shutdown
  • kernel:before-init
  • kernel:after-init
  • plugin:registered
  • plugin:before-init
  • plugin:init
  • plugin:after-init
  • plugin:before-start
  • plugin:started
  • plugin:after-start
  • plugin:before-destroy
  • plugin:destroyed
  • plugin:after-destroy
  • plugin:error
  • service:registered
  • service:unregistered
  • hook:registered
  • hook:triggered

PluginLifecyclePhaseEvent

Properties

PropertyTypeRequiredDescription
pluginNamestringName of the plugin
timestampintegerUnix timestamp in milliseconds when event occurred
durationnumberoptionalDuration of the lifecycle phase in milliseconds
phaseEnum<'init' | 'start' | 'destroy'>optionalLifecycle phase

PluginRegisteredEvent

Properties

PropertyTypeRequiredDescription
pluginNamestringName of the plugin
timestampintegerUnix timestamp in milliseconds when event occurred
versionstringoptionalPlugin version

ServiceRegisteredEvent

Properties

PropertyTypeRequiredDescription
serviceNamestringName of the registered service
timestampintegerUnix timestamp in milliseconds
serviceTypestringoptionalType or interface name of the service

ServiceUnregisteredEvent

Properties

PropertyTypeRequiredDescription
serviceNamestringName of the unregistered service
timestampintegerUnix timestamp in milliseconds

On this page