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

38 lines
920 B
JavaScript
Raw Normal View History

// @flow
2018-06-25 17:42:50 +00:00
import {
exportHAR,
exportJSON,
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: {
async uri(
uri: string,
options: { workspaceId?: string } = {}
): Promise<void> {
await importUri(options.workspaceId || null, uri);
},
2018-06-25 17:42:50 +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 } = {}
): Promise<string> {
options = options || {};
return exportJSON(null, options.includePrivate);
},
2018-06-25 17:42:50 +00:00
async har(options: { includePrivate?: boolean } = {}): Promise<string> {
return exportHAR(null, options.includePrivate);
}
}
};
}