sprinklers3/common/sprinklersRpc/websocketData.ts

80 lines
2.5 KiB
TypeScript
Raw Normal View History

import * as rpc from "../jsonRpc/index";
2018-08-12 11:55:15 +03:00
import { IUser } from "@common/httpApi";
import { Response as ResponseData } from "@common/sprinklersRpc/deviceRequests";
export interface IAuthenticateRequest {
accessToken: string;
}
export interface IDeviceSubscribeRequest {
2018-06-29 18:16:06 -06:00
deviceId: string;
}
export interface IDeviceCallRequest {
deviceId: string;
2017-10-09 08:09:08 -06:00
data: any;
}
export interface IClientRequestTypes {
"authenticate": IAuthenticateRequest;
"deviceSubscribe": IDeviceSubscribeRequest;
"deviceUnsubscribe": IDeviceSubscribeRequest;
"deviceCall": IDeviceCallRequest;
}
export interface IAuthenticateResponse {
authenticated: boolean;
message: string;
2018-08-12 11:55:15 +03:00
user: IUser;
}
export interface IDeviceSubscribeResponse {
deviceId: string;
}
2017-10-09 08:09:08 -06:00
export interface IDeviceCallResponse {
data: ResponseData;
2017-10-09 08:09:08 -06:00
}
export interface IServerResponseTypes {
"authenticate": IAuthenticateResponse;
"deviceSubscribe": IDeviceSubscribeResponse;
"deviceUnsubscribe": IDeviceSubscribeResponse;
"deviceCall": IDeviceCallResponse;
2018-06-16 23:54:03 -06:00
}
export type ClientRequestMethods = keyof IClientRequestTypes;
export interface IBrokerConnectionUpdate {
brokerConnected: boolean;
2018-06-30 14:49:13 -06:00
}
export interface IDeviceUpdate {
deviceId: string;
data: any;
}
2017-10-09 08:09:08 -06:00
export interface IServerNotificationTypes {
"brokerConnectionUpdate": IBrokerConnectionUpdate;
"deviceUpdate": IDeviceUpdate;
2018-06-30 23:26:48 -06:00
"error": IError;
2017-10-09 08:09:08 -06:00
}
export type ServerNotificationMethod = keyof IServerNotificationTypes;
2018-06-30 23:26:48 -06:00
export type IError = rpc.DefaultErrorType;
export type ErrorData = rpc.ErrorData<IError>;
2018-06-30 23:26:48 -06:00
export type ServerMessage = rpc.Message<{}, IServerResponseTypes, IError, IServerNotificationTypes>;
export type ServerNotification = rpc.Notification<IServerNotificationTypes>;
2018-06-30 23:26:48 -06:00
export type ServerResponse = rpc.Response<IServerResponseTypes, IError>;
export type ServerResponseData<Method extends keyof IServerResponseTypes = keyof IServerResponseTypes> =
2018-06-30 23:26:48 -06:00
rpc.ResponseData<IServerResponseTypes, IError, Method>;
export type ServerResponseHandlers = rpc.ResponseHandlers<IServerResponseTypes, IError>;
export type ServerNotificationHandlers = rpc.NotificationHandlers<IServerNotificationTypes>;
2017-10-09 08:09:08 -06:00
export type ClientRequest<Method extends keyof IClientRequestTypes = keyof IClientRequestTypes> =
rpc.Request<IClientRequestTypes, Method>;
2018-06-30 23:26:48 -06:00
export type ClientMessage = rpc.Message<IClientRequestTypes, {}, IError, {}>;
export type ClientRequestHandlers = rpc.RequestHandlers<IClientRequestTypes, IServerResponseTypes, IError>;