*Update dist

This commit is contained in:
Derrick Hammer 2022-12-04 06:37:24 -05:00
parent 8c2f857c55
commit bc34a95ebb
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
14 changed files with 99 additions and 67 deletions

7
dist/index.d.ts vendored
View File

@ -1,7 +1,4 @@
import RpcNetwork from "./network.js";
import RpcQueryBase from "./query/base.js";
import SimpleRpcQuery from "./query/simple.js";
import WisdomRpcQuery from "./query/wisdom.js";
export * from "./types.js";
export { RpcNetwork, RpcQueryBase, SimpleRpcQuery, WisdomRpcQuery };
export * from "./query/index.js";
export * from "./network.js";
//# sourceMappingURL=index.d.ts.map

2
dist/index.d.ts.map vendored
View File

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAE/C,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC"}

7
dist/index.js vendored
View File

@ -1,6 +1,3 @@
import RpcNetwork from "./network.js";
import RpcQueryBase from "./query/base.js";
import SimpleRpcQuery from "./query/simple.js";
import WisdomRpcQuery from "./query/wisdom.js";
export * from "./types.js";
export { RpcNetwork, RpcQueryBase, SimpleRpcQuery, WisdomRpcQuery };
export * from "./query/index.js";
export * from "./network.js";

28
dist/network.d.ts vendored
View File

@ -1,8 +1,8 @@
import SimpleRpcQuery from "./query/simple.js";
import WisdomRpcQuery from "./query/wisdom.js";
import { RpcQueryOptions } from "./types.js";
import RpcNetworkQueryFactory from "./query/index.js";
export default class RpcNetwork {
constructor(dht?: any);
private _factory;
get factory(): RpcNetworkQueryFactory;
private _dht;
get dht(): any;
private _majorityThreshold;
@ -27,27 +27,5 @@ export default class RpcNetwork {
addRelay(pubkey: string): void;
removeRelay(pubkey: string): boolean;
clearRelays(): void;
wisdomQuery(
method: string,
module: string,
data?: object | any[],
bypassCache?: boolean,
options?: {}
): WisdomRpcQuery;
simpleQuery(
relay: string,
method: string,
module: string,
data?: object | any[],
bypassCache?: boolean,
options?: RpcQueryOptions
): SimpleRpcQuery;
clearCacheQuery(
relays: string[],
method: string,
module: string,
data?: object | any[],
options?: RpcQueryOptions
): SimpleRpcQuery;
}
//# sourceMappingURL=network.d.ts.map

View File

@ -1 +1 @@
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAKA,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,UAAU;gBACjB,GAAG,MAAY;IAI3B,OAAO,CAAC,IAAI,CAAa;IAEzB,IAAI,GAAG,QAEN;IAED,OAAO,CAAC,kBAAkB,CAAQ;IAElC,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED,IAAI,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAElC;IAED,OAAO,CAAC,aAAa,CAAM;IAE3B,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,EAE7B;IAED,OAAO,CAAC,aAAa,CAAK;IAE1B,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,EAE7B;IAED,OAAO,CAAC,OAAO,CAAgB;IAE/B,IAAI,MAAM,IAAI,MAAM,EAAE,CAErB;IAED,OAAO,CAAC,MAAM,CAAC,CAAgB;IAE/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AAkB,CAAQ;IAElC,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED,IAAI,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAElC;IAED,OAAO,CAAC,aAAa,CAAM;IAE3B,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,EAE7B;IAED,OAAO,CAAC,aAAa,CAAK;IAE1B,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,EAE7B;IAED,OAAO,CAAC,OAAO,CAAgB;IAE/B,IAAI,MAAM,IAAI,MAAM,EAAE,CAErB;IAED,OAAO,CAAC,MAAM,CAAC,CAAgB;IAE/B,IAAI,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAMzB;IAED,OAAO,CAAC,YAAY,CAAkB;IAEtC,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,IAAI,WAAW,CAAC,KAAK,EAAE,OAAO,EAE7B;IAED,OAAO,CAAC,UAAU,CAAa;IAE/B,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,SAAS,CAAC,KAAK,EAAE,MAAM,EAE1B;IAEM,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAK9B,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAWpC,WAAW,IAAI,IAAI;CAG3B"}

31
dist/network.js vendored
View File

@ -1,12 +1,14 @@
// @ts-ignore
import DHT from "@hyperswarm/dht";
import SimpleRpcQuery from "./query/simple.js";
import WisdomRpcQuery from "./query/wisdom.js";
import ClearCacheRpcQuery from "./query/clearCache.js";
import RpcNetworkQueryFactory from "./query/index.js";
export default class RpcNetwork {
constructor(dht = new DHT()) {
this._dht = dht;
}
_factory = new RpcNetworkQueryFactory(this);
get factory() {
return this._factory;
}
_dht;
get dht() {
return this._dht;
@ -72,27 +74,4 @@ export default class RpcNetwork {
clearRelays() {
this._relays = [];
}
wisdomQuery(method, module, data = {}, bypassCache = false, options = {}) {
return new WisdomRpcQuery(this, {
method,
module,
data,
bypassCache: bypassCache || this._bypassCache,
}, options).run();
}
simpleQuery(relay, method, module, data = {}, bypassCache = false, options = {}) {
return new SimpleRpcQuery(this, relay, {
method,
module,
data,
bypassCache: bypassCache || this._bypassCache,
}, options).run();
}
clearCacheQuery(relays, method, module, data = {}, options = {}) {
return new ClearCacheRpcQuery(this, relays, {
method,
module,
data,
}, options).run();
}
}

38
dist/query/index.d.ts vendored Normal file
View File

@ -0,0 +1,38 @@
import { ClientRPCRequest, RPCRequest } from "@lumeweb/relay-types";
import { RpcQueryOptions } from "../types.js";
import WisdomRpcQuery from "./wisdom.js";
import SimpleRpcQuery from "./simple.js";
import ClearCacheRpcQuery from "./clearCache.js";
import RpcNetwork from "../network.js";
import RpcQueryBase from "./base.js";
export default class RpcNetworkQueryFactory {
private _network;
constructor(network: RpcNetwork);
wisdom({
query,
options,
}: {
query: ClientRPCRequest;
options?: RpcQueryOptions;
}): WisdomRpcQuery;
simple({
relay,
query,
options,
}: {
relay: string;
query: ClientRPCRequest;
options?: RpcQueryOptions;
}): SimpleRpcQuery;
clearCache({
relays,
query,
options,
}: {
relays: string[];
query: RPCRequest;
options?: RpcQueryOptions;
}): ClearCacheRpcQuery;
}
export { RpcNetwork, RpcQueryBase, SimpleRpcQuery, WisdomRpcQuery };
//# sourceMappingURL=index.d.ts.map

1
dist/query/index.d.ts.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/query/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,cAAc,MAAM,aAAa,CAAC;AACzC,OAAO,cAAc,MAAM,aAAa,CAAC;AACzC,OAAO,kBAAkB,MAAM,iBAAiB,CAAC;AACjD,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,YAAY,MAAM,WAAW,CAAC;AAErC,MAAM,CAAC,OAAO,OAAO,sBAAsB;IACzC,OAAO,CAAC,QAAQ,CAAa;gBAEjB,OAAO,EAAE,UAAU;IAI/B,MAAM,CAAC,EACL,KAAK,EACL,OAAY,GACb,EAAE;QACD,KAAK,EAAE,gBAAgB,CAAC;QACxB,OAAO,CAAC,EAAE,eAAe,CAAC;KAC3B,GAAG,cAAc;IAWlB,MAAM,CAAC,EACL,KAAK,EACL,KAAK,EACL,OAAY,GACb,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,gBAAgB,CAAC;QACxB,OAAO,CAAC,EAAE,eAAe,CAAC;KAC3B,GAAG,cAAc;IAYlB,UAAU,CAAC,EACT,MAAM,EACN,KAAK,EACL,OAAY,GACb,EAAE;QACD,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,KAAK,EAAE,UAAU,CAAC;QAClB,OAAO,CAAC,EAAE,eAAe,CAAC;KAC3B,GAAG,kBAAkB;CAGvB;AAED,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC"}

27
dist/query/index.js vendored Normal file
View File

@ -0,0 +1,27 @@
import WisdomRpcQuery from "./wisdom.js";
import SimpleRpcQuery from "./simple.js";
import ClearCacheRpcQuery from "./clearCache.js";
import RpcNetwork from "../network.js";
import RpcQueryBase from "./base.js";
export default class RpcNetworkQueryFactory {
_network;
constructor(network) {
this._network = network;
}
wisdom({ query, options = {}, }) {
return new WisdomRpcQuery(this._network, {
...query,
bypassCache: query.bypassCache || this._network.bypassCache,
}, options).run();
}
simple({ relay, query, options = {}, }) {
return new SimpleRpcQuery(this._network, relay, {
...query,
bypassCache: query.bypassCache || this._network.bypassCache,
}, options).run();
}
clearCache({ relays, query, options = {}, }) {
return new ClearCacheRpcQuery(this._network, relays, query, options).run();
}
}
export { RpcNetwork, RpcQueryBase, SimpleRpcQuery, WisdomRpcQuery };

View File

@ -4,6 +4,7 @@ import { RpcQueryOptions } from "../types.js";
import RpcQueryBase from "./base.js";
export default class SimpleRpcQuery extends RpcQueryBase {
protected _relay: string;
protected _query: ClientRPCRequest;
constructor(
network: RpcNetwork,
relay: string,

View File

@ -1 +1 @@
{"version":3,"file":"simple.d.ts","sourceRoot":"","sources":["../../src/query/simple.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EACL,gBAAgB,EAIjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAU9C,OAAO,YAAY,MAAM,WAAW,CAAC;AAErC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,YAAY;IACtD,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;gBAGvB,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,eAAe;cAMV,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;cAKrB,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC;cA2B1B,cAAc;CAmB/B"}
{"version":3,"file":"simple.d.ts","sourceRoot":"","sources":["../../src/query/simple.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EACL,gBAAgB,EAIjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAW9C,OAAO,YAAY,MAAM,WAAW,CAAC;AAErC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,YAAY;IACtD,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,UAAkB,MAAM,EAAE,gBAAgB,CAAC;gBAGzC,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,eAAe;cAMV,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;cAKrB,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC;cAwC1B,cAAc;CAmB/B"}

13
dist/query/simple.js vendored
View File

@ -1,5 +1,5 @@
import b4a from "b4a";
import { isPromise, validateTimestampedResponse, } from "../util.js";
import { hashQuery, isPromise, validateTimestampedResponse, } from "../util.js";
import RPC from "@lumeweb/rpc";
import { ERR_INVALID_SIGNATURE } from "../error.js";
import RpcQueryBase from "./base.js";
@ -26,6 +26,17 @@ export default class SimpleRpcQuery extends RpcQueryBase {
}
await socket.opened;
const rpc = new RPC(socket);
if (this._query.bypassCache) {
delete this._query.bypassCache;
await this.queryRpc(rpc, {
module: "rpc",
method: "clear_cached_item",
data: hashQuery(this._query),
});
}
if ("bypassCache" in this._query) {
delete this._query.bypassCache;
}
try {
await this.queryRpc(rpc, this._query);
}

View File

@ -1 +1 @@
{"version":3,"file":"wisdom.d.ts","sourceRoot":"","sources":["../../src/query/wisdom.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAEhB,oBAAoB,EAEpB,WAAW,EACZ,MAAM,sBAAsB,CAAC;AAW9B,OAAO,YAAY,MAAM,WAAW,CAAC;AAUrC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,YAAY;IACtD,UAAkB,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACnD,UAAkB,MAAM,EAAE,gBAAgB,CAAC;IAC3C,IAAI,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,CAEjC;cAEe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAMrC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,OAAO,GAAE,OAAe,GAAG,IAAI;cAcrD,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC;cAgC1B,aAAa;IAyE7B,SAAS,CAAC,SAAS,IAAI,MAAM,EAAE;CAmBhC"}
{"version":3,"file":"wisdom.d.ts","sourceRoot":"","sources":["../../src/query/wisdom.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAEhB,oBAAoB,EAEpB,WAAW,EACZ,MAAM,sBAAsB,CAAC;AAW9B,OAAO,YAAY,MAAM,WAAW,CAAC;AAUrC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,YAAY;IACtD,UAAkB,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACnD,UAAkB,MAAM,EAAE,gBAAgB,CAAC;IAC3C,IAAI,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,CAEjC;cAEe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAMrC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,OAAO,GAAE,OAAe,GAAG,IAAI;cAcrD,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC;cA8B1B,aAAa;IAyE7B,SAAS,CAAC,SAAS,IAAI,MAAM,EAAE;CAmBhC"}

View File

@ -37,7 +37,10 @@ export default class WisdomRpcQuery extends RpcQueryBase {
}
if (this._query.bypassCache) {
delete this._query.bypassCache;
const clearCacheQuery = this._network.clearCacheQuery(relays, this._query.method, this._query.module, this._query.data);
const clearCacheQuery = this._network.factory.clearCache({
relays,
query: this._query,
});
await clearCacheQuery.result;
}
if ("bypassCache" in this._query) {