Knub 30 conversion base work; Work on Utility plugin Knub 30 conversion

This commit is contained in:
Dragory 2020-07-05 05:00:54 +03:00
parent 1bf5a7fa28
commit d62a4e26ae
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
18 changed files with 585 additions and 324 deletions

View file

@ -0,0 +1,20 @@
import { BasePluginType, plugin, PluginBlueprint } from "knub";
import * as t from "io-ts";
import { pluginConfigPreprocessor } from "../pluginUtils";
export interface ZeppelinPluginBlueprint<TPluginType extends BasePluginType = BasePluginType> extends PluginBlueprint<TPluginType> {
configSchema?: t.TypeC<any>;
}
export function zeppelinPlugin(name: string, blueprint: Omit<ZeppelinPluginBlueprint, "name">): ZeppelinPluginBlueprint;
export function zeppelinPlugin<TPluginType extends BasePluginType>():
(name: string, blueprint: Omit<ZeppelinPluginBlueprint<TPluginType>, "name">) => ZeppelinPluginBlueprint<TPluginType>;
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;
}
}