@waku/core 0.0.31-1887f4f.0 → 0.0.31-39f8920.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/{base_protocol-WTp5jKZK.js → base_protocol-Dge5_tvU.js} +3 -7
- package/bundle/{index-COT0phC8.js → index-Gts2Ddu_.js} +38 -52
- package/bundle/index.js +214 -193
- package/bundle/lib/base_protocol.js +2 -2
- package/bundle/lib/message/version_0.js +2 -2
- package/bundle/{version_0-SMRUXDNR.js → version_0-CNRKFufI.js} +154 -308
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/base_protocol.d.ts +2 -3
- package/dist/lib/base_protocol.js +3 -7
- package/dist/lib/base_protocol.js.map +1 -1
- package/dist/lib/connection_manager.d.ts +1 -1
- package/dist/lib/connection_manager.js.map +1 -1
- package/dist/lib/filter/index.d.ts +3 -2
- package/dist/lib/filter/index.js +4 -2
- package/dist/lib/filter/index.js.map +1 -1
- package/dist/lib/health_manager.d.ts +14 -0
- package/dist/lib/health_manager.js +70 -0
- package/dist/lib/health_manager.js.map +1 -0
- package/dist/lib/light_push/index.d.ts +3 -2
- package/dist/lib/light_push/index.js +4 -2
- package/dist/lib/light_push/index.js.map +1 -1
- package/dist/lib/metadata/index.d.ts +2 -2
- package/dist/lib/metadata/index.js +9 -9
- package/dist/lib/metadata/index.js.map +1 -1
- package/dist/lib/store/index.d.ts +5 -44
- package/dist/lib/store/index.js +39 -45
- package/dist/lib/store/index.js.map +1 -1
- package/dist/lib/store/rpc.d.ts +22 -0
- package/dist/lib/store/rpc.js +74 -0
- package/dist/lib/store/rpc.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +2 -2
- package/src/lib/base_protocol.ts +3 -7
- package/src/lib/connection_manager.ts +1 -1
- package/src/lib/filter/index.ts +3 -10
- package/src/lib/health_manager.ts +90 -0
- package/src/lib/light_push/index.ts +6 -9
- package/src/lib/metadata/index.ts +11 -12
- package/src/lib/store/index.ts +53 -93
- package/src/lib/store/rpc.ts +92 -0
- package/dist/lib/store/history_rpc.d.ts +0 -27
- package/dist/lib/store/history_rpc.js +0 -72
- package/dist/lib/store/history_rpc.js.map +0 -1
- package/src/lib/store/history_rpc.ts +0 -93
@@ -1,93 +0,0 @@
|
|
1
|
-
import { proto_store as proto } from "@waku/proto";
|
2
|
-
import type { Uint8ArrayList } from "uint8arraylist";
|
3
|
-
import { v4 as uuid } from "uuid";
|
4
|
-
|
5
|
-
const OneMillion = BigInt(1_000_000);
|
6
|
-
|
7
|
-
export enum PageDirection {
|
8
|
-
BACKWARD = "backward",
|
9
|
-
FORWARD = "forward"
|
10
|
-
}
|
11
|
-
|
12
|
-
export interface Params {
|
13
|
-
contentTopics: string[];
|
14
|
-
pubsubTopic: string;
|
15
|
-
pageDirection: PageDirection;
|
16
|
-
pageSize: number;
|
17
|
-
startTime?: Date;
|
18
|
-
endTime?: Date;
|
19
|
-
cursor?: proto.Index;
|
20
|
-
}
|
21
|
-
|
22
|
-
export class HistoryRpc {
|
23
|
-
private constructor(public readonly proto: proto.HistoryRpc) {}
|
24
|
-
|
25
|
-
public get query(): proto.HistoryQuery | undefined {
|
26
|
-
return this.proto.query;
|
27
|
-
}
|
28
|
-
|
29
|
-
public get response(): proto.HistoryResponse | undefined {
|
30
|
-
return this.proto.response;
|
31
|
-
}
|
32
|
-
|
33
|
-
/**
|
34
|
-
* Create History Query.
|
35
|
-
*/
|
36
|
-
public static createQuery(params: Params): HistoryRpc {
|
37
|
-
const contentFilters = params.contentTopics.map((contentTopic) => {
|
38
|
-
return { contentTopic };
|
39
|
-
});
|
40
|
-
|
41
|
-
const direction = directionToProto(params.pageDirection);
|
42
|
-
|
43
|
-
const pagingInfo = {
|
44
|
-
pageSize: BigInt(params.pageSize),
|
45
|
-
cursor: params.cursor,
|
46
|
-
direction
|
47
|
-
} as proto.PagingInfo;
|
48
|
-
|
49
|
-
let startTime, endTime;
|
50
|
-
if (params.startTime) {
|
51
|
-
// milliseconds 10^-3 to nanoseconds 10^-9
|
52
|
-
startTime = BigInt(params.startTime.valueOf()) * OneMillion;
|
53
|
-
}
|
54
|
-
|
55
|
-
if (params.endTime) {
|
56
|
-
// milliseconds 10^-3 to nanoseconds 10^-9
|
57
|
-
endTime = BigInt(params.endTime.valueOf()) * OneMillion;
|
58
|
-
}
|
59
|
-
return new HistoryRpc({
|
60
|
-
requestId: uuid(),
|
61
|
-
query: {
|
62
|
-
pubsubTopic: params.pubsubTopic,
|
63
|
-
contentFilters,
|
64
|
-
pagingInfo,
|
65
|
-
startTime,
|
66
|
-
endTime
|
67
|
-
},
|
68
|
-
response: undefined
|
69
|
-
});
|
70
|
-
}
|
71
|
-
|
72
|
-
public decode(bytes: Uint8ArrayList): HistoryRpc {
|
73
|
-
const res = proto.HistoryRpc.decode(bytes);
|
74
|
-
return new HistoryRpc(res);
|
75
|
-
}
|
76
|
-
|
77
|
-
public encode(): Uint8Array {
|
78
|
-
return proto.HistoryRpc.encode(this.proto);
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
function directionToProto(
|
83
|
-
pageDirection: PageDirection
|
84
|
-
): proto.PagingInfo.Direction {
|
85
|
-
switch (pageDirection) {
|
86
|
-
case PageDirection.BACKWARD:
|
87
|
-
return proto.PagingInfo.Direction.BACKWARD;
|
88
|
-
case PageDirection.FORWARD:
|
89
|
-
return proto.PagingInfo.Direction.FORWARD;
|
90
|
-
default:
|
91
|
-
return proto.PagingInfo.Direction.BACKWARD;
|
92
|
-
}
|
93
|
-
}
|