kodi-api
Version:
A complete implementation of Kodi JSON-RPC calls in an easy-to-use Javascript/TypeScript client.
64 lines (63 loc) • 2.55 kB
TypeScript
import type { HttpClient, HttpClientOptions, HttpsClient, HttpsClientOptions, TcpClient, TcpClientOptions } from 'jayson/promise';
import type { Schema } from 'jsonschema';
import type { WebSocketClient, WebSocketClientOptions } from './WebSocketClient';
export interface JsonSchema extends Schema {
name?: string;
}
export declare type JaysonClient = HttpClient | HttpsClient | TcpClient | WebSocketClient;
export declare type JaysonClientOptions = HttpClientOptions | HttpsClientOptions | TcpClientOptions | WebSocketClientOptions;
export declare type ClientType = 'http' | 'https' | 'tcp' | 'ws';
export declare type ParameterMode = 'arguments' | 'object';
export declare type KodiObjectMethod = (obj?: Record<string, any>) => Promise<any>;
export declare type KodiArgumentMethod = (...args: any[]) => Promise<any>;
export declare type KodiMethod = KodiArgumentMethod | KodiObjectMethod;
interface KodiBaseClientOptions {
clientType: ClientType;
clientOptions?: JaysonClientOptions;
throwValidationError?: boolean;
parameterMode?: ParameterMode;
}
interface KodiHttpClientOptions extends KodiBaseClientOptions {
clientType: 'http';
clientOptions?: HttpClientOptions;
}
interface KodiHttpsClientOptions extends KodiBaseClientOptions {
clientType: 'https';
clientOptions?: HttpsClientOptions;
}
interface KodiTcpClientOptions extends KodiBaseClientOptions {
clientType: 'tcp';
clientOptions?: TcpClientOptions;
}
interface KodiWsClientOptions extends KodiBaseClientOptions {
clientType: 'ws';
clientOptions?: WebSocketClientOptions;
}
export declare type KodiClientOptions = KodiHttpClientOptions | KodiHttpsClientOptions | KodiTcpClientOptions | KodiWsClientOptions;
export interface JsonRpcResponse {
id?: string | number;
jsonrpc: '2.0';
result: any;
}
export interface ServiceDescription {
description: string;
id: 'http://xbmc.org/jsonrpc/ServiceDescription.json';
version: string;
methods: Record<string, MethodDescription>;
notifications: Record<string, NotificationDescription>;
types: Record<string, JsonSchema>;
}
export interface PropertyDescription {
description: string;
params: JsonSchema[];
returns: JsonSchema;
type: 'method' | 'notification';
}
export interface MethodDescription extends PropertyDescription {
type: 'method';
}
export interface NotificationDescription extends PropertyDescription {
returns: null;
type: 'notification';
}
export {};