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

View File

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

View File

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