/** * Copyright Linkurious SAS 2012 - 2019 * * - Created on 2019-09-17. */ import type { Router as ExpressRouter, Request as ExpressRequest } from 'express'; import { RestClient } from '../../restClient'; export declare enum PluginRequestHeader { USER_ID = "linkurious-user-id", USER_EMAIL = "linkurious-user-email", PLUGIN_SECRET = "linkurious-plugin-secret" } export declare enum PluginState { DISABLED = "disabled", RUNNING = "running", STOPPED = "stopped", ERROR_RUNTIME = "error-runtime", ERROR_MANIFEST = "error-manifest" } export interface InstalledPlugin { name: string; version: string; /** * The URL of the icon of the plugin. Optional. */ icon?: string; /** * The localized strings of the plugin, keyed by language code. */ i18n: Record; state: PluginState; actions: PluginAction[]; basePath?: string; error?: string; } /** * The localized strings of a plugin in a given language. */ export interface PluginLanguageValues { title: string; description: string; } export interface PluginLogs { logs: InstanceLogs[]; } interface InstanceLogs { basePath: string; content: string; } export interface PluginParam { name: string; } export interface UploadPluginParam { file: File; } export interface IPluginConfig extends Record { disabled?: boolean; basePath?: string; debugPort?: string | number; } export interface PluginConfig extends IPluginConfig { basePath: string; } /** * The options passed to a plugin's route initialization function. */ export interface PluginRouteOptions { parentProcess: PluginParentProcess; router: ExpressRouter; configuration: C; getRestClient: (req: ExpressRequest) => RestClient; } /** * Interface for communicating with the parent process (that is, the Linkurious server) from * within a plugin. */ export interface PluginParentProcess { /** * Send plugin metadata to the parent process. This should be done at least once each time the * plugin starts (the metadata isn't persisted between restarts), and whenever the metadata * changes. */ postMetadata(metadata: PluginMetadata): void; } /** * The metadata exposed by a plugin to the parent process. */ export interface PluginMetadata { /** * The list of the actions of the plugin. */ actions: PluginAction[]; } /** * An action exposed by a plugin, for Linkurious users. It's similar to a custom action. */ export interface PluginAction { /** * A human readable name identifying the action. */ name: string; /** * The URL template for invoking the action. It has the same syntax as a custom action URL template. */ urlTemplate: string; /** * An optional data-source key this action is scoped to. If undefined, the action is available no * matter what is the current data-source. */ sourceKey?: string; /** * Who can access this action: admins only or all authenticated users. */ access: 'admin' | '*'; } export {};