From 7894366e6399c4aee08963b9925440f6a6ba2675 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 31 Dec 2021 02:19:14 +0000 Subject: [PATCH 1/2] Bump ts-proto from 1.82.5 to 1.97.0 Bumps [ts-proto](https://github.com/stephenh/ts-proto) from 1.82.5 to 1.97.0. - [Release notes](https://github.com/stephenh/ts-proto/releases) - [Changelog](https://github.com/stephenh/ts-proto/blob/main/CHANGELOG.md) - [Commits](https://github.com/stephenh/ts-proto/compare/v1.82.5...v1.97.0) --- updated-dependencies: - dependency-name: ts-proto dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index db3ba9eaeb..f4d9aaf31e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16139,9 +16139,9 @@ } }, "node_modules/ts-proto": { - "version": "1.82.5", - "resolved": "https://registry.npmjs.org/ts-proto/-/ts-proto-1.82.5.tgz", - "integrity": "sha512-RqlTxosROuYdeWRLa6Qu8Wz9dc3fpAh+R8PELUlhSSZlUiEkTos662SgKHOB8UoJd9CBMSyJPRC7z8k2WvWzhw==", + "version": "1.97.0", + "resolved": "https://registry.npmjs.org/ts-proto/-/ts-proto-1.97.0.tgz", + "integrity": "sha512-GrECiLTy5POpIZehd7r8lsnrBz1QqG9Sfr3x4ytbz7YRjSjMZeBIG3LI2gW0KtIL1VrUTJic3wV61PR5i7AaQQ==", "dev": true, "dependencies": { "@types/object-hash": "^1.3.0", @@ -30092,9 +30092,9 @@ } }, "ts-proto": { - "version": "1.82.5", - "resolved": "https://registry.npmjs.org/ts-proto/-/ts-proto-1.82.5.tgz", - "integrity": "sha512-RqlTxosROuYdeWRLa6Qu8Wz9dc3fpAh+R8PELUlhSSZlUiEkTos662SgKHOB8UoJd9CBMSyJPRC7z8k2WvWzhw==", + "version": "1.97.0", + "resolved": "https://registry.npmjs.org/ts-proto/-/ts-proto-1.97.0.tgz", + "integrity": "sha512-GrECiLTy5POpIZehd7r8lsnrBz1QqG9Sfr3x4ytbz7YRjSjMZeBIG3LI2gW0KtIL1VrUTJic3wV61PR5i7AaQQ==", "dev": true, "requires": { "@types/object-hash": "^1.3.0", From fa3ab19176a1f1dc47a71786752ee60402441305 Mon Sep 17 00:00:00 2001 From: Franck Date: Mon, 3 Jan 2022 10:55:55 +1100 Subject: [PATCH 2/2] Generate proto files withts-protoa 1.97.0 --- src/proto/waku/v2/light_push.ts | 162 +++++++------ src/proto/waku/v2/message.ts | 89 ++++---- src/proto/waku/v2/store.ts | 391 ++++++++++++++------------------ 3 files changed, 296 insertions(+), 346 deletions(-) diff --git a/src/proto/waku/v2/light_push.ts b/src/proto/waku/v2/light_push.ts index bff84d2fca..dc545a0167 100644 --- a/src/proto/waku/v2/light_push.ts +++ b/src/proto/waku/v2/light_push.ts @@ -21,7 +21,9 @@ export interface PushRPC { response: PushResponse | undefined; } -const basePushRequest: object = { pubSubTopic: '' }; +function createBasePushRequest(): PushRequest { + return { pubSubTopic: '', message: undefined }; +} export const PushRequest = { encode( @@ -40,7 +42,7 @@ export const PushRequest = { decode(input: _m0.Reader | Uint8Array, length?: number): PushRequest { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...basePushRequest } as PushRequest; + const message = createBasePushRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -59,17 +61,15 @@ export const PushRequest = { }, fromJSON(object: any): PushRequest { - const message = { ...basePushRequest } as PushRequest; - if (object.pubSubTopic !== undefined && object.pubSubTopic !== null) { - message.pubSubTopic = String(object.pubSubTopic); - } else { - message.pubSubTopic = ''; - } - if (object.message !== undefined && object.message !== null) { - message.message = WakuMessage.fromJSON(object.message); - } else { - message.message = undefined; - } + const message = createBasePushRequest(); + message.pubSubTopic = + object.pubSubTopic !== undefined && object.pubSubTopic !== null + ? String(object.pubSubTopic) + : ''; + message.message = + object.message !== undefined && object.message !== null + ? WakuMessage.fromJSON(object.message) + : undefined; return message; }, @@ -84,23 +84,22 @@ export const PushRequest = { return obj; }, - fromPartial(object: DeepPartial): PushRequest { - const message = { ...basePushRequest } as PushRequest; - if (object.pubSubTopic !== undefined && object.pubSubTopic !== null) { - message.pubSubTopic = object.pubSubTopic; - } else { - message.pubSubTopic = ''; - } - if (object.message !== undefined && object.message !== null) { - message.message = WakuMessage.fromPartial(object.message); - } else { - message.message = undefined; - } + fromPartial, I>>( + object: I + ): PushRequest { + const message = createBasePushRequest(); + message.pubSubTopic = object.pubSubTopic ?? ''; + message.message = + object.message !== undefined && object.message !== null + ? WakuMessage.fromPartial(object.message) + : undefined; return message; }, }; -const basePushResponse: object = { isSuccess: false, info: '' }; +function createBasePushResponse(): PushResponse { + return { isSuccess: false, info: '' }; +} export const PushResponse = { encode( @@ -119,7 +118,7 @@ export const PushResponse = { decode(input: _m0.Reader | Uint8Array, length?: number): PushResponse { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...basePushResponse } as PushResponse; + const message = createBasePushResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -138,17 +137,15 @@ export const PushResponse = { }, fromJSON(object: any): PushResponse { - const message = { ...basePushResponse } as PushResponse; - if (object.isSuccess !== undefined && object.isSuccess !== null) { - message.isSuccess = Boolean(object.isSuccess); - } else { - message.isSuccess = false; - } - if (object.info !== undefined && object.info !== null) { - message.info = String(object.info); - } else { - message.info = ''; - } + const message = createBasePushResponse(); + message.isSuccess = + object.isSuccess !== undefined && object.isSuccess !== null + ? Boolean(object.isSuccess) + : false; + message.info = + object.info !== undefined && object.info !== null + ? String(object.info) + : ''; return message; }, @@ -159,23 +156,19 @@ export const PushResponse = { return obj; }, - fromPartial(object: DeepPartial): PushResponse { - const message = { ...basePushResponse } as PushResponse; - if (object.isSuccess !== undefined && object.isSuccess !== null) { - message.isSuccess = object.isSuccess; - } else { - message.isSuccess = false; - } - if (object.info !== undefined && object.info !== null) { - message.info = object.info; - } else { - message.info = ''; - } + fromPartial, I>>( + object: I + ): PushResponse { + const message = createBasePushResponse(); + message.isSuccess = object.isSuccess ?? false; + message.info = object.info ?? ''; return message; }, }; -const basePushRPC: object = { requestId: '' }; +function createBasePushRPC(): PushRPC { + return { requestId: '', request: undefined, response: undefined }; +} export const PushRPC = { encode( @@ -197,7 +190,7 @@ export const PushRPC = { decode(input: _m0.Reader | Uint8Array, length?: number): PushRPC { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...basePushRPC } as PushRPC; + const message = createBasePushRPC(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -219,22 +212,19 @@ export const PushRPC = { }, fromJSON(object: any): PushRPC { - const message = { ...basePushRPC } as PushRPC; - if (object.requestId !== undefined && object.requestId !== null) { - message.requestId = String(object.requestId); - } else { - message.requestId = ''; - } - if (object.request !== undefined && object.request !== null) { - message.request = PushRequest.fromJSON(object.request); - } else { - message.request = undefined; - } - if (object.response !== undefined && object.response !== null) { - message.response = PushResponse.fromJSON(object.response); - } else { - message.response = undefined; - } + const message = createBasePushRPC(); + message.requestId = + object.requestId !== undefined && object.requestId !== null + ? String(object.requestId) + : ''; + message.request = + object.request !== undefined && object.request !== null + ? PushRequest.fromJSON(object.request) + : undefined; + message.response = + object.response !== undefined && object.response !== null + ? PushResponse.fromJSON(object.response) + : undefined; return message; }, @@ -252,23 +242,17 @@ export const PushRPC = { return obj; }, - fromPartial(object: DeepPartial): PushRPC { - const message = { ...basePushRPC } as PushRPC; - if (object.requestId !== undefined && object.requestId !== null) { - message.requestId = object.requestId; - } else { - message.requestId = ''; - } - if (object.request !== undefined && object.request !== null) { - message.request = PushRequest.fromPartial(object.request); - } else { - message.request = undefined; - } - if (object.response !== undefined && object.response !== null) { - message.response = PushResponse.fromPartial(object.response); - } else { - message.response = undefined; - } + fromPartial, I>>(object: I): PushRPC { + const message = createBasePushRPC(); + message.requestId = object.requestId ?? ''; + message.request = + object.request !== undefined && object.request !== null + ? PushRequest.fromPartial(object.request) + : undefined; + message.response = + object.response !== undefined && object.response !== null + ? PushResponse.fromPartial(object.response) + : undefined; return message; }, }; @@ -281,6 +265,7 @@ type Builtin = | number | boolean | undefined; + export type DeepPartial = T extends Builtin ? T : T extends Array @@ -291,6 +276,13 @@ export type DeepPartial = T extends Builtin ? { [K in keyof T]?: DeepPartial } : Partial; +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin + ? P + : P & + { [K in keyof P]: Exact } & + Record>, never>; + if (_m0.util.Long !== Long) { _m0.util.Long = Long as any; _m0.configure(); diff --git a/src/proto/waku/v2/message.ts b/src/proto/waku/v2/message.ts index e15107d6ee..c6d6f684b2 100644 --- a/src/proto/waku/v2/message.ts +++ b/src/proto/waku/v2/message.ts @@ -11,7 +11,14 @@ export interface WakuMessage { timestamp?: number | undefined; } -const baseWakuMessage: object = {}; +function createBaseWakuMessage(): WakuMessage { + return { + payload: undefined, + contentTopic: undefined, + version: undefined, + timestamp: undefined, + }; +} export const WakuMessage = { encode( @@ -36,7 +43,7 @@ export const WakuMessage = { decode(input: _m0.Reader | Uint8Array, length?: number): WakuMessage { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseWakuMessage } as WakuMessage; + const message = createBaseWakuMessage(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -61,25 +68,23 @@ export const WakuMessage = { }, fromJSON(object: any): WakuMessage { - const message = { ...baseWakuMessage } as WakuMessage; - if (object.payload !== undefined && object.payload !== null) { - message.payload = bytesFromBase64(object.payload); - } - if (object.contentTopic !== undefined && object.contentTopic !== null) { - message.contentTopic = String(object.contentTopic); - } else { - message.contentTopic = undefined; - } - if (object.version !== undefined && object.version !== null) { - message.version = Number(object.version); - } else { - message.version = undefined; - } - if (object.timestamp !== undefined && object.timestamp !== null) { - message.timestamp = Number(object.timestamp); - } else { - message.timestamp = undefined; - } + const message = createBaseWakuMessage(); + message.payload = + object.payload !== undefined && object.payload !== null + ? bytesFromBase64(object.payload) + : undefined; + message.contentTopic = + object.contentTopic !== undefined && object.contentTopic !== null + ? String(object.contentTopic) + : undefined; + message.version = + object.version !== undefined && object.version !== null + ? Number(object.version) + : undefined; + message.timestamp = + object.timestamp !== undefined && object.timestamp !== null + ? Number(object.timestamp) + : undefined; return message; }, @@ -92,39 +97,27 @@ export const WakuMessage = { : undefined); message.contentTopic !== undefined && (obj.contentTopic = message.contentTopic); - message.version !== undefined && (obj.version = message.version); + message.version !== undefined && + (obj.version = Math.round(message.version)); message.timestamp !== undefined && (obj.timestamp = message.timestamp); return obj; }, - fromPartial(object: DeepPartial): WakuMessage { - const message = { ...baseWakuMessage } as WakuMessage; - if (object.payload !== undefined && object.payload !== null) { - message.payload = object.payload; - } else { - message.payload = undefined; - } - if (object.contentTopic !== undefined && object.contentTopic !== null) { - message.contentTopic = object.contentTopic; - } else { - message.contentTopic = undefined; - } - if (object.version !== undefined && object.version !== null) { - message.version = object.version; - } else { - message.version = undefined; - } - if (object.timestamp !== undefined && object.timestamp !== null) { - message.timestamp = object.timestamp; - } else { - message.timestamp = undefined; - } + fromPartial, I>>( + object: I + ): WakuMessage { + const message = createBaseWakuMessage(); + message.payload = object.payload ?? undefined; + message.contentTopic = object.contentTopic ?? undefined; + message.version = object.version ?? undefined; + message.timestamp = object.timestamp ?? undefined; return message; }, }; declare var self: any | undefined; declare var window: any | undefined; +declare var global: any | undefined; var globalThis: any = (() => { if (typeof globalThis !== 'undefined') return globalThis; if (typeof self !== 'undefined') return self; @@ -164,6 +157,7 @@ type Builtin = | number | boolean | undefined; + export type DeepPartial = T extends Builtin ? T : T extends Array @@ -174,6 +168,13 @@ export type DeepPartial = T extends Builtin ? { [K in keyof T]?: DeepPartial } : Partial; +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin + ? P + : P & + { [K in keyof P]: Exact } & + Record>, never>; + if (_m0.util.Long !== Long) { _m0.util.Long = Long as any; _m0.configure(); diff --git a/src/proto/waku/v2/store.ts b/src/proto/waku/v2/store.ts index 19bb9180a9..b501f02a03 100644 --- a/src/proto/waku/v2/store.ts +++ b/src/proto/waku/v2/store.ts @@ -113,7 +113,9 @@ export interface HistoryRPC { response: HistoryResponse | undefined; } -const baseIndex: object = { receivedTime: 0, senderTime: 0 }; +function createBaseIndex(): Index { + return { digest: new Uint8Array(), receivedTime: 0, senderTime: 0 }; +} export const Index = { encode(message: Index, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { @@ -132,8 +134,7 @@ export const Index = { decode(input: _m0.Reader | Uint8Array, length?: number): Index { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseIndex } as Index; - message.digest = new Uint8Array(); + const message = createBaseIndex(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -155,21 +156,19 @@ export const Index = { }, fromJSON(object: any): Index { - const message = { ...baseIndex } as Index; - message.digest = new Uint8Array(); - if (object.digest !== undefined && object.digest !== null) { - message.digest = bytesFromBase64(object.digest); - } - if (object.receivedTime !== undefined && object.receivedTime !== null) { - message.receivedTime = Number(object.receivedTime); - } else { - message.receivedTime = 0; - } - if (object.senderTime !== undefined && object.senderTime !== null) { - message.senderTime = Number(object.senderTime); - } else { - message.senderTime = 0; - } + const message = createBaseIndex(); + message.digest = + object.digest !== undefined && object.digest !== null + ? bytesFromBase64(object.digest) + : new Uint8Array(); + message.receivedTime = + object.receivedTime !== undefined && object.receivedTime !== null + ? Number(object.receivedTime) + : 0; + message.senderTime = + object.senderTime !== undefined && object.senderTime !== null + ? Number(object.senderTime) + : 0; return message; }, @@ -185,28 +184,18 @@ export const Index = { return obj; }, - fromPartial(object: DeepPartial): Index { - const message = { ...baseIndex } as Index; - if (object.digest !== undefined && object.digest !== null) { - message.digest = object.digest; - } else { - message.digest = new Uint8Array(); - } - if (object.receivedTime !== undefined && object.receivedTime !== null) { - message.receivedTime = object.receivedTime; - } else { - message.receivedTime = 0; - } - if (object.senderTime !== undefined && object.senderTime !== null) { - message.senderTime = object.senderTime; - } else { - message.senderTime = 0; - } + fromPartial, I>>(object: I): Index { + const message = createBaseIndex(); + message.digest = object.digest ?? new Uint8Array(); + message.receivedTime = object.receivedTime ?? 0; + message.senderTime = object.senderTime ?? 0; return message; }, }; -const basePagingInfo: object = { pageSize: 0, direction: 0 }; +function createBasePagingInfo(): PagingInfo { + return { pageSize: 0, cursor: undefined, direction: 0 }; +} export const PagingInfo = { encode( @@ -228,7 +217,7 @@ export const PagingInfo = { decode(input: _m0.Reader | Uint8Array, length?: number): PagingInfo { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...basePagingInfo } as PagingInfo; + const message = createBasePagingInfo(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -250,28 +239,26 @@ export const PagingInfo = { }, fromJSON(object: any): PagingInfo { - const message = { ...basePagingInfo } as PagingInfo; - if (object.pageSize !== undefined && object.pageSize !== null) { - message.pageSize = Number(object.pageSize); - } else { - message.pageSize = 0; - } - if (object.cursor !== undefined && object.cursor !== null) { - message.cursor = Index.fromJSON(object.cursor); - } else { - message.cursor = undefined; - } - if (object.direction !== undefined && object.direction !== null) { - message.direction = pagingInfo_DirectionFromJSON(object.direction); - } else { - message.direction = 0; - } + const message = createBasePagingInfo(); + message.pageSize = + object.pageSize !== undefined && object.pageSize !== null + ? Number(object.pageSize) + : 0; + message.cursor = + object.cursor !== undefined && object.cursor !== null + ? Index.fromJSON(object.cursor) + : undefined; + message.direction = + object.direction !== undefined && object.direction !== null + ? pagingInfo_DirectionFromJSON(object.direction) + : 0; return message; }, toJSON(message: PagingInfo): unknown { const obj: any = {}; - message.pageSize !== undefined && (obj.pageSize = message.pageSize); + message.pageSize !== undefined && + (obj.pageSize = Math.round(message.pageSize)); message.cursor !== undefined && (obj.cursor = message.cursor ? Index.toJSON(message.cursor) : undefined); message.direction !== undefined && @@ -279,28 +266,23 @@ export const PagingInfo = { return obj; }, - fromPartial(object: DeepPartial): PagingInfo { - const message = { ...basePagingInfo } as PagingInfo; - if (object.pageSize !== undefined && object.pageSize !== null) { - message.pageSize = object.pageSize; - } else { - message.pageSize = 0; - } - if (object.cursor !== undefined && object.cursor !== null) { - message.cursor = Index.fromPartial(object.cursor); - } else { - message.cursor = undefined; - } - if (object.direction !== undefined && object.direction !== null) { - message.direction = object.direction; - } else { - message.direction = 0; - } + fromPartial, I>>( + object: I + ): PagingInfo { + const message = createBasePagingInfo(); + message.pageSize = object.pageSize ?? 0; + message.cursor = + object.cursor !== undefined && object.cursor !== null + ? Index.fromPartial(object.cursor) + : undefined; + message.direction = object.direction ?? 0; return message; }, }; -const baseContentFilter: object = { contentTopic: '' }; +function createBaseContentFilter(): ContentFilter { + return { contentTopic: '' }; +} export const ContentFilter = { encode( @@ -316,7 +298,7 @@ export const ContentFilter = { decode(input: _m0.Reader | Uint8Array, length?: number): ContentFilter { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseContentFilter } as ContentFilter; + const message = createBaseContentFilter(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -332,12 +314,11 @@ export const ContentFilter = { }, fromJSON(object: any): ContentFilter { - const message = { ...baseContentFilter } as ContentFilter; - if (object.contentTopic !== undefined && object.contentTopic !== null) { - message.contentTopic = String(object.contentTopic); - } else { - message.contentTopic = ''; - } + const message = createBaseContentFilter(); + message.contentTopic = + object.contentTopic !== undefined && object.contentTopic !== null + ? String(object.contentTopic) + : ''; return message; }, @@ -348,18 +329,24 @@ export const ContentFilter = { return obj; }, - fromPartial(object: DeepPartial): ContentFilter { - const message = { ...baseContentFilter } as ContentFilter; - if (object.contentTopic !== undefined && object.contentTopic !== null) { - message.contentTopic = object.contentTopic; - } else { - message.contentTopic = ''; - } + fromPartial, I>>( + object: I + ): ContentFilter { + const message = createBaseContentFilter(); + message.contentTopic = object.contentTopic ?? ''; return message; }, }; -const baseHistoryQuery: object = {}; +function createBaseHistoryQuery(): HistoryQuery { + return { + pubSubTopic: undefined, + contentFilters: [], + pagingInfo: undefined, + startTime: undefined, + endTime: undefined, + }; +} export const HistoryQuery = { encode( @@ -387,8 +374,7 @@ export const HistoryQuery = { decode(input: _m0.Reader | Uint8Array, length?: number): HistoryQuery { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseHistoryQuery } as HistoryQuery; - message.contentFilters = []; + const message = createBaseHistoryQuery(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -418,33 +404,26 @@ export const HistoryQuery = { }, fromJSON(object: any): HistoryQuery { - const message = { ...baseHistoryQuery } as HistoryQuery; - message.contentFilters = []; - if (object.pubSubTopic !== undefined && object.pubSubTopic !== null) { - message.pubSubTopic = String(object.pubSubTopic); - } else { - message.pubSubTopic = undefined; - } - if (object.contentFilters !== undefined && object.contentFilters !== null) { - for (const e of object.contentFilters) { - message.contentFilters.push(ContentFilter.fromJSON(e)); - } - } - if (object.pagingInfo !== undefined && object.pagingInfo !== null) { - message.pagingInfo = PagingInfo.fromJSON(object.pagingInfo); - } else { - message.pagingInfo = undefined; - } - if (object.startTime !== undefined && object.startTime !== null) { - message.startTime = Number(object.startTime); - } else { - message.startTime = undefined; - } - if (object.endTime !== undefined && object.endTime !== null) { - message.endTime = Number(object.endTime); - } else { - message.endTime = undefined; - } + const message = createBaseHistoryQuery(); + message.pubSubTopic = + object.pubSubTopic !== undefined && object.pubSubTopic !== null + ? String(object.pubSubTopic) + : undefined; + message.contentFilters = (object.contentFilters ?? []).map((e: any) => + ContentFilter.fromJSON(e) + ); + message.pagingInfo = + object.pagingInfo !== undefined && object.pagingInfo !== null + ? PagingInfo.fromJSON(object.pagingInfo) + : undefined; + message.startTime = + object.startTime !== undefined && object.startTime !== null + ? Number(object.startTime) + : undefined; + message.endTime = + object.endTime !== undefined && object.endTime !== null + ? Number(object.endTime) + : undefined; return message; }, @@ -468,39 +447,26 @@ export const HistoryQuery = { return obj; }, - fromPartial(object: DeepPartial): HistoryQuery { - const message = { ...baseHistoryQuery } as HistoryQuery; - message.contentFilters = []; - if (object.pubSubTopic !== undefined && object.pubSubTopic !== null) { - message.pubSubTopic = object.pubSubTopic; - } else { - message.pubSubTopic = undefined; - } - if (object.contentFilters !== undefined && object.contentFilters !== null) { - for (const e of object.contentFilters) { - message.contentFilters.push(ContentFilter.fromPartial(e)); - } - } - if (object.pagingInfo !== undefined && object.pagingInfo !== null) { - message.pagingInfo = PagingInfo.fromPartial(object.pagingInfo); - } else { - message.pagingInfo = undefined; - } - if (object.startTime !== undefined && object.startTime !== null) { - message.startTime = object.startTime; - } else { - message.startTime = undefined; - } - if (object.endTime !== undefined && object.endTime !== null) { - message.endTime = object.endTime; - } else { - message.endTime = undefined; - } + fromPartial, I>>( + object: I + ): HistoryQuery { + const message = createBaseHistoryQuery(); + message.pubSubTopic = object.pubSubTopic ?? undefined; + message.contentFilters = + object.contentFilters?.map((e) => ContentFilter.fromPartial(e)) || []; + message.pagingInfo = + object.pagingInfo !== undefined && object.pagingInfo !== null + ? PagingInfo.fromPartial(object.pagingInfo) + : undefined; + message.startTime = object.startTime ?? undefined; + message.endTime = object.endTime ?? undefined; return message; }, }; -const baseHistoryResponse: object = { error: 0 }; +function createBaseHistoryResponse(): HistoryResponse { + return { messages: [], pagingInfo: undefined, error: 0 }; +} export const HistoryResponse = { encode( @@ -522,8 +488,7 @@ export const HistoryResponse = { decode(input: _m0.Reader | Uint8Array, length?: number): HistoryResponse { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseHistoryResponse } as HistoryResponse; - message.messages = []; + const message = createBaseHistoryResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -545,23 +510,18 @@ export const HistoryResponse = { }, fromJSON(object: any): HistoryResponse { - const message = { ...baseHistoryResponse } as HistoryResponse; - message.messages = []; - if (object.messages !== undefined && object.messages !== null) { - for (const e of object.messages) { - message.messages.push(WakuMessage.fromJSON(e)); - } - } - if (object.pagingInfo !== undefined && object.pagingInfo !== null) { - message.pagingInfo = PagingInfo.fromJSON(object.pagingInfo); - } else { - message.pagingInfo = undefined; - } - if (object.error !== undefined && object.error !== null) { - message.error = historyResponse_ErrorFromJSON(object.error); - } else { - message.error = 0; - } + const message = createBaseHistoryResponse(); + message.messages = (object.messages ?? []).map((e: any) => + WakuMessage.fromJSON(e) + ); + message.pagingInfo = + object.pagingInfo !== undefined && object.pagingInfo !== null + ? PagingInfo.fromJSON(object.pagingInfo) + : undefined; + message.error = + object.error !== undefined && object.error !== null + ? historyResponse_ErrorFromJSON(object.error) + : 0; return message; }, @@ -583,29 +543,24 @@ export const HistoryResponse = { return obj; }, - fromPartial(object: DeepPartial): HistoryResponse { - const message = { ...baseHistoryResponse } as HistoryResponse; - message.messages = []; - if (object.messages !== undefined && object.messages !== null) { - for (const e of object.messages) { - message.messages.push(WakuMessage.fromPartial(e)); - } - } - if (object.pagingInfo !== undefined && object.pagingInfo !== null) { - message.pagingInfo = PagingInfo.fromPartial(object.pagingInfo); - } else { - message.pagingInfo = undefined; - } - if (object.error !== undefined && object.error !== null) { - message.error = object.error; - } else { - message.error = 0; - } + fromPartial, I>>( + object: I + ): HistoryResponse { + const message = createBaseHistoryResponse(); + message.messages = + object.messages?.map((e) => WakuMessage.fromPartial(e)) || []; + message.pagingInfo = + object.pagingInfo !== undefined && object.pagingInfo !== null + ? PagingInfo.fromPartial(object.pagingInfo) + : undefined; + message.error = object.error ?? 0; return message; }, }; -const baseHistoryRPC: object = { requestId: '' }; +function createBaseHistoryRPC(): HistoryRPC { + return { requestId: '', query: undefined, response: undefined }; +} export const HistoryRPC = { encode( @@ -630,7 +585,7 @@ export const HistoryRPC = { decode(input: _m0.Reader | Uint8Array, length?: number): HistoryRPC { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseHistoryRPC } as HistoryRPC; + const message = createBaseHistoryRPC(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -652,22 +607,19 @@ export const HistoryRPC = { }, fromJSON(object: any): HistoryRPC { - const message = { ...baseHistoryRPC } as HistoryRPC; - if (object.requestId !== undefined && object.requestId !== null) { - message.requestId = String(object.requestId); - } else { - message.requestId = ''; - } - if (object.query !== undefined && object.query !== null) { - message.query = HistoryQuery.fromJSON(object.query); - } else { - message.query = undefined; - } - if (object.response !== undefined && object.response !== null) { - message.response = HistoryResponse.fromJSON(object.response); - } else { - message.response = undefined; - } + const message = createBaseHistoryRPC(); + message.requestId = + object.requestId !== undefined && object.requestId !== null + ? String(object.requestId) + : ''; + message.query = + object.query !== undefined && object.query !== null + ? HistoryQuery.fromJSON(object.query) + : undefined; + message.response = + object.response !== undefined && object.response !== null + ? HistoryResponse.fromJSON(object.response) + : undefined; return message; }, @@ -685,29 +637,26 @@ export const HistoryRPC = { return obj; }, - fromPartial(object: DeepPartial): HistoryRPC { - const message = { ...baseHistoryRPC } as HistoryRPC; - if (object.requestId !== undefined && object.requestId !== null) { - message.requestId = object.requestId; - } else { - message.requestId = ''; - } - if (object.query !== undefined && object.query !== null) { - message.query = HistoryQuery.fromPartial(object.query); - } else { - message.query = undefined; - } - if (object.response !== undefined && object.response !== null) { - message.response = HistoryResponse.fromPartial(object.response); - } else { - message.response = undefined; - } + fromPartial, I>>( + object: I + ): HistoryRPC { + const message = createBaseHistoryRPC(); + message.requestId = object.requestId ?? ''; + message.query = + object.query !== undefined && object.query !== null + ? HistoryQuery.fromPartial(object.query) + : undefined; + message.response = + object.response !== undefined && object.response !== null + ? HistoryResponse.fromPartial(object.response) + : undefined; return message; }, }; declare var self: any | undefined; declare var window: any | undefined; +declare var global: any | undefined; var globalThis: any = (() => { if (typeof globalThis !== 'undefined') return globalThis; if (typeof self !== 'undefined') return self; @@ -747,6 +696,7 @@ type Builtin = | number | boolean | undefined; + export type DeepPartial = T extends Builtin ? T : T extends Array @@ -757,6 +707,13 @@ export type DeepPartial = T extends Builtin ? { [K in keyof T]?: DeepPartial } : Partial; +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin + ? P + : P & + { [K in keyof P]: Exact } & + Record>, never>; + function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER');