MCPcopy Create free account
hub / github.com/Kong/insomnia / invokePluginMethod

Function invokePluginMethod

packages/insomnia/src/plugins/invoke-method.ts:70–300  ·  view source on GitHub ↗
(method: PluginInvokeMethod, args?: unknown)

Source from the content-addressed store, hash-verified

68}
69
70export 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;

Callers 2

Calls 15

getThemesFunction · 0.90
getPluginsFunction · 0.90
getActivePluginsFunction · 0.90
reloadPluginsFunction · 0.90
getRequestActionsFunction · 0.90
getRequestGroupActionsFunction · 0.90
getWorkspaceActionsFunction · 0.90
getDocumentActionsFunction · 0.90
shouldSandboxPluginFunction · 0.90
getBundlePluginsFunction · 0.90
executePluginMainActionFunction · 0.90

Tested by

no test coverage detected