import { IObservable } from '@opensumi/ide-monaco/lib/common/observable'; import { QueryParam, QueryResult, VSXExtensionRaw, VSXSearchParam, VSXSearchResult } from './vsx-registry-types'; export enum EnableScope { GLOBAL = 'GLOBAL', WORKSPACE = 'WORKSPACE', } export enum TabActiveKey { MARKETPLACE = 'marketplace', INSTALLED = 'installed', } export enum InstallState { INSTALLED = 'INSTALLED', NOT_INSTALLED = 'NOT_INSTALLED', SHOULD_UPDATE = 'SHOULD_UPDATE', } export type VSXExtensionNamespaceAccess = 'public' | 'restricted'; /** * Should be aligned with https://github.com/eclipse/openvsx/blob/master/server/src/main/java/org/eclipse/openvsx/json/UserJson.java */ export interface VSXUser { loginName: string; homepage?: string; } export class VSXExtension { readonly name: string; readonly version?: string; readonly iconUrl?: string; readonly publisher?: string; readonly displayName?: string; readonly description?: string; readonly namespace?: string; readonly averageRating?: number; readonly downloadCount?: number; readonly downloadUrl?: string; readonly readmeUrl?: string; readonly licenseUrl?: string; readonly repository?: string; readonly license?: string; readonly readme?: string; readonly url?: string; readonly preview?: boolean; readonly namespaceAccess?: VSXExtensionNamespaceAccess; readonly publishedBy?: VSXUser; readonly path?: string; readonly realpath?: string; readonly extensionId?: string; readonly originId?: string; static KEYS: Set = new Set([ 'version', 'iconUrl', 'publisher', 'name', 'displayName', 'description', 'averageRating', 'downloadCount', 'downloadUrl', 'readmeUrl', 'licenseUrl', 'repository', 'license', 'readme', 'preview', 'namespaceAccess', 'publishedBy', ]); } export const VSXExtensionServiceToken = Symbol('VSXExtensionSerivceToken'); export interface IVSXExtensionService { search(keyword: string): Promise; searchInstalledExtensions(keyword: string): Promise; install(extension: VSXExtension): Promise; uninstall(extension: VSXExtension): Promise; getLocalExtension(extensionId?: string): Promise; getRemoteRawExtension(extensionId?: string): Promise; getOpenVSXRegistry(): Promise; getExtensionId(extension: VSXExtension): string; openExtensionEditor(extensionId: string, state: InstallState): Promise; extensions: VSXExtension[]; extensionsObservable: IObservable; installedExtensions: VSXExtension[]; installedExtensionsObservable: IObservable; openVSXRegistry: string; openVSXRegistryObservable: IObservable; } export const VSXExtensionServicePath = 'VSXExtensionServicePath'; export interface IExtensionInstallParam { id: string; name: string; url: string; version: string; } export interface IVSXExtensionBackService { search(param?: VSXSearchParam): Promise; install(param: IExtensionInstallParam): Promise; getExtension(param: QueryParam): Promise; getOpenVSXRegistry(): Promise; } export const IOpenvsxMarketplaceService = Symbol('IOpenvsxMarketplaceService'); export interface IMarketplaceService { downloadHeaders?: { [key: string]: string }; getExtensionDetail(param: QueryParam): Promise; search(param?: VSXSearchParam): Promise; }