(method: PluginInvokeMethod, args?: unknown)
| 68 | } |
| 69 | |
| 70 | export async function invokePluginMethod(method: PluginInvokeMethod, args?: unknown): Promise<unknown> { |
| 71 | switch (method) { |
| 72 | case 'getThemes': { |
| 73 | const themes = await getThemes(); |
| 74 | return themes.map(({ plugin, theme }) => ({ plugin: serializePlugin(plugin), theme })); |
| 75 | } |
| 76 | |
| 77 | case 'getPlugins': { |
| 78 | const plugins = await getPlugins(); |
| 79 | return plugins.map(serializePlugin); |
| 80 | } |
| 81 | |
| 82 | case 'getActivePlugins': { |
| 83 | const plugins = await getActivePlugins(); |
| 84 | return plugins.map(serializePlugin); |
| 85 | } |
| 86 | |
| 87 | case 'reloadPlugins': { |
| 88 | await reloadPlugins(); |
| 89 | return null; |
| 90 | } |
| 91 | |
| 92 | case 'getRequestActions': { |
| 93 | const actions = await getRequestActions(); |
| 94 | return actions.map(a => ({ label: a.label, icon: a.icon, pluginName: a.plugin.name })); |
| 95 | } |
| 96 | |
| 97 | case 'getRequestGroupActions': { |
| 98 | const actions = await getRequestGroupActions(); |
| 99 | return actions.map(a => ({ label: a.label, icon: a.icon, pluginName: a.plugin.name })); |
| 100 | } |
| 101 | |
| 102 | case 'getWorkspaceActions': { |
| 103 | const actions = await getWorkspaceActions(); |
| 104 | return actions.map(a => ({ label: a.label, icon: a.icon, pluginName: a.plugin.name })); |
| 105 | } |
| 106 | |
| 107 | case 'getDocumentActions': { |
| 108 | const actions = await getDocumentActions(); |
| 109 | return actions.map(a => ({ label: a.label, hideAfterClick: a.hideAfterClick, pluginName: a.plugin.name })); |
| 110 | } |
| 111 | |
| 112 | case 'executeAction': { |
| 113 | const { type, pluginName, label, projectId, domainData } = args as ExecutePluginActionArgs; |
| 114 | |
| 115 | let allActions: any[]; |
| 116 | switch (type) { |
| 117 | case 'request': { |
| 118 | allActions = await getRequestActions(); |
| 119 | break; |
| 120 | } |
| 121 | case 'requestGroup': { |
| 122 | allActions = await getRequestGroupActions(); |
| 123 | break; |
| 124 | } |
| 125 | case 'workspace': { |
| 126 | allActions = await getWorkspaceActions(); |
| 127 | break; |
no test coverage detected