@mochabug/adapt-web
Version:
The client library to execute automations, without effort, in a browser environment
37 lines (36 loc) • 1.78 kB
TypeScript
import { ValueJson } from "@bufbuild/protobuf/wkt";
import { AutomationIdJson, GetSessionResponseJson, InheritSessionResponseJson, ReadOutputResponseJson, ReadUrlsResponseJson, SessionJson, StartSessionRequestJson, StartSessionResponseJson, UrlJson } from "./genproto/mochabugapis/adapt/automations/v1/automations_pb.js";
export declare function startSession(req: StartSessionRequestJson, token?: string): Promise<StartSessionResponseJson>;
export declare function inheritSession(automation: AutomationIdJson, sessionToken: string): Promise<InheritSessionResponseJson>;
export declare function getSession(automation: AutomationIdJson, sessionToken: string): Promise<GetSessionResponseJson>;
export declare function readOutput(automation: AutomationIdJson, sessionToken: string): Promise<ReadOutputResponseJson>;
export declare function readUrls(automation: AutomationIdJson, sessionToken: string): Promise<ReadUrlsResponseJson>;
export declare function stopSession(automation: AutomationIdJson, sessionToken: string): Promise<void>;
export declare class RestClientError extends Error {
status: number;
statusText: string;
response: Response;
constructor(response: Response);
}
export interface Output {
vertex: string;
data: {
[key: string]: ValueJson;
};
created?: Date;
}
export type SubscriptionOptions = {
sessionToken: string;
session: string;
automation: AutomationIdJson;
onOutput?: (output: Output) => void;
onSession?: (session: SessionJson) => void;
onUrl?: (url: UrlJson) => void;
};
export declare class MqttClient {
private readonly clientId;
private mqttClient;
constructor(clientId: string);
subscribe(opts: SubscriptionOptions): Promise<void>;
unsubscribe(): Promise<void>;
}