UNPKG

2.54 kBTypeScriptView Raw
1/// <reference types="react" />
2import { Subscribable } from 'rxjs';
3import { ConfigurationUpdateParams } from 'sourcegraph/module/protocol';
4import { Controller } from './controller';
5import { QueryResult } from './graphql';
6import * as GQL from './schema/graphqlschema';
7import { ConfigurationCascadeOrError, ConfigurationSubject, ID, Settings } from './settings';
8export declare type UpdateExtensionSettingsArgs = {
9 edit?: ConfigurationUpdateParams;
10} | {
11 extensionID: string;
12 enabled?: boolean;
13 remove?: boolean;
14};
15/**
16 * Description of the context in which extensions-client-common is running, and platform-specific hooks.
17 */
18export interface Context<S extends ConfigurationSubject, C extends Settings> {
19 /**
20 * An observable that emits whenever the configuration cascade changes (including when any individual subject's
21 * settings change).
22 */
23 readonly configurationCascade: Subscribable<ConfigurationCascadeOrError<S, C>>;
24 updateExtensionSettings(subject: ID, args: UpdateExtensionSettingsArgs): Subscribable<void>;
25 /**
26 * Sends a request to the Sourcegraph GraphQL API and returns the response.
27 *
28 * @param request The GraphQL request (query or mutation)
29 * @param variables An object whose properties are GraphQL query name-value variable pairs
30 * @return Observable that emits the result or an error if the HTTP request failed
31 */
32 queryGraphQL(request: string, variables?: {
33 [name: string]: any;
34 }): Subscribable<QueryResult<Pick<GQL.IQuery, 'extensionRegistry'>>>;
35 /**
36 * React components for icons. They are expected to size themselves appropriately with the surrounding DOM flow
37 * content.
38 */
39 readonly icons: Record<'Loader' | 'Warning' | 'Menu' | 'CaretDown', React.ComponentType<{
40 className: 'icon-inline' | string;
41 onClick?: () => void;
42 }>>;
43 /**
44 * Forces the currently displayed tooltip, if any, to update its contents.
45 */
46 forceUpdateTooltip(): void;
47 /**
48 * Experimental capabilities implemented by the client (that are not defined by the Sourcegraph extension API
49 * specification). These capabilities are passed verbatim to extensions in the initialize request's
50 * capabilities.experimental property.
51 */
52 experimentalClientCapabilities?: any;
53}
54/**
55 * React partial props for components needing the extensions controller.
56 */
57export interface ExtensionsProps<S extends ConfigurationSubject, C extends Settings> {
58 extensions: Controller<S, C>;
59}