2021-05-27 20:22:27 +00:00
|
|
|
import 'codemirror';
|
2021-07-22 23:04:56 +00:00
|
|
|
|
2021-09-08 15:38:07 +00:00
|
|
|
import { GraphQLInfoOptions } from 'codemirror-graphql/info';
|
|
|
|
import { ModifiedGraphQLJumpOptions } from 'codemirror-graphql/jump';
|
|
|
|
import { GraphQLSchema } from 'graphql';
|
|
|
|
|
2021-05-27 20:22:27 +00:00
|
|
|
import { HandleGetRenderContext, HandleRender } from './common/render';
|
2021-09-15 13:01:35 +00:00
|
|
|
import { Settings } from './models/settings';
|
2021-09-08 15:38:07 +00:00
|
|
|
import { NunjucksParsedTag } from './templating/utils';
|
2021-05-27 20:22:27 +00:00
|
|
|
|
|
|
|
type LinkClickCallback = (url: string) => void;
|
|
|
|
|
|
|
|
interface InsomniaExtensions {
|
|
|
|
closeHintDropdown: () => void;
|
|
|
|
enableNunjucksTags: (
|
|
|
|
handleRender: HandleRender,
|
|
|
|
handleGetRenderContext?: HandleGetRenderContext,
|
2021-12-13 07:45:08 +00:00
|
|
|
showVariableSourceAndValue?: boolean,
|
2021-05-27 20:22:27 +00:00
|
|
|
) => void;
|
|
|
|
isHintDropdownActive: () => boolean;
|
|
|
|
makeLinksClickable: (handleClick: LinkClickCallback) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
declare module 'codemirror' {
|
|
|
|
type CodeMirrorLinkClickCallback = LinkClickCallback;
|
|
|
|
|
|
|
|
interface Editor extends InsomniaExtensions {}
|
|
|
|
interface EditorFromTextEditor extends InsomniaExtensions {}
|
2021-09-08 15:38:07 +00:00
|
|
|
interface TextMarker {
|
|
|
|
// This flag is being used internally by codemirror and the fold extension
|
|
|
|
__isFold: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Variable {
|
|
|
|
name: string;
|
|
|
|
value: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Snippet {
|
|
|
|
name: string;
|
|
|
|
displayValue: string;
|
|
|
|
value: string | (() => Promise<unknown>);
|
|
|
|
}
|
|
|
|
|
2021-09-15 13:01:35 +00:00
|
|
|
interface EnvironmentAutocompleteOptions extends Pick<Settings, 'hotKeyRegistry' | 'autocompleteDelay'> {
|
2021-09-08 15:38:07 +00:00
|
|
|
getConstants?: () => string[] | PromiseLike<string[]>;
|
|
|
|
getVariables?: () => Variable[] | PromiseLike<Variable[]>;
|
|
|
|
getSnippets?: () => Snippet[] | PromiseLike<Snippet[]>;
|
|
|
|
getTags?: () => NunjucksParsedTag[] | PromiseLike<NunjucksParsedTag[]>;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface EditorConfiguration {
|
|
|
|
info?: GraphQLInfoOptions;
|
|
|
|
jump?: ModifiedGraphQLJumpOptions;
|
|
|
|
environmentAutocomplete?: EnvironmentAutocompleteOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Hint {
|
|
|
|
/**
|
|
|
|
* Custom Insomnia Key. Used for checking the type of the hint
|
|
|
|
*/
|
|
|
|
type: 'constant' | 'variable' | 'snippet' | 'tag';
|
|
|
|
/**
|
|
|
|
* Custom Insomnia Key. The segment that matched and produced this hint
|
|
|
|
*/
|
|
|
|
segment: string;
|
|
|
|
/**
|
|
|
|
* Custom Insomnia Key. This value gets displayed in the autocomplete menu.
|
|
|
|
*/
|
|
|
|
displayValue: string;
|
|
|
|
/**
|
|
|
|
* Custom Insomnia Key. The display value of the hint
|
|
|
|
*/
|
|
|
|
comment?: string;
|
|
|
|
/**
|
|
|
|
* Custom Insomnia Key. Used for sorting the hints
|
|
|
|
*/
|
|
|
|
score: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ShowHintOptions {
|
|
|
|
variables?: Variable[];
|
|
|
|
constants?: string[];
|
|
|
|
snippets?: Snippet[];
|
|
|
|
tags?: NunjucksParsedTag[];
|
|
|
|
showAllOnNoMatch?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface LintOptions {
|
|
|
|
schema?: GraphQLSchema;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface EditorEventMap {
|
|
|
|
fold: (instance: Editor, from: Position) => void;
|
|
|
|
unfold: (instance: Editor, from: Position) => void;
|
|
|
|
}
|
2021-09-15 13:01:35 +00:00
|
|
|
|
|
|
|
const keyNames: Record<number, string>;
|
2021-05-27 20:22:27 +00:00
|
|
|
}
|