insomnia/packages/insomnia-app/app/plugins/context/data.js

32 lines
973 B
JavaScript
Raw Normal View History

// @flow
import {
exportWorkspacesHAR,
exportWorkspacesData,
importRaw,
importUri,
} from '../../common/import';
2018-06-25 17:42:50 +00:00
export function init(): { import: Object, export: Object } {
return {
2018-06-25 17:42:50 +00:00
import: {
2018-10-17 16:42:33 +00:00
async uri(uri: string, options: { workspaceId?: string } = {}): Promise<void> {
await importUri(options.workspaceId || null, uri);
},
2018-10-17 16:42:33 +00:00
async raw(text: string, options: { workspaceId?: string } = {}): Promise<void> {
await importRaw(options.workspaceId || null, text);
},
},
2018-06-25 17:42:50 +00:00
export: {
async insomnia(
options: { includePrivate?: boolean, format?: 'json' | 'yaml' } = {},
): Promise<string> {
options = options || {};
2019-04-18 18:13:12 +00:00
return exportWorkspacesData(null, !!options.includePrivate, options.format || 'json');
},
2018-06-25 17:42:50 +00:00
async har(options: { includePrivate?: boolean } = {}): Promise<string> {
2019-04-18 18:13:12 +00:00
return exportWorkspacesHAR(null, !!options.includePrivate);
},
},
};
}