remove SpecInfo type (#4255)

* remove SpecInfo

* Update packages/insomnia-app/app/ui/components/modals/generate-config-modal.tsx

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>
This commit is contained in:
Jack Kavanagh 2021-11-29 18:28:25 +01:00 committed by GitHub
parent 681ee649ee
commit 77d2a5d6b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 18 deletions

View File

@ -4,6 +4,7 @@ import mkdirp from 'mkdirp';
import path from 'path';
import appConfig from '../../config/config.json';
import { ParsedApiSpec } from '../common/api-specs';
import { PLUGIN_PATH } from '../common/constants';
import { resolveHomePath } from '../common/misc';
import * as models from '../models';
@ -81,18 +82,11 @@ export interface WorkspaceAction extends InternalProperties {
icon?: string;
}
export interface SpecInfo {
contents: Record<string, any>;
rawContents: string;
format: string;
formatVersion: string;
}
export interface ConfigGenerator extends InternalProperties {
label: string;
docsLink?: string;
generate: (
info: SpecInfo,
info: ParsedApiSpec,
) => Promise<{
document?: string;
error?: string;
@ -100,7 +94,7 @@ export interface ConfigGenerator extends InternalProperties {
}
export interface DocumentAction extends InternalProperties {
action: (context: Record<string, any>, documents: SpecInfo) => void | Promise<void>;
action: (context: Record<string, any>, documents: ParsedApiSpec) => void | Promise<void>;
label: string;
hideAfterClick?: boolean;
}

View File

@ -92,7 +92,6 @@ const useDocumentActionPlugins = ({ workspace, apiSpec, project }: Props) => {
...pluginContexts.data.init(project._id),
...pluginContexts.store.init(p.plugin),
};
// @ts-expect-error -- TSCONVERSION
await p.action(context, parseApiSpec(apiSpec.contents));
} catch (err) {
showError({

View File

@ -57,19 +57,17 @@ export class GenerateConfigModal extends PureComponent<{}, State> {
docsLink: generatePlugin.docsLink,
error: null,
};
let result;
try {
// @ts-expect-error -- TSCONVERSION
result = await generatePlugin.generate(parseApiSpec(apiSpec.contents));
const result = await generatePlugin.generate(parseApiSpec(apiSpec.contents));
if (result.document) {
config.content = result.document;
}
config.error = result.error || null;
return config;
} catch (err) {
config.error = err.message;
return config;
}
config.content = result.document || null;
config.error = result.error || null;
return config;
}
async show({ activeTabLabel, apiSpec }: ShowOptions) {