mirror of https://github.com/waku-org/js-waku.git
Mark all proto fields as optional
As expected in proto version 3.
This commit is contained in:
parent
c4758a8737
commit
9e8d4b9bb1
|
@ -51,7 +51,7 @@ export class FilterRPC {
|
||||||
return this.proto.push;
|
return this.proto.push;
|
||||||
}
|
}
|
||||||
|
|
||||||
get requestId(): string {
|
get requestId(): string | undefined {
|
||||||
return this.proto.requestId;
|
return this.proto.requestId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,12 @@ export class WakuFilter {
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const requestId = request.requestId;
|
||||||
|
if (!requestId)
|
||||||
|
throw new Error(
|
||||||
|
"Internal error: createRequest expected to set `requestId`"
|
||||||
|
);
|
||||||
|
|
||||||
const peer = await this.getPeer(opts?.peerId);
|
const peer = await this.getPeer(opts?.peerId);
|
||||||
const stream = await this.newStream(peer);
|
const stream = await this.newStream(peer);
|
||||||
|
|
||||||
|
@ -90,11 +96,11 @@ export class WakuFilter {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addCallback(request.requestId, callback);
|
this.addCallback(requestId, callback);
|
||||||
|
|
||||||
return async () => {
|
return async () => {
|
||||||
await this.unsubscribe(topic, contentFilters, request.requestId, peer);
|
await this.unsubscribe(topic, contentFilters, requestId, peer);
|
||||||
this.removeCallback(request.requestId);
|
this.removeCallback(requestId);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +113,7 @@ export class WakuFilter {
|
||||||
async (source: AsyncIterable<Buffer>) => {
|
async (source: AsyncIterable<Buffer>) => {
|
||||||
for await (const bytes of source) {
|
for await (const bytes of source) {
|
||||||
const res = FilterRPC.decode(bytes.slice());
|
const res = FilterRPC.decode(bytes.slice());
|
||||||
if (res.push?.messages?.length) {
|
if (res.requestId && res.push?.messages?.length) {
|
||||||
await this.pushMessages(res.requestId, res.push.messages);
|
await this.pushMessages(res.requestId, res.push.messages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,7 @@ export class WakuStore {
|
||||||
const response = reply.response as protoV2Beta4.HistoryResponse;
|
const response = reply.response as protoV2Beta4.HistoryResponse;
|
||||||
|
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
throw "History response contains an Error" + response.error;
|
throw "History response contains an Error: " + response.error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!response.messages || !response.messages.length) {
|
if (!response.messages || !response.messages.length) {
|
||||||
|
|
|
@ -3,12 +3,12 @@ syntax = "proto3";
|
||||||
import "message.proto";
|
import "message.proto";
|
||||||
|
|
||||||
message FilterRequest {
|
message FilterRequest {
|
||||||
bool subscribe = 1;
|
optional bool subscribe = 1;
|
||||||
string topic = 2;
|
optional string topic = 2;
|
||||||
repeated ContentFilter content_filters = 3;
|
repeated ContentFilter content_filters = 3;
|
||||||
|
|
||||||
message ContentFilter {
|
message ContentFilter {
|
||||||
string content_topic = 1;
|
optional string content_topic = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ message MessagePush {
|
||||||
}
|
}
|
||||||
|
|
||||||
message FilterRPC {
|
message FilterRPC {
|
||||||
string request_id = 1;
|
optional string request_id = 1;
|
||||||
optional FilterRequest request = 2;
|
optional FilterRequest request = 2;
|
||||||
optional MessagePush push = 3;
|
optional MessagePush push = 3;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,20 +15,20 @@ import {
|
||||||
import type { Codec } from "protons-runtime";
|
import type { Codec } from "protons-runtime";
|
||||||
|
|
||||||
export interface FilterRequest {
|
export interface FilterRequest {
|
||||||
subscribe: boolean;
|
subscribe?: boolean;
|
||||||
topic: string;
|
topic?: string;
|
||||||
contentFilters: FilterRequest.ContentFilter[];
|
contentFilters: FilterRequest.ContentFilter[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace FilterRequest {
|
export namespace FilterRequest {
|
||||||
export interface ContentFilter {
|
export interface ContentFilter {
|
||||||
contentTopic: string;
|
contentTopic?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace ContentFilter {
|
export namespace ContentFilter {
|
||||||
export const codec = (): Codec<ContentFilter> => {
|
export const codec = (): Codec<ContentFilter> => {
|
||||||
return message<ContentFilter>({
|
return message<ContentFilter>({
|
||||||
1: { name: "contentTopic", codec: string },
|
1: { name: "contentTopic", codec: string, optional: true },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ export namespace FilterRequest {
|
||||||
|
|
||||||
export const codec = (): Codec<FilterRequest> => {
|
export const codec = (): Codec<FilterRequest> => {
|
||||||
return message<FilterRequest>({
|
return message<FilterRequest>({
|
||||||
1: { name: "subscribe", codec: bool },
|
1: { name: "subscribe", codec: bool, optional: true },
|
||||||
2: { name: "topic", codec: string },
|
2: { name: "topic", codec: string, optional: true },
|
||||||
3: {
|
3: {
|
||||||
name: "contentFilters",
|
name: "contentFilters",
|
||||||
codec: FilterRequest.ContentFilter.codec(),
|
codec: FilterRequest.ContentFilter.codec(),
|
||||||
|
@ -83,7 +83,7 @@ export namespace MessagePush {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FilterRPC {
|
export interface FilterRPC {
|
||||||
requestId: string;
|
requestId?: string;
|
||||||
request?: FilterRequest;
|
request?: FilterRequest;
|
||||||
push?: MessagePush;
|
push?: MessagePush;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ export interface FilterRPC {
|
||||||
export namespace FilterRPC {
|
export namespace FilterRPC {
|
||||||
export const codec = (): Codec<FilterRPC> => {
|
export const codec = (): Codec<FilterRPC> => {
|
||||||
return message<FilterRPC>({
|
return message<FilterRPC>({
|
||||||
1: { name: "requestId", codec: string },
|
1: { name: "requestId", codec: string, optional: true },
|
||||||
2: { name: "request", codec: FilterRequest.codec(), optional: true },
|
2: { name: "request", codec: FilterRequest.codec(), optional: true },
|
||||||
3: { name: "push", codec: MessagePush.codec(), optional: true },
|
3: { name: "push", codec: MessagePush.codec(), optional: true },
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,17 +3,17 @@ syntax = "proto3";
|
||||||
import "message.proto";
|
import "message.proto";
|
||||||
|
|
||||||
message PushRequest {
|
message PushRequest {
|
||||||
string pub_sub_topic = 1;
|
optional string pub_sub_topic = 1;
|
||||||
WakuMessage message = 2;
|
optional WakuMessage message = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PushResponse {
|
message PushResponse {
|
||||||
bool is_success = 1;
|
optional bool is_success = 1;
|
||||||
string info = 2;
|
optional string info = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PushRPC {
|
message PushRPC {
|
||||||
string request_id = 1;
|
optional string request_id = 1;
|
||||||
optional PushRequest request = 2;
|
optional PushRequest request = 2;
|
||||||
optional PushResponse response = 3;
|
optional PushResponse response = 3;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,15 +15,15 @@ import {
|
||||||
import type { Codec } from "protons-runtime";
|
import type { Codec } from "protons-runtime";
|
||||||
|
|
||||||
export interface PushRequest {
|
export interface PushRequest {
|
||||||
pubSubTopic: string;
|
pubSubTopic?: string;
|
||||||
message: WakuMessage;
|
message?: WakuMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace PushRequest {
|
export namespace PushRequest {
|
||||||
export const codec = (): Codec<PushRequest> => {
|
export const codec = (): Codec<PushRequest> => {
|
||||||
return message<PushRequest>({
|
return message<PushRequest>({
|
||||||
1: { name: "pubSubTopic", codec: string },
|
1: { name: "pubSubTopic", codec: string, optional: true },
|
||||||
2: { name: "message", codec: WakuMessage.codec() },
|
2: { name: "message", codec: WakuMessage.codec(), optional: true },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,15 +37,15 @@ export namespace PushRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PushResponse {
|
export interface PushResponse {
|
||||||
isSuccess: boolean;
|
isSuccess?: boolean;
|
||||||
info: string;
|
info?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace PushResponse {
|
export namespace PushResponse {
|
||||||
export const codec = (): Codec<PushResponse> => {
|
export const codec = (): Codec<PushResponse> => {
|
||||||
return message<PushResponse>({
|
return message<PushResponse>({
|
||||||
1: { name: "isSuccess", codec: bool },
|
1: { name: "isSuccess", codec: bool, optional: true },
|
||||||
2: { name: "info", codec: string },
|
2: { name: "info", codec: string, optional: true },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ export namespace PushResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PushRPC {
|
export interface PushRPC {
|
||||||
requestId: string;
|
requestId?: string;
|
||||||
request?: PushRequest;
|
request?: PushRequest;
|
||||||
response?: PushResponse;
|
response?: PushResponse;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ export interface PushRPC {
|
||||||
export namespace PushRPC {
|
export namespace PushRPC {
|
||||||
export const codec = (): Codec<PushRPC> => {
|
export const codec = (): Codec<PushRPC> => {
|
||||||
return message<PushRPC>({
|
return message<PushRPC>({
|
||||||
1: { name: "requestId", codec: string },
|
1: { name: "requestId", codec: string, optional: true },
|
||||||
2: { name: "request", codec: PushRequest.codec(), optional: true },
|
2: { name: "request", codec: PushRequest.codec(), optional: true },
|
||||||
3: { name: "response", codec: PushResponse.codec(), optional: true },
|
3: { name: "response", codec: PushResponse.codec(), optional: true },
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,23 +3,23 @@ syntax = "proto3";
|
||||||
import "message.proto";
|
import "message.proto";
|
||||||
|
|
||||||
message Index {
|
message Index {
|
||||||
bytes digest = 1;
|
optional bytes digest = 1;
|
||||||
double received_time = 2;
|
optional double received_time = 2;
|
||||||
double sender_time = 3;
|
optional double sender_time = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PagingInfo {
|
message PagingInfo {
|
||||||
uint64 page_size = 1;
|
optional uint64 page_size = 1;
|
||||||
Index cursor = 2;
|
optional Index cursor = 2;
|
||||||
enum Direction {
|
enum Direction {
|
||||||
DIRECTION_BACKWARD_UNSPECIFIED = 0;
|
DIRECTION_BACKWARD_UNSPECIFIED = 0;
|
||||||
DIRECTION_FORWARD = 1;
|
DIRECTION_FORWARD = 1;
|
||||||
}
|
}
|
||||||
Direction direction = 3;
|
optional Direction direction = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ContentFilter {
|
message ContentFilter {
|
||||||
string content_topic = 1;
|
optional string content_topic = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message HistoryQuery {
|
message HistoryQuery {
|
||||||
|
@ -32,16 +32,16 @@ message HistoryQuery {
|
||||||
|
|
||||||
message HistoryResponse {
|
message HistoryResponse {
|
||||||
repeated WakuMessage messages = 2;
|
repeated WakuMessage messages = 2;
|
||||||
PagingInfo paging_info = 3;
|
optional PagingInfo paging_info = 3;
|
||||||
enum Error {
|
enum Error {
|
||||||
ERROR_NONE_UNSPECIFIED = 0;
|
ERROR_NONE_UNSPECIFIED = 0;
|
||||||
ERROR_INVALID_CURSOR = 1;
|
ERROR_INVALID_CURSOR = 1;
|
||||||
}
|
}
|
||||||
Error error = 4;
|
optional Error error = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message HistoryRPC {
|
message HistoryRPC {
|
||||||
string request_id = 1;
|
optional string request_id = 1;
|
||||||
optional HistoryQuery query = 2;
|
optional HistoryQuery query = 2;
|
||||||
optional HistoryResponse response = 3;
|
optional HistoryResponse response = 3;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,17 +16,17 @@ import {
|
||||||
import type { Codec } from "protons-runtime";
|
import type { Codec } from "protons-runtime";
|
||||||
|
|
||||||
export interface Index {
|
export interface Index {
|
||||||
digest: Uint8Array;
|
digest?: Uint8Array;
|
||||||
receivedTime: number;
|
receivedTime?: number;
|
||||||
senderTime: number;
|
senderTime?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace Index {
|
export namespace Index {
|
||||||
export const codec = (): Codec<Index> => {
|
export const codec = (): Codec<Index> => {
|
||||||
return message<Index>({
|
return message<Index>({
|
||||||
1: { name: "digest", codec: bytes },
|
1: { name: "digest", codec: bytes, optional: true },
|
||||||
2: { name: "receivedTime", codec: double },
|
2: { name: "receivedTime", codec: double, optional: true },
|
||||||
3: { name: "senderTime", codec: double },
|
3: { name: "senderTime", codec: double, optional: true },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,9 +40,9 @@ export namespace Index {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PagingInfo {
|
export interface PagingInfo {
|
||||||
pageSize: bigint;
|
pageSize?: bigint;
|
||||||
cursor: Index;
|
cursor?: Index;
|
||||||
direction: PagingInfo.Direction;
|
direction?: PagingInfo.Direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace PagingInfo {
|
export namespace PagingInfo {
|
||||||
|
@ -64,9 +64,13 @@ export namespace PagingInfo {
|
||||||
|
|
||||||
export const codec = (): Codec<PagingInfo> => {
|
export const codec = (): Codec<PagingInfo> => {
|
||||||
return message<PagingInfo>({
|
return message<PagingInfo>({
|
||||||
1: { name: "pageSize", codec: uint64 },
|
1: { name: "pageSize", codec: uint64, optional: true },
|
||||||
2: { name: "cursor", codec: Index.codec() },
|
2: { name: "cursor", codec: Index.codec(), optional: true },
|
||||||
3: { name: "direction", codec: PagingInfo.Direction.codec() },
|
3: {
|
||||||
|
name: "direction",
|
||||||
|
codec: PagingInfo.Direction.codec(),
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -80,13 +84,13 @@ export namespace PagingInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ContentFilter {
|
export interface ContentFilter {
|
||||||
contentTopic: string;
|
contentTopic?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace ContentFilter {
|
export namespace ContentFilter {
|
||||||
export const codec = (): Codec<ContentFilter> => {
|
export const codec = (): Codec<ContentFilter> => {
|
||||||
return message<ContentFilter>({
|
return message<ContentFilter>({
|
||||||
1: { name: "contentTopic", codec: string },
|
1: { name: "contentTopic", codec: string, optional: true },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -133,8 +137,8 @@ export namespace HistoryQuery {
|
||||||
|
|
||||||
export interface HistoryResponse {
|
export interface HistoryResponse {
|
||||||
messages: WakuMessage[];
|
messages: WakuMessage[];
|
||||||
pagingInfo: PagingInfo;
|
pagingInfo?: PagingInfo;
|
||||||
error: HistoryResponse.Error;
|
error?: HistoryResponse.Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace HistoryResponse {
|
export namespace HistoryResponse {
|
||||||
|
@ -157,8 +161,12 @@ export namespace HistoryResponse {
|
||||||
export const codec = (): Codec<HistoryResponse> => {
|
export const codec = (): Codec<HistoryResponse> => {
|
||||||
return message<HistoryResponse>({
|
return message<HistoryResponse>({
|
||||||
2: { name: "messages", codec: WakuMessage.codec(), repeats: true },
|
2: { name: "messages", codec: WakuMessage.codec(), repeats: true },
|
||||||
3: { name: "pagingInfo", codec: PagingInfo.codec() },
|
3: { name: "pagingInfo", codec: PagingInfo.codec(), optional: true },
|
||||||
4: { name: "error", codec: HistoryResponse.Error.codec() },
|
4: {
|
||||||
|
name: "error",
|
||||||
|
codec: HistoryResponse.Error.codec(),
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -172,7 +180,7 @@ export namespace HistoryResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HistoryRPC {
|
export interface HistoryRPC {
|
||||||
requestId: string;
|
requestId?: string;
|
||||||
query?: HistoryQuery;
|
query?: HistoryQuery;
|
||||||
response?: HistoryResponse;
|
response?: HistoryResponse;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +188,7 @@ export interface HistoryRPC {
|
||||||
export namespace HistoryRPC {
|
export namespace HistoryRPC {
|
||||||
export const codec = (): Codec<HistoryRPC> => {
|
export const codec = (): Codec<HistoryRPC> => {
|
||||||
return message<HistoryRPC>({
|
return message<HistoryRPC>({
|
||||||
1: { name: "requestId", codec: string },
|
1: { name: "requestId", codec: string, optional: true },
|
||||||
2: { name: "query", codec: HistoryQuery.codec(), optional: true },
|
2: { name: "query", codec: HistoryQuery.codec(), optional: true },
|
||||||
3: { name: "response", codec: HistoryResponse.codec(), optional: true },
|
3: { name: "response", codec: HistoryResponse.codec(), optional: true },
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,24 +3,24 @@ syntax = "proto3";
|
||||||
import "message.proto";
|
import "message.proto";
|
||||||
|
|
||||||
message Index {
|
message Index {
|
||||||
bytes digest = 1;
|
optional bytes digest = 1;
|
||||||
sint64 received_time = 2;
|
optional sint64 received_time = 2;
|
||||||
sint64 sender_time = 3;
|
optional sint64 sender_time = 3;
|
||||||
string pubsub_topic = 4;
|
optional string pubsub_topic = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PagingInfo {
|
message PagingInfo {
|
||||||
uint64 page_size = 1;
|
optional uint64 page_size = 1;
|
||||||
Index cursor = 2;
|
optional Index cursor = 2;
|
||||||
enum Direction {
|
enum Direction {
|
||||||
DIRECTION_BACKWARD_UNSPECIFIED = 0;
|
DIRECTION_BACKWARD_UNSPECIFIED = 0;
|
||||||
DIRECTION_FORWARD = 1;
|
DIRECTION_FORWARD = 1;
|
||||||
}
|
}
|
||||||
Direction direction = 3;
|
optional Direction direction = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ContentFilter {
|
message ContentFilter {
|
||||||
string content_topic = 1;
|
optional string content_topic = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message HistoryQuery {
|
message HistoryQuery {
|
||||||
|
@ -33,16 +33,16 @@ message HistoryQuery {
|
||||||
|
|
||||||
message HistoryResponse {
|
message HistoryResponse {
|
||||||
repeated WakuMessage messages = 2;
|
repeated WakuMessage messages = 2;
|
||||||
PagingInfo paging_info = 3;
|
optional PagingInfo paging_info = 3;
|
||||||
enum Error {
|
enum Error {
|
||||||
ERROR_NONE_UNSPECIFIED = 0;
|
ERROR_NONE_UNSPECIFIED = 0;
|
||||||
ERROR_INVALID_CURSOR = 1;
|
ERROR_INVALID_CURSOR = 1;
|
||||||
}
|
}
|
||||||
Error error = 4;
|
optional Error error = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message HistoryRPC {
|
message HistoryRPC {
|
||||||
string request_id = 1;
|
optional string request_id = 1;
|
||||||
optional HistoryQuery query = 2;
|
optional HistoryQuery query = 2;
|
||||||
optional HistoryResponse response = 3;
|
optional HistoryResponse response = 3;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,19 +16,19 @@ import {
|
||||||
import type { Codec } from "protons-runtime";
|
import type { Codec } from "protons-runtime";
|
||||||
|
|
||||||
export interface Index {
|
export interface Index {
|
||||||
digest: Uint8Array;
|
digest?: Uint8Array;
|
||||||
receivedTime: bigint;
|
receivedTime?: bigint;
|
||||||
senderTime: bigint;
|
senderTime?: bigint;
|
||||||
pubsubTopic: string;
|
pubsubTopic?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace Index {
|
export namespace Index {
|
||||||
export const codec = (): Codec<Index> => {
|
export const codec = (): Codec<Index> => {
|
||||||
return message<Index>({
|
return message<Index>({
|
||||||
1: { name: "digest", codec: bytes },
|
1: { name: "digest", codec: bytes, optional: true },
|
||||||
2: { name: "receivedTime", codec: sint64 },
|
2: { name: "receivedTime", codec: sint64, optional: true },
|
||||||
3: { name: "senderTime", codec: sint64 },
|
3: { name: "senderTime", codec: sint64, optional: true },
|
||||||
4: { name: "pubsubTopic", codec: string },
|
4: { name: "pubsubTopic", codec: string, optional: true },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,9 +42,9 @@ export namespace Index {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PagingInfo {
|
export interface PagingInfo {
|
||||||
pageSize: bigint;
|
pageSize?: bigint;
|
||||||
cursor: Index;
|
cursor?: Index;
|
||||||
direction: PagingInfo.Direction;
|
direction?: PagingInfo.Direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace PagingInfo {
|
export namespace PagingInfo {
|
||||||
|
@ -66,9 +66,13 @@ export namespace PagingInfo {
|
||||||
|
|
||||||
export const codec = (): Codec<PagingInfo> => {
|
export const codec = (): Codec<PagingInfo> => {
|
||||||
return message<PagingInfo>({
|
return message<PagingInfo>({
|
||||||
1: { name: "pageSize", codec: uint64 },
|
1: { name: "pageSize", codec: uint64, optional: true },
|
||||||
2: { name: "cursor", codec: Index.codec() },
|
2: { name: "cursor", codec: Index.codec(), optional: true },
|
||||||
3: { name: "direction", codec: PagingInfo.Direction.codec() },
|
3: {
|
||||||
|
name: "direction",
|
||||||
|
codec: PagingInfo.Direction.codec(),
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -82,13 +86,13 @@ export namespace PagingInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ContentFilter {
|
export interface ContentFilter {
|
||||||
contentTopic: string;
|
contentTopic?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace ContentFilter {
|
export namespace ContentFilter {
|
||||||
export const codec = (): Codec<ContentFilter> => {
|
export const codec = (): Codec<ContentFilter> => {
|
||||||
return message<ContentFilter>({
|
return message<ContentFilter>({
|
||||||
1: { name: "contentTopic", codec: string },
|
1: { name: "contentTopic", codec: string, optional: true },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -135,8 +139,8 @@ export namespace HistoryQuery {
|
||||||
|
|
||||||
export interface HistoryResponse {
|
export interface HistoryResponse {
|
||||||
messages: WakuMessage[];
|
messages: WakuMessage[];
|
||||||
pagingInfo: PagingInfo;
|
pagingInfo?: PagingInfo;
|
||||||
error: HistoryResponse.Error;
|
error?: HistoryResponse.Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace HistoryResponse {
|
export namespace HistoryResponse {
|
||||||
|
@ -159,8 +163,12 @@ export namespace HistoryResponse {
|
||||||
export const codec = (): Codec<HistoryResponse> => {
|
export const codec = (): Codec<HistoryResponse> => {
|
||||||
return message<HistoryResponse>({
|
return message<HistoryResponse>({
|
||||||
2: { name: "messages", codec: WakuMessage.codec(), repeats: true },
|
2: { name: "messages", codec: WakuMessage.codec(), repeats: true },
|
||||||
3: { name: "pagingInfo", codec: PagingInfo.codec() },
|
3: { name: "pagingInfo", codec: PagingInfo.codec(), optional: true },
|
||||||
4: { name: "error", codec: HistoryResponse.Error.codec() },
|
4: {
|
||||||
|
name: "error",
|
||||||
|
codec: HistoryResponse.Error.codec(),
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -174,7 +182,7 @@ export namespace HistoryResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HistoryRPC {
|
export interface HistoryRPC {
|
||||||
requestId: string;
|
requestId?: string;
|
||||||
query?: HistoryQuery;
|
query?: HistoryQuery;
|
||||||
response?: HistoryResponse;
|
response?: HistoryResponse;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +190,7 @@ export interface HistoryRPC {
|
||||||
export namespace HistoryRPC {
|
export namespace HistoryRPC {
|
||||||
export const codec = (): Codec<HistoryRPC> => {
|
export const codec = (): Codec<HistoryRPC> => {
|
||||||
return message<HistoryRPC>({
|
return message<HistoryRPC>({
|
||||||
1: { name: "requestId", codec: string },
|
1: { name: "requestId", codec: string, optional: true },
|
||||||
2: { name: "query", codec: HistoryQuery.codec(), optional: true },
|
2: { name: "query", codec: HistoryQuery.codec(), optional: true },
|
||||||
3: { name: "response", codec: HistoryResponse.codec(), optional: true },
|
3: { name: "response", codec: HistoryResponse.codec(), optional: true },
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue