2020-07-05 05:00:54 +03:00
|
|
|
import { BasePluginType, plugin, PluginBlueprint } from "knub";
|
|
|
|
import * as t from "io-ts";
|
2020-07-22 22:56:21 +03:00
|
|
|
import { getPluginConfigPreprocessor } from "../pluginUtils";
|
2020-07-22 23:11:42 +03:00
|
|
|
import { TMarkdown } from "../types";
|
2020-07-05 05:00:54 +03:00
|
|
|
|
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-22 23:11:42 +03:00
|
|
|
|
|
|
|
info?: {
|
|
|
|
prettyName: string;
|
|
|
|
description?: TMarkdown;
|
|
|
|
usageGuide?: TMarkdown;
|
|
|
|
configurationGuide?: TMarkdown;
|
|
|
|
};
|
2020-07-05 05:00:54 +03:00
|
|
|
}
|
|
|
|
|
2020-07-22 22:08:20 +03:00
|
|
|
export function zeppelinPlugin<TPartialBlueprint extends Omit<ZeppelinPluginBlueprint, "name">>(
|
2020-07-06 02:01:01 +03:00
|
|
|
name: string,
|
2020-07-22 22:08:20 +03:00
|
|
|
blueprint: TPartialBlueprint,
|
|
|
|
): TPartialBlueprint & { name: string };
|
|
|
|
|
|
|
|
export function zeppelinPlugin<TPluginType extends BasePluginType>(): <
|
|
|
|
TPartialBlueprint extends Omit<ZeppelinPluginBlueprint<TPluginType>, "name">
|
|
|
|
>(
|
|
|
|
name: string,
|
|
|
|
blueprint: TPartialBlueprint,
|
|
|
|
) => TPartialBlueprint & { name: string };
|
|
|
|
|
2020-07-05 05:00:54 +03:00
|
|
|
export function zeppelinPlugin(...args) {
|
|
|
|
if (args.length) {
|
|
|
|
const blueprint: ZeppelinPluginBlueprint = plugin(...(args as Parameters<typeof plugin>));
|
2020-07-22 22:56:21 +03:00
|
|
|
blueprint.configPreprocessor = getPluginConfigPreprocessor(blueprint);
|
2020-07-05 05:00:54 +03:00
|
|
|
return blueprint;
|
|
|
|
} else {
|
|
|
|
return zeppelinPlugin;
|
|
|
|
}
|
|
|
|
}
|