UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

193 lines (192 loc) 10.7 kB
import { Observable, Subject } from 'rxjs'; import { EnvironmentModuleEntryPoint, EnvironmentModuleEntryPointType } from '../../manifest/environment-modules'; import { RpcExtensionBrokerRequest, RpcExtensionBrokerRequestResult } from '../../rpc/extension-broker/rpc-extension-broker-model'; import { Rpc } from '../../rpc/rpc'; import { ExtensionBrokerEmitRequestPayload, ExtensionBrokerRequestPayload } from './model/extension-broker-request-payload'; import { ExtensionBrokerDestroyResponsePayload, ExtensionBrokerMoveResponsePayload, ExtensionBrokerResponsePayload, FulfillmentEntryPoints } from './model/extension-broker-response-payload'; import { ExtensionEntries } from './model/extension-entries'; import { SnapInExtensionInstance, WorkerExtensionInstance } from './model/extension-instance'; import { ExtensionRect } from './model/extension-rect'; import { ExtensionSearchOptions } from './model/extension-search-options'; export declare abstract class ExtensionBrokerQuery { protected rpc: Rpc; constructor(rpc: Rpc); protected watcher: Subject<RpcExtensionBrokerRequestResult>; resultEmitter: Subject<ExtensionBrokerEmitRequestPayload>; abstract getTargetExtensions(extensionTargetId: string): Observable<FulfillmentEntryPoints>; abstract createSnapIn(entryPointId: string): Observable<SnapInExtensionInstance>; abstract createWorker(entryPointId: string, extensionTarget?: string): Observable<WorkerExtensionInstance>; abstract findWorker(searchOptions: ExtensionSearchOptions): Observable<WorkerExtensionInstance>; abstract getExtensionEntryPointsByType(types: EnvironmentModuleEntryPointType[]): Observable<EnvironmentModuleEntryPoint[]>; abstract runWorker(entryPointId: string, method: string, version: number, ...args: any[]): Observable<any>; abstract startWorker(entryPointId: string, method: string, version: number, ...args: any[]): Observable<void>; abstract createDialog(entryPointId: string): Observable<any>; abstract showDialog(entryPointId: string, version: number, ...args: any[]): Observable<any>; abstract callService(entryPointId: string, method: string, version: number, ...args: any[]): Observable<any>; abstract request<T extends ExtensionBrokerResponsePayload>(payload: ExtensionBrokerRequestPayload): Observable<T>; /** * Handles rpc response messages from the extension host. * @param data the result of the extension host request */ onRpcResponse(data: RpcExtensionBrokerRequestResult): Promise<void>; /** * Calls a method on a extension instance and returns its result. * @param instanceId The instance id of the extension to call * @param method The method to call * @param version The version of the method to call * @param args The arguments to pass to the method * @returns an observable for the result of the call (may be null if method call is void) */ protected call(instanceId: string, method: string, version: number, ...args: any[]): Observable<any>; /** * Destroys a extension instance * @param instanceId The instance id of the extension to destroy * @returns an observable for when the extension is destroyed */ protected destroy(instanceId: string): Observable<ExtensionBrokerDestroyResponsePayload>; /** * Moves a extension instance * @param instanceId The instance id of the extension to destroy * @param rect The rectangular position to move the extension to (relative to the iframe) * @param zIndex the z index to move to, default is 1 * @returns an observable for when the extension is destroyed */ protected move(instanceId: string, rect: ExtensionRect, zIndex?: number): Observable<ExtensionBrokerMoveResponsePayload>; } /** * Extension broker listener class * Register a listener without needed full extension broker service */ export declare class ExtensionBrokerListener { private static extensionBrokerModuleSubjectServer; private static requestReceivedSubject; static get requestReceived(): Observable<RpcExtensionBrokerRequest>; static initialize(rpc: Rpc): void; private static handleRpcRequest; } /** * Extension Broker Module Side Service. * Manages requests designated for other extensions through the shell using RPC */ export declare class ExtensionBroker extends ExtensionBrokerQuery { /** * The source name to use for logging */ protected get logSourceName(): string; /** * Initializes a new instance of the Extension Broker class * @param rpc The rpc to use to communicate with the shell */ constructor(rpc: Rpc); /** * Occurs when an emit request is received from shell */ private onEmitReceived; /** * Gets the entry point ids for all the extensions that fulfill an extension targets contract * In some cases, as specified by the extension target, the shell may ask the user to select a preferred * extension that fulfills the target contract. Returning only the 1 entry point id. * @param extensionTargetId The id of the extension target * @return An observable for the entry point ids of the extensions that fulfill an extension targets contract. */ getTargetExtensions(extensionTargetId: string): Observable<FulfillmentEntryPoints>; /** * Creates a SnapIn instance given its entry point id. * This instance is tied to the calling extension and will close when destroy is called or the calling extension is destroyed. * @param entryPointId The id of the worker to create */ createSnapIn(entryPointId: string): Observable<SnapInExtensionInstance>; /** * Finds a worker given either its entryPointId or instanceId * @param searchOptions The search options for finding a worker instance */ findWorker(searchOptions: ExtensionSearchOptions): Observable<WorkerExtensionInstance>; /** * Finds extensions by search condition. * @param searchOptions The search options for finding manifest entry points that meet the condition. */ findEntriesByCondition(searchOptions: ExtensionSearchOptions): Observable<ExtensionEntries>; /** * return all registered entry points by type * @param types entry point types to return */ getExtensionEntryPointsByType(types: EnvironmentModuleEntryPointType[]): Observable<EnvironmentModuleEntryPoint[]>; /** * Creates a worker instance given its entry point id. * This instance is tied to the calling extension and will close when destroy is called or the calling extension is destroyed. * @param entryPointId The id of the worker to create */ createWorker(entryPointId: string, extensionTarget?: string): Observable<WorkerExtensionInstance>; /** * subscribe to results emission for specific action */ listen(eventType: string, instanceId: string): Observable<any>; /** * Runs a worker instance and returns the result of one method. After which the worker is destroyed. * @param entryPointId The id of the worker to create * @param method The method to call * @param version The version of the method to call * @param args The arguments to pass to the method * @returns an observable for the result of the worker. */ runWorker(entryPointId: string, method: string, version: number, ...args: any[]): Observable<any>; /** * Runs a worker instance with no association to the calling extension. * The worker will run its own workflow until it is finished * @param entryPointId The id of the worker to create * @param method The method to call * @param version The version of the method to call * @param args The arguments to pass to the method * @returns an observable fro the creation of the worker. */ startWorker(entryPointId: string, method: string, version: number, ...args: any[]): Observable<void>; /** * Runs a dialog instance and returns its result. After which the dialog is destroyed. * @param entryPointId The id of the dialog to create * @param version The version of the dialog to call * @param args The arguments to pass to the dialog * @returns an observable for the result of the dialog. */ createDialog(entryPointId: string): Observable<any>; /** * Runs a dialog instance and returns its result. After which the dialog is destroyed. * @param entryPointId The id of the dialog to create * @param version The version of the dialog to call * @param args The arguments to pass to the dialog * @returns an observable for the result of the dialog. */ showDialog(entryPointId: string, version: number, ...args: any[]): Observable<any>; /** * Runs a dialog instance and returns its result. After which the dialog is destroyed. * @param instanceId The id of the extension to show * @param version The version of the extension tp show * @param args The arguments to pass to the extension * @returns an observable for the result of the dialog. */ show(instanceId: string, version: number, ...args: any[]): Observable<any>; /** * Emit a result to listeners subscribed to the given eventType and instanceId * @param instanceId The instance Id of the component emitting the result * @param eventType the type of event being emitted, can be any string like "output", "validation", "changes" * so listeners can subscribe to specific event streams. listeners must be aware of chosen eventType * @param result the result to be sent to event listeners */ emitResult<T>(instanceId: string, eventType: string, result: T): Observable<ExtensionBrokerResponsePayload>; /** * Calls a method on a service extension * @param entryPointId The id of the service to call * @param method The method to call * @param version The version of the method to call * @param args The arguments to pass to the method * @returns an observable for the result of the service method. */ callService(entryPointId: string, method: string, version: number, ...args: any[]): Observable<any>; destroyRequested(entryPointId: string, version: number, args?: any[]): Observable<any>; /** * Makes an extension broker request via the RPC * @param requestType The @see RpcExtensionBrokerRequestType. * @param payload The payload for this message. Depends on requestType. * @returns An observable for the response message from the shell */ request<T extends ExtensionBrokerResponsePayload>(payload: ExtensionBrokerRequestPayload): Observable<T>; }