@emigrate/plugin-tools
Advanced tools
Comparing version
@@ -1,2 +0,3 @@ | ||
import { type PluginFromType, type GeneratorPlugin, type EmigrateReporter, type EmigrateStorage, type LoaderPlugin, type StringOrModule } from './types.js'; | ||
import { type PluginFromType, type GeneratorPlugin, type EmigrateReporter, type EmigrateStorage, type LoaderPlugin, type StringOrModule, type SerializedError } from './types.js'; | ||
export declare const serializeError: (error: Error) => SerializedError; | ||
export declare const isGeneratorPlugin: (plugin: any) => plugin is GeneratorPlugin; | ||
@@ -3,0 +4,0 @@ export declare const isEmigrateStorage: (plugin: any) => plugin is EmigrateStorage; |
import process from 'node:process'; | ||
export const serializeError = (error) => { | ||
return { | ||
name: error.name, | ||
message: error.message, | ||
stack: error.stack, | ||
cause: error.cause instanceof Error ? serializeError(error.cause) : error.cause, | ||
}; | ||
}; | ||
export const isGeneratorPlugin = (plugin) => { | ||
@@ -3,0 +11,0 @@ if (!plugin || typeof plugin !== 'object') { |
@@ -6,2 +6,8 @@ export type Awaitable<T> = T | PromiseLike<T>; | ||
export type MigrationStatus = 'failed' | 'done' | 'pending'; | ||
export type SerializedError = { | ||
name: string; | ||
message: string; | ||
stack?: string; | ||
cause?: unknown; | ||
}; | ||
export type MigrationHistoryEntry = { | ||
@@ -11,3 +17,3 @@ name: string; | ||
date: Date; | ||
error?: unknown; | ||
error?: SerializedError; | ||
}; | ||
@@ -68,3 +74,9 @@ export type Storage = { | ||
*/ | ||
onError(migration: MigrationMetadataFinished, error: Error): Promise<void>; | ||
onError(migration: MigrationMetadataFinished, error: SerializedError): Promise<void>; | ||
/** | ||
* Called when the command is finished or aborted (e.g. by a SIGTERM or SIGINT signal). | ||
* | ||
* Use this to clean up any resources like database connections or file handles. | ||
*/ | ||
end(): Promise<void>; | ||
}; | ||
@@ -137,3 +149,3 @@ export type EmigrateStorage = { | ||
duration: number; | ||
error?: Error; | ||
error?: SerializedError; | ||
}; | ||
@@ -140,0 +152,0 @@ export type LoaderPlugin = { |
{ | ||
"name": "@emigrate/plugin-tools", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
64918
1.99%525
4.17%