Content Events
When integrated with @bluecadet/launchpad-controller, the content package emits lifecycle events throughout the fetch process. All events are fully type-safe through TypeScript declaration merging.
Fetch Lifecycle Events
content:fetch:start
Emitted when the content fetch process begins.
Payload:
{
timestamp: Date; // When the fetch started
}Example:
eventBus.on('content:fetch:start', (data) => {
console.log(`Content fetch started at ${data.timestamp.toISOString()}`);
});content:fetch:done
Emitted when all content has been successfully fetched.
Payload:
{
sources: string[]; // IDs of sources that were fetched
}Example:
eventBus.on('content:fetch:done', (data) => {
console.log(`Sources: ${data.sources.join(', ')}`);
});content:fetch:error
Emitted when the fetch process encounters an error.
Payload:
{
error: Error; // The error that occurred
source?: string; // Optional: ID of the source that failed
}Example:
eventBus.on('content:fetch:error', (data) => {
console.error('Content fetch failed:', data.error);
if (data.source) {
console.error(`Failed source: ${data.source}`);
}
});Source Events
content:source:start
Emitted when a content source begins fetching.
Payload:
{
sourceId: string; // ID of the source
sourceType: string; // Type of source (e.g., 'sanity', 'contentful')
}Example:
eventBus.on('content:source:start', (data) => {
console.log(`Fetching from ${data.sourceType} source: ${data.sourceId}`);
});content:source:done
Emitted when a source completes successfully.
Payload:
{
sourceId: string; // ID of the source
}Example:
eventBus.on('content:source:done', (data) => {
console.log(`Source ${data.sourceId} fetched`);
});content:source:error
Emitted when a source encounters an error.
Payload:
{
sourceId: string; // ID of the source
error: Error; // The error that occurred
}Example:
eventBus.on('content:source:error', (data) => {
console.error(`Source ${data.sourceId} failed:`, data.error);
});Document Events
content:document:write
Emitted when a document is successfully written into the current fetch run's staged output.
Payload:
{
sourceId: string; // ID of the source
documentId: string; // ID of the document
path: string; // Absolute staged file path for this run
}path points at the staged file under tempPath/runs/<runId>/downloads/..., not the final published file under downloadPath. After a successful run, Launchpad promotes the staged tree into downloadPath.
Example:
eventBus.on('content:document:write', (data) => {
console.log(`Wrote staged document ${data.documentId} to ${data.path}`);
});content:document:error
Emitted when a document write fails.
Payload:
{
sourceId: string; // ID of the source
documentId: string; // ID of the document
error: Error; // The error that occurred
}Example:
eventBus.on('content:document:error', (data) => {
console.error(`Failed to write document ${data.documentId}:`, data.error);
});Transform Events
content:transform:start
Emitted when a content transform begins processing.
Payload:
{
transformName: string; // Name of the transform
}Example:
eventBus.on('content:transform:start', (data) => {
console.log(`Running transform: ${data.transformName}`);
});content:transform:done
Emitted when a transform completes successfully.
Payload:
{
transformName: string; // Name of the transform
duration: number; // Time taken in milliseconds
}Example:
eventBus.on('content:transform:done', (data) => {
console.log(`Transform ${data.transformName} completed in ${data.duration}ms`);
});content:transform:error
Emitted when a transform encounters an error.
Payload:
{
transformName: string; // Name of the transform
error: Error; // The error that occurred
}Example:
eventBus.on('content:transform:error', (data) => {
console.error(`Transform ${data.transformName} failed:`, data.error);
});See Also
- Controller Events Reference - Complete event system documentation
- Monitor Events - Monitor subsystem events