import { DynamicIconProps, RouteConfig } from '@bluebase/components'; import { Theme } from '..'; import { BlueBase } from '../BlueBase'; import { IntlContextData } from '../contexts'; import { MaybeArray, MaybePromise, MaybeThunk } from '../utils'; import { AssetCollection } from './AssetRegistry'; import { BlueBaseModuleRegistry, BlueBaseModuleRegistryInputItem, BlueBaseModuleRegistryItem } from './BlueBaseModuleRegistry'; import { ComponentCollection } from './ComponentRegistry'; import { ConfigCollection } from './ConfigRegistry'; import { FilterNestedCollection } from './FilterRegistry'; import { FontCollection } from './FontRegistry'; import { ItemCollection } from './Registry'; import { ThemeCollection } from './ThemeRegistry'; export type PluginCategory = 'app' | 'store' | 'router' | 'logging' | 'theme' | 'analytics' | string; export interface RouteOptions { BB: BlueBase; intl: IntlContextData; theme: Theme; } export interface PluginValue { assets: AssetCollection; components: ComponentCollection; filters: FilterNestedCollection; fonts: FontCollection; themes: ThemeCollection; routes?: MaybeThunk>>; } export type PluginValueInput = Partial; export interface PluginRegistryItemExtras { [key: string]: any; /** * Name of the plugin. * * We put it in meta so we can show the name in menu een without downloading * the whole plugin. */ name: string; /** Plugin categories */ categories?: PluginCategory[]; /** Plugin description */ description?: string; /** Plugin version */ version?: string; /** Plugin Icon Props */ icon?: MaybeThunk; /** Is this plugin currently enabled/ */ enabled: boolean; /** Default plugin configs */ defaultConfigs: ConfigCollection; /** Main route used as home page of the plugin */ indexRoute?: string; } export type PluginRegistryItem = BlueBaseModuleRegistryItem & PluginRegistryItemExtras; export type PluginRegistryInputItem = BlueBaseModuleRegistryInputItem>; type ItemType = PluginRegistryItem; type ItemInputType = PluginRegistryInputItem; export type Plugin = PluginRegistryItemExtras & PluginValue; export type PluginInput = PluginRegistryInputItem; export type PluginCollection = ItemCollection; export declare function inputToPlugin(plugin: PluginInput): Promise; /** * Creates a BlueBase plugin from input params * @param plugin */ export declare function createPlugin(plugin: Partial): PluginInput; export declare function resolveRoutes(routes: PluginValue['routes'], options: RouteOptions): Promise; /** * 🔌 PluginRegistry */ export declare class PluginRegistry extends BlueBaseModuleRegistry { /** * Returns a Promise that resolves a Plugin * @param keys */ resolve(...keys: string[]): Promise; /** * Checks if a plugin is enabled * @param key */ isEnabled(key: string): boolean; /** * Enable a plugin * @param key */ enable(key: string): Promise; /** * Disable a plugin * @param key */ disable(key: string): Promise; /** * Returns all enabled plugins */ getAllEnabled(): Promise<(PluginRegistryItemExtras & PluginValue)[]>; /** * Checks if a config belongs to a plugin. Does so by checking 2 things: * * 1. Does the config start with 'plugin.{key}.'? * 2. Does the config exist in defaultConfigs property of the plugin? * * Returns true if any of the above are true, otherwise returns false * * @param key */ hasConfig(key: string, config: string): boolean; /** * Creates a map of routes for each plugin * * Ignores plugins if: * * - Plugin is not enabled * - Plugin is not resolved */ getRouteMap(options: RouteOptions, prefixPluginKey?: boolean): Promise<{ [key: string]: RouteConfig[]; }>; /** * Register a collection of items. * @param collection */ registerCollection(collection?: ItemCollection): Promise; /** * Convert any input value to an item. This is where you transform inputs and add defualts * @param key * @param partial */ protected createItem(key: string, partial: any): ItemType; /** * Typeguard to check a given object is an input value * @param value */ protected isInputValue(value: any): value is PluginRegistryInputItem['value']; } export {};