insomnia/app/plugins/context/data.js
Gregory Schier c79d7fdd77
Plugin API Import/Export (#627)
* Add query parameter API for requests

* Add plugin APIs for importing

* Updated some things
2017-11-26 13:42:43 +00:00

26 lines
896 B
JavaScript

// @flow
import type {Plugin} from '../';
import {exportHAR, exportJSON, importRaw, importUri} from '../../common/import';
export function init (plugin: Plugin): {'import': Object, 'export': Object} {
return {
'import': {
async uri (uri: string, options: {workspaceId?: string} = {}): Promise<void> {
await importUri(options.workspaceId || null, uri);
},
async raw (text: string, options: {workspaceId?: string} = {}): Promise<void> {
await importRaw(options.workspaceId || null, text);
}
},
'export': {
async insomnia (options: {includePrivate?: boolean} = {}): Promise<string> {
options = options || {};
return exportJSON(null, options.includePrivate);
},
async har (options: {includePrivate?: boolean} = {}): Promise<string> {
return exportHAR(null, options.includePrivate);
}
}
};
}