@iotize/device-client.js
Version:
IoTize Device client for Javascript
46 lines (45 loc) • 1.89 kB
TypeScript
import { Command } from "../../../client/api/request";
import { Command as CommandInterface } from "../../../client/api/request/command";
import { Response as ResponseInterface } from "../../../client/api/response/response.interface";
import { ApiRequest } from "../../../client/impl/request";
import { ResponseAdapter, FilterFunction, Predicate, ResponseAdapterFunction, RouteType } from "./definitions";
export declare class EqualRequestFilter implements Predicate<CommandInterface> {
protected command: CommandInterface;
constructor(command: CommandInterface);
test(command: CommandInterface): boolean;
toString(): string;
}
export declare class RegExpFilter implements Predicate<Command> {
protected regex: RegExp;
constructor(regex: RegExp);
test(input: Command): boolean;
}
export declare class Util {
static parseApiRequestString(cmdString: string): ApiRequest;
}
export declare class Router {
_routes: {
predicate: Predicate<any>;
adapter: ResponseAdapter<any>;
}[];
constructor();
readonly routes: {
predicate: Predicate<any>;
adapter: ResponseAdapter<any>;
}[];
findRoute(request: Command): any;
addRoute<T>(left: FilterFunction<CommandInterface> | Predicate<CommandInterface> | CommandInterface | RegExp | string, right: ResponseAdapterFunction<T> | ResponseAdapter<T> | ResponseInterface<T> | Uint8Array): this;
/**
* Mapping a command (represented as a string with format "<request-type> <path> [data]"
* ie: GET /3//3 0xABCD or POST /1024//0 0xtest
*
* Response must either be:
* - an hexadecimal data represented as a string (0xABCD)
* - An object with a coreRet and a body
* - A Uint8Array
*/
addRoutes(map: {
[key: string]: RouteType;
}): this;
clearRoutes(): this;
}