diff --git a/dist/index.d.ts b/dist/index.d.ts index 15b8544..df559b6 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,41 +1,83 @@ /// import { ErrTuple } from "libskynet"; import type { RPCRequest } from "@lumeweb/relay-types"; -import { RpcQueryOptions, StreamHandlerFunction, StreamingRpcQueryOptions } from "@lumeweb/dht-rpc-client"; +import { + RpcQueryOptions, + StreamHandlerFunction, + StreamingRpcQueryOptions, +} from "@lumeweb/dht-rpc-client"; import { Buffer } from "buffer"; export declare class RpcNetwork { - private _actionQueue; - private _addQueue; - private _removeQueue; - get ready(): Promise; - addRelay(pubkey: string): void; - removeRelay(pubkey: string): void; - clearRelays(): void; - private static deleteItem; - wisdomQuery(method: string, module: string, data?: object | any[], bypassCache?: boolean, options?: RpcQueryOptions): WisdomRpcQuery; - streamingQuery(relay: Buffer | string, method: string, module: string, streamHandler: StreamHandlerFunction, data?: object | any[], options?: RpcQueryOptions): StreamingRpcQuery; - simpleQuery(relay: Buffer | string, method: string, module: string, data?: object | any[], options?: RpcQueryOptions): SimpleRpcQuery; - processQueue(): Promise; + private _actionQueue; + private _addQueue; + private _removeQueue; + get ready(): Promise; + addRelay(pubkey: string): void; + removeRelay(pubkey: string): void; + clearRelays(): void; + private static deleteItem; + wisdomQuery( + method: string, + module: string, + data?: object | any[], + bypassCache?: boolean, + options?: RpcQueryOptions + ): WisdomRpcQuery; + streamingQuery( + relay: Buffer | string, + method: string, + module: string, + streamHandler: StreamHandlerFunction, + data?: object | any[], + options?: RpcQueryOptions + ): StreamingRpcQuery; + simpleQuery( + relay: Buffer | string, + method: string, + module: string, + data?: object | any[], + options?: RpcQueryOptions + ): SimpleRpcQuery; + processQueue(): Promise; } export declare abstract class RpcQueryBase { - protected _promise?: Promise; - protected _network: RpcNetwork; - protected _query: RPCRequest; - protected _options: RpcQueryOptions; - protected _queryType: string; - constructor(network: RpcNetwork, query: RPCRequest, options: RpcQueryOptions | undefined, queryType: string); - run(): this; - get result(): Promise; + protected _promise?: Promise; + protected _network: RpcNetwork; + protected _query: RPCRequest; + protected _options: RpcQueryOptions; + protected _queryType: string; + constructor( + network: RpcNetwork, + query: RPCRequest, + options: RpcQueryOptions | undefined, + queryType: string + ); + run(): this; + get result(): Promise; } export declare class SimpleRpcQuery extends RpcQueryBase { - constructor(network: RpcNetwork, relay: string | Buffer, query: RPCRequest, options: RpcQueryOptions); + constructor( + network: RpcNetwork, + relay: string | Buffer, + query: RPCRequest, + options: RpcQueryOptions + ); } export declare class StreamingRpcQuery extends RpcQueryBase { - protected _options: StreamingRpcQueryOptions; - constructor(network: RpcNetwork, relay: string | Buffer, query: RPCRequest, options: StreamingRpcQueryOptions); - run(): this; + protected _options: StreamingRpcQueryOptions; + constructor( + network: RpcNetwork, + relay: string | Buffer, + query: RPCRequest, + options: StreamingRpcQueryOptions + ); + run(): this; } export declare class WisdomRpcQuery extends RpcQueryBase { - constructor(network: RpcNetwork, query: RPCRequest, options?: RpcQueryOptions); + constructor( + network: RpcNetwork, + query: RPCRequest, + options?: RpcQueryOptions + ); } -//# sourceMappingURL=index.d.ts.map \ No newline at end of file +//# sourceMappingURL=index.d.ts.map diff --git a/dist/index.d.ts.map b/dist/index.d.ts.map index 54cd00e..4d48f44 100644 --- a/dist/index.d.ts.map +++ b/dist/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAsBhC,qBAAa,UAAU;IACrB,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,YAAY,CAAgB;IAEp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AAG,MAAM,EACtB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,wBAAwB;IAM5B,GAAG,IAAI,IAAI;CAenB;AAED,qBAAa,cAAe,SAAQ,YAAY;gBAE5C,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,UAAU,EACjB,OAAO,GAAE,eAAoB;CAIhC"} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index d279d56..740bbec 100644 --- a/dist/index.js +++ b/dist/index.js @@ -88,9 +88,10 @@ export class RpcQueryBase { this._queryType = queryType; } run() { - this._promise = this._network - .processQueue() - .then(() => callModule(RPC_MODULE, this._queryType, this._query)); + this._promise = this._network.processQueue().then(() => callModule(RPC_MODULE, this._queryType, { + query: this._query, + options: this._options, + })); return this; } get result() { @@ -114,9 +115,10 @@ export class StreamingRpcQuery extends RpcQueryBase { this._options = options; } run() { - this._promise = this._network - .processQueue() - .then(() => connectModule(RPC_MODULE, this._queryType, this._query, this._options.streamHandler)); + this._promise = this._network.processQueue().then(() => connectModule(RPC_MODULE, this._queryType, { + query: this._query, + options: this._options, + }, this._options.streamHandler)); return this; } }