@waku/interfaces 0.0.26-ce62600.0 → 0.0.26-f387f59.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.
@@ -0,0 +1,12 @@
1
+ export type ShardInfo = {
2
+ clusterId: number;
3
+ shards: number[];
4
+ };
5
+
6
+ export type ContentTopicInfo = {
7
+ clusterId?: number;
8
+ contentTopics: string[];
9
+ };
10
+
11
+ export type StaticSharding = ShardInfo;
12
+ export type AutoSharding = ContentTopicInfo;
package/src/store.ts CHANGED
@@ -1,72 +1,101 @@
1
- import { proto_store as proto } from "@waku/proto";
2
-
3
1
  import type { IDecodedMessage, IDecoder } from "./message.js";
4
2
  import type { IBaseProtocolCore, IBaseProtocolSDK } from "./protocols.js";
5
3
 
6
- export enum PageDirection {
7
- BACKWARD = "backward",
8
- FORWARD = "forward"
9
- }
4
+ export type StoreCursor = Uint8Array;
10
5
 
11
- export interface TimeFilter {
12
- startTime: Date;
13
- endTime: Date;
14
- }
6
+ /**
7
+ * Parameters for a store query request, as specified in the Waku Store v3 RFC.
8
+ */
9
+ export type QueryRequestParams = {
10
+ /**
11
+ * Whether to include the full message data in the response.
12
+ * - `true`: The response will include the message content and associated pubsub topic for each matching message.
13
+ * - `false`: The response will only include the message hashes for each matching message.
14
+ * @default true
15
+ */
16
+ includeData: boolean;
15
17
 
16
- export interface Cursor {
17
- digest: Uint8Array;
18
- receiverTime: bigint;
19
- senderTime: bigint;
18
+ /**
19
+ * The pubsub topic to query. This field is mandatory.
20
+ * The query will only return messages that were published on this specific pubsub topic.
21
+ */
20
22
  pubsubTopic: string;
21
- }
22
23
 
23
- export type StoreQueryOptions = {
24
24
  /**
25
- * The direction in which pages are retrieved:
26
- * - { @link PageDirection.BACKWARD }: Most recent page first.
27
- * - { @link PageDirection.FORWARD }: Oldest page first.
28
- *
29
- * Note: This does not affect the ordering of messages with the page
30
- * (the oldest message is always first).
31
- *
32
- * @default { @link PageDirection.BACKWARD }
25
+ * The content topics to filter the messages.
26
+ * The query will only return messages that have a content topic included in this array.
27
+ * This field MUST be populated together with the `pubsubTopic` field for content topic filtering to be applied.
28
+ * If either `contentTopics` or `pubsubTopic` is not provided or empty, no content topic filtering will be applied.
33
29
  */
34
- pageDirection?: PageDirection;
30
+ contentTopics: string[];
31
+
35
32
  /**
36
- * The number of message per page.
33
+ * The start time for the time range filter.
34
+ * The query will only return messages with a timestamp greater than or equal to `timeStart`.
35
+ * If not provided, no start time filtering will be applied.
37
36
  */
38
- pageSize?: number;
37
+ timeStart?: Date;
38
+
39
39
  /**
40
- * Retrieve messages with a timestamp within the provided values.
40
+ * The end time for the time range filter.
41
+ * The query will only return messages with a timestamp strictly less than `timeEnd`.
42
+ * If not provided, no end time filtering will be applied.
41
43
  */
42
- timeFilter?: TimeFilter;
44
+ timeEnd?: Date;
45
+
46
+ /**
47
+ * The message hashes to lookup.
48
+ * If provided, the query will be a message hash lookup query and will only return messages that match the specified hashes.
49
+ * If not provided or empty, the query will be a content filtered query based on the other filter parameters.
50
+ * @default undefined
51
+ */
52
+ messageHashes?: Uint8Array[];
53
+
54
+ /**
55
+ * The cursor to start the query from.
56
+ * The cursor represents the message hash of the last message returned in the previous query.
57
+ * The query will start from the message immediately following the cursor, excluding the message at the cursor itself.
58
+ * If not provided, the query will start from the beginning or end of the store, depending on the `paginationForward` option.
59
+ * @default undefined
60
+ */
61
+ paginationCursor?: Uint8Array;
62
+
63
+ /**
64
+ * The direction of pagination.
65
+ * - `true`: Forward pagination, starting from the oldest message and moving towards the newest.
66
+ * - `false`: Backward pagination, starting from the newest message and moving towards the oldest.
67
+ * @default false
68
+ */
69
+ paginationForward: boolean;
70
+
43
71
  /**
44
- * Cursor as an index to start a query from. Must be generated from a Waku
45
- * Message.
72
+ * The maximum number of messages to retrieve per page.
73
+ * If not provided, the store's default pagination limit will be used.
74
+ * @default undefined
46
75
  */
47
- cursor?: proto.Index;
76
+ paginationLimit?: number;
48
77
  };
49
78
 
50
79
  export type IStoreCore = IBaseProtocolCore;
51
80
 
52
81
  export type IStoreSDK = IBaseProtocolSDK & {
53
82
  protocol: IBaseProtocolCore;
54
- createCursor(message: IDecodedMessage): Cursor;
83
+ createCursor(message: IDecodedMessage): StoreCursor;
55
84
  queryGenerator: <T extends IDecodedMessage>(
56
85
  decoders: IDecoder<T>[],
57
- options?: StoreQueryOptions
86
+ options?: Partial<QueryRequestParams>
58
87
  ) => AsyncGenerator<Promise<T | undefined>[]>;
59
88
 
60
89
  queryWithOrderedCallback: <T extends IDecodedMessage>(
61
90
  decoders: IDecoder<T>[],
62
91
  callback: (message: T) => Promise<void | boolean> | boolean | void,
63
- options?: StoreQueryOptions
92
+ options?: Partial<QueryRequestParams>
64
93
  ) => Promise<void>;
65
94
  queryWithPromiseCallback: <T extends IDecodedMessage>(
66
95
  decoders: IDecoder<T>[],
67
96
  callback: (
68
97
  message: Promise<T | undefined>
69
98
  ) => Promise<void | boolean> | boolean | void,
70
- options?: StoreQueryOptions
99
+ options?: Partial<QueryRequestParams>
71
100
  ) => Promise<void>;
72
101
  };
package/src/waku.ts CHANGED
@@ -3,6 +3,7 @@ import type { MultiaddrInput } from "@multiformats/multiaddr";
3
3
 
4
4
  import { IConnectionManager } from "./connection_manager.js";
5
5
  import type { IFilterSDK } from "./filter.js";
6
+ import { IHealthManager } from "./health_manager.js";
6
7
  import type { Libp2p } from "./libp2p.js";
7
8
  import type { ILightPushSDK } from "./light_push.js";
8
9
  import { Protocols } from "./protocols.js";
@@ -27,6 +28,8 @@ export interface Waku {
27
28
  isStarted(): boolean;
28
29
 
29
30
  isConnected(): boolean;
31
+
32
+ health: IHealthManager;
30
33
  }
31
34
 
32
35
  export interface LightNode extends Waku {