2020-07-05 05:00:54 +03:00
|
|
|
import { BasePluginType, plugin, PluginBlueprint } from "knub";
|
|
|
|
import * as t from "io-ts";
|
|
|
|
import { pluginConfigPreprocessor } from "../pluginUtils";
|
|
|
|
|
2020-07-06 02:01:01 +03:00
|
|
|
export interface ZeppelinPluginBlueprint<TPluginType extends BasePluginType = BasePluginType>
|
|
|
|
extends PluginBlueprint<TPluginType> {
|
2020-07-05 05:00:54 +03:00
|
|
|
configSchema?: t.TypeC<any>;
|
2020-07-06 02:01:01 +03:00
|
|
|
showInDocs?: boolean;
|
2020-07-05 05:00:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export function zeppelinPlugin(name: string, blueprint: Omit<ZeppelinPluginBlueprint, "name">): ZeppelinPluginBlueprint;
|
2020-07-06 02:01:01 +03:00
|
|
|
export function zeppelinPlugin<TPluginType extends BasePluginType>(): (
|
|
|
|
name: string,
|
|
|
|
blueprint: Omit<ZeppelinPluginBlueprint<TPluginType>, "name">,
|
|
|
|
) => ZeppelinPluginBlueprint<TPluginType>;
|
2020-07-05 05:00:54 +03:00
|
|
|
export function zeppelinPlugin(...args) {
|
|
|
|
if (args.length) {
|
|
|
|
const blueprint: ZeppelinPluginBlueprint = plugin(...(args as Parameters<typeof plugin>));
|
|
|
|
blueprint.configPreprocessor = pluginConfigPreprocessor.bind(blueprint);
|
|
|
|
return blueprint;
|
|
|
|
} else {
|
|
|
|
return zeppelinPlugin;
|
|
|
|
}
|
|
|
|
}
|