From 5957cbf80f94c8e15165ec2a6d75d88dfc8c20a8 Mon Sep 17 00:00:00 2001 From: Zetazzz Date: Thu, 16 Nov 2023 16:27:49 +0800 Subject: [PATCH] add isSDK and isAmino --- .../akash/deployment/v1beta1/authz.ts | 43 +- .../cosmos/authz/v1beta1/authz.ts | 249 ++- .../cosmos/bank/v1beta1/authz.ts | 53 +- .../cosmos/base/v1beta1/coin.ts | 176 ++ .../cosmos_proto/cosmos.ts | 129 ++ .../google/protobuf/any.ts | 225 ++ .../google/protobuf/descriptor.ts | 1962 ++++++++++++++++- .../google/protobuf/timestamp.ts | 194 +- .../__snapshots__/misc.overall.test.ts.snap | 12 + packages/ast/src/encoding/object.ts | 6 +- packages/ast/src/encoding/proto/is/index.ts | 18 +- .../ast/types/encoding/proto/is/index.d.ts | 4 + packages/ast/types/utils/utils.d.ts | 2 + .../__tests__/impl-interfaces.test.ts | 4 +- 14 files changed, 3027 insertions(+), 50 deletions(-) diff --git a/__fixtures__/misc/output-impl-interfaces-gen/akash/deployment/v1beta1/authz.ts b/__fixtures__/misc/output-impl-interfaces-gen/akash/deployment/v1beta1/authz.ts index 2e337d4aa..b83b09842 100644 --- a/__fixtures__/misc/output-impl-interfaces-gen/akash/deployment/v1beta1/authz.ts +++ b/__fixtures__/misc/output-impl-interfaces-gen/akash/deployment/v1beta1/authz.ts @@ -1,4 +1,4 @@ -import { Coin } from "../../../cosmos/base/v1beta1/coin"; +import { Coin, CoinAmino, CoinSDKType } from "../../../cosmos/base/v1beta1/coin"; import { BinaryReader, BinaryWriter } from "../../../binary"; import { isSet, DeepPartial } from "../../../helpers"; import { GlobalDecoderRegistry } from "../../../registry"; @@ -18,6 +18,28 @@ export interface DepositDeploymentAuthorizationProtoMsg { typeUrl: "/akash.deployment.v1beta1.DepositDeploymentAuthorization"; value: Uint8Array; } +/** + * DepositDeploymentAuthorization allows the grantee to deposit up to spend_limit coins from + * the granter's account for a deployment. + */ +export interface DepositDeploymentAuthorizationAmino { + /** + * SpendLimit is the amount the grantee is authorized to spend from the granter's account for + * the purpose of deployment. + */ + spend_limit?: CoinAmino; +} +export interface DepositDeploymentAuthorizationAminoMsg { + type: "/akash.deployment.v1beta1.DepositDeploymentAuthorization"; + value: DepositDeploymentAuthorizationAmino; +} +/** + * DepositDeploymentAuthorization allows the grantee to deposit up to spend_limit coins from + * the granter's account for a deployment. + */ +export interface DepositDeploymentAuthorizationSDKType { + spend_limit: CoinSDKType; +} function createBaseDepositDeploymentAuthorization(): DepositDeploymentAuthorization { return { spendLimit: Coin.fromPartial({}) @@ -28,6 +50,12 @@ export const DepositDeploymentAuthorization = { is(o: any): o is DepositDeploymentAuthorization { return o && (o.$typeUrl === DepositDeploymentAuthorization.typeUrl || Coin.is(o.spendLimit)); }, + isSDK(o: any): o is DepositDeploymentAuthorization { + return o && (o.$typeUrl === DepositDeploymentAuthorization.typeUrl || Coin.isSDK(o.spend_limit)); + }, + isAmino(o: any): o is DepositDeploymentAuthorization { + return o && (o.$typeUrl === DepositDeploymentAuthorization.typeUrl || Coin.isAmino(o.spend_limit)); + }, encode(message: DepositDeploymentAuthorization, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.spendLimit !== undefined) { Coin.encode(message.spendLimit, writer.uint32(10).fork()).ldelim(); @@ -68,6 +96,19 @@ export const DepositDeploymentAuthorization = { } return message; }, + fromAmino(object: DepositDeploymentAuthorizationAmino): DepositDeploymentAuthorization { + return { + spendLimit: object?.spend_limit ? Coin.fromAmino(object.spend_limit) : undefined + }; + }, + toAmino(message: DepositDeploymentAuthorization): DepositDeploymentAuthorizationAmino { + const obj: any = {}; + obj.spend_limit = message.spendLimit ? Coin.toAmino(message.spendLimit) : undefined; + return obj; + }, + fromAminoMsg(object: DepositDeploymentAuthorizationAminoMsg): DepositDeploymentAuthorization { + return DepositDeploymentAuthorization.fromAmino(object.value); + }, fromProtoMsg(message: DepositDeploymentAuthorizationProtoMsg): DepositDeploymentAuthorization { return DepositDeploymentAuthorization.decode(message.value); }, diff --git a/__fixtures__/misc/output-impl-interfaces-gen/cosmos/authz/v1beta1/authz.ts b/__fixtures__/misc/output-impl-interfaces-gen/cosmos/authz/v1beta1/authz.ts index 75c2c22e5..ab59757b1 100644 --- a/__fixtures__/misc/output-impl-interfaces-gen/cosmos/authz/v1beta1/authz.ts +++ b/__fixtures__/misc/output-impl-interfaces-gen/cosmos/authz/v1beta1/authz.ts @@ -1,7 +1,7 @@ -import { Any } from "../../../google/protobuf/any"; -import { Timestamp } from "../../../google/protobuf/timestamp"; -import { DepositDeploymentAuthorization } from "../../../akash/deployment/v1beta1/authz"; -import { SendAuthorization } from "../../bank/v1beta1/authz"; +import { Any, AnyProtoMsg, AnyAmino, AnySDKType } from "../../../google/protobuf/any"; +import { Timestamp, TimestampAmino, TimestampSDKType } from "../../../google/protobuf/timestamp"; +import { DepositDeploymentAuthorization, DepositDeploymentAuthorizationProtoMsg, DepositDeploymentAuthorizationSDKType } from "../../../akash/deployment/v1beta1/authz"; +import { SendAuthorization, SendAuthorizationProtoMsg, SendAuthorizationSDKType } from "../../bank/v1beta1/authz"; import { BinaryReader, BinaryWriter } from "../../../binary"; import { isSet, DeepPartial, toTimestamp, fromTimestamp } from "../../../helpers"; import { GlobalDecoderRegistry } from "../../../registry"; @@ -18,6 +18,25 @@ export interface GenericAuthorizationProtoMsg { typeUrl: "/cosmos.authz.v1beta1.GenericAuthorization"; value: Uint8Array; } +/** + * GenericAuthorization gives the grantee unrestricted permissions to execute + * the provided method on behalf of the granter's account. + */ +export interface GenericAuthorizationAmino { + /** Msg, identified by it's type URL, to grant unrestricted permissions to execute */ + msg: string; +} +export interface GenericAuthorizationAminoMsg { + type: "cosmos-sdk/GenericAuthorization"; + value: GenericAuthorizationAmino; +} +/** + * GenericAuthorization gives the grantee unrestricted permissions to execute + * the provided method on behalf of the granter's account. + */ +export interface GenericAuthorizationSDKType { + msg: string; +} /** * Grant gives permissions to execute * the provide method with expiration time. @@ -35,6 +54,34 @@ export interface GrantProtoMsg { typeUrl: "/cosmos.authz.v1beta1.Grant"; value: Uint8Array; } +export type GrantEncoded = Omit & { + authorization?: GenericAuthorizationProtoMsg | DepositDeploymentAuthorizationProtoMsg | SendAuthorizationProtoMsg | AnyProtoMsg | undefined; +}; +/** + * Grant gives permissions to execute + * the provide method with expiration time. + */ +export interface GrantAmino { + authorization?: AnyAmino; + /** + * time when the grant will expire and will be pruned. If null, then the grant + * doesn't have a time expiration (other conditions in `authorization` + * may apply to invalidate the grant) + */ + expiration?: string; +} +export interface GrantAminoMsg { + type: "cosmos-sdk/Grant"; + value: GrantAmino; +} +/** + * Grant gives permissions to execute + * the provide method with expiration time. + */ +export interface GrantSDKType { + authorization: GenericAuthorizationSDKType | DepositDeploymentAuthorizationSDKType | SendAuthorizationSDKType | AnySDKType | undefined; + expiration?: Date; +} /** * GrantAuthorization extends a grant with both the addresses of the grantee and granter. * It is used in genesis.proto and query.proto @@ -49,6 +96,33 @@ export interface GrantAuthorizationProtoMsg { typeUrl: "/cosmos.authz.v1beta1.GrantAuthorization"; value: Uint8Array; } +export type GrantAuthorizationEncoded = Omit & { + authorization?: GenericAuthorizationProtoMsg | DepositDeploymentAuthorizationProtoMsg | SendAuthorizationProtoMsg | AnyProtoMsg | undefined; +}; +/** + * GrantAuthorization extends a grant with both the addresses of the grantee and granter. + * It is used in genesis.proto and query.proto + */ +export interface GrantAuthorizationAmino { + granter: string; + grantee: string; + authorization?: AnyAmino; + expiration?: string; +} +export interface GrantAuthorizationAminoMsg { + type: "cosmos-sdk/GrantAuthorization"; + value: GrantAuthorizationAmino; +} +/** + * GrantAuthorization extends a grant with both the addresses of the grantee and granter. + * It is used in genesis.proto and query.proto + */ +export interface GrantAuthorizationSDKType { + granter: string; + grantee: string; + authorization?: GenericAuthorizationSDKType | DepositDeploymentAuthorizationSDKType | SendAuthorizationSDKType | AnySDKType | undefined; + expiration?: Date; +} /** GrantQueueItem contains the list of TypeURL of a sdk.Msg. */ export interface GrantQueueItem { /** msg_type_urls contains the list of TypeURL of a sdk.Msg. */ @@ -58,6 +132,19 @@ export interface GrantQueueItemProtoMsg { typeUrl: "/cosmos.authz.v1beta1.GrantQueueItem"; value: Uint8Array; } +/** GrantQueueItem contains the list of TypeURL of a sdk.Msg. */ +export interface GrantQueueItemAmino { + /** msg_type_urls contains the list of TypeURL of a sdk.Msg. */ + msg_type_urls: string[]; +} +export interface GrantQueueItemAminoMsg { + type: "cosmos-sdk/GrantQueueItem"; + value: GrantQueueItemAmino; +} +/** GrantQueueItem contains the list of TypeURL of a sdk.Msg. */ +export interface GrantQueueItemSDKType { + msg_type_urls: string[]; +} function createBaseGenericAuthorization(): GenericAuthorization { return { msg: "" @@ -68,6 +155,12 @@ export const GenericAuthorization = { is(o: any): o is GenericAuthorization { return o && (o.$typeUrl === GenericAuthorization.typeUrl || typeof o.msg === "string"); }, + isSDK(o: any): o is GenericAuthorization { + return o && (o.$typeUrl === GenericAuthorization.typeUrl || typeof o.msg === "string"); + }, + isAmino(o: any): o is GenericAuthorization { + return o && (o.$typeUrl === GenericAuthorization.typeUrl || typeof o.msg === "string"); + }, encode(message: GenericAuthorization, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.msg !== "") { writer.uint32(10).string(message.msg); @@ -106,6 +199,25 @@ export const GenericAuthorization = { message.msg = object.msg ?? ""; return message; }, + fromAmino(object: GenericAuthorizationAmino): GenericAuthorization { + return { + msg: object.msg + }; + }, + toAmino(message: GenericAuthorization): GenericAuthorizationAmino { + const obj: any = {}; + obj.msg = message.msg; + return obj; + }, + fromAminoMsg(object: GenericAuthorizationAminoMsg): GenericAuthorization { + return GenericAuthorization.fromAmino(object.value); + }, + toAminoMsg(message: GenericAuthorization): GenericAuthorizationAminoMsg { + return { + type: "cosmos-sdk/GenericAuthorization", + value: GenericAuthorization.toAmino(message) + }; + }, fromProtoMsg(message: GenericAuthorizationProtoMsg): GenericAuthorization { return GenericAuthorization.decode(message.value); }, @@ -131,6 +243,12 @@ export const Grant = { is(o: any): o is Grant { return o && (o.$typeUrl === Grant.typeUrl || GenericAuthorization.is(o.authorization) || DepositDeploymentAuthorization.is(o.authorization) || SendAuthorization.is(o.authorization) || Any.is(o.authorization)); }, + isSDK(o: any): o is Grant { + return o && (o.$typeUrl === Grant.typeUrl || GenericAuthorization.isSDK(o.authorization) || DepositDeploymentAuthorization.isSDK(o.authorization) || SendAuthorization.isSDK(o.authorization) || Any.isSDK(o.authorization)); + }, + isAmino(o: any): o is Grant { + return o && (o.$typeUrl === Grant.typeUrl || GenericAuthorization.isAmino(o.authorization) || DepositDeploymentAuthorization.isAmino(o.authorization) || SendAuthorization.isAmino(o.authorization) || Any.isAmino(o.authorization)); + }, encode(message: Grant, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.authorization !== undefined) { Any.encode((message.authorization as Any), writer.uint32(10).fork()).ldelim(); @@ -180,6 +298,27 @@ export const Grant = { message.expiration = object.expiration ?? undefined; return message; }, + fromAmino(object: GrantAmino): Grant { + return { + authorization: object?.authorization ? Authorization_FromAmino(object.authorization) : undefined, + expiration: object?.expiration ? fromTimestamp(Timestamp.fromAmino(object.expiration)) : undefined + }; + }, + toAmino(message: Grant): GrantAmino { + const obj: any = {}; + obj.authorization = message.authorization ? Authorization_ToAmino((message.authorization as Any)) : undefined; + obj.expiration = message.expiration ? Timestamp.toAmino(toTimestamp(message.expiration)) : undefined; + return obj; + }, + fromAminoMsg(object: GrantAminoMsg): Grant { + return Grant.fromAmino(object.value); + }, + toAminoMsg(message: Grant): GrantAminoMsg { + return { + type: "cosmos-sdk/Grant", + value: Grant.toAmino(message) + }; + }, fromProtoMsg(message: GrantProtoMsg): Grant { return Grant.decode(message.value); }, @@ -207,6 +346,12 @@ export const GrantAuthorization = { is(o: any): o is GrantAuthorization { return o && (o.$typeUrl === GrantAuthorization.typeUrl || typeof o.granter === "string" && typeof o.grantee === "string"); }, + isSDK(o: any): o is GrantAuthorization { + return o && (o.$typeUrl === GrantAuthorization.typeUrl || typeof o.granter === "string" && typeof o.grantee === "string"); + }, + isAmino(o: any): o is GrantAuthorization { + return o && (o.$typeUrl === GrantAuthorization.typeUrl || typeof o.granter === "string" && typeof o.grantee === "string"); + }, encode(message: GrantAuthorization, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.granter !== "") { writer.uint32(10).string(message.granter); @@ -274,6 +419,31 @@ export const GrantAuthorization = { message.expiration = object.expiration ?? undefined; return message; }, + fromAmino(object: GrantAuthorizationAmino): GrantAuthorization { + return { + granter: object.granter, + grantee: object.grantee, + authorization: object?.authorization ? Authorization_FromAmino(object.authorization) : undefined, + expiration: object?.expiration ? fromTimestamp(Timestamp.fromAmino(object.expiration)) : undefined + }; + }, + toAmino(message: GrantAuthorization): GrantAuthorizationAmino { + const obj: any = {}; + obj.granter = message.granter; + obj.grantee = message.grantee; + obj.authorization = message.authorization ? Authorization_ToAmino((message.authorization as Any)) : undefined; + obj.expiration = message.expiration ? Timestamp.toAmino(toTimestamp(message.expiration)) : undefined; + return obj; + }, + fromAminoMsg(object: GrantAuthorizationAminoMsg): GrantAuthorization { + return GrantAuthorization.fromAmino(object.value); + }, + toAminoMsg(message: GrantAuthorization): GrantAuthorizationAminoMsg { + return { + type: "cosmos-sdk/GrantAuthorization", + value: GrantAuthorization.toAmino(message) + }; + }, fromProtoMsg(message: GrantAuthorizationProtoMsg): GrantAuthorization { return GrantAuthorization.decode(message.value); }, @@ -298,6 +468,12 @@ export const GrantQueueItem = { is(o: any): o is GrantQueueItem { return o && (o.$typeUrl === GrantQueueItem.typeUrl || Array.isArray(o.msgTypeUrls) && (!o.msgTypeUrls.length || typeof o.msgTypeUrls[0] === "string")); }, + isSDK(o: any): o is GrantQueueItem { + return o && (o.$typeUrl === GrantQueueItem.typeUrl || Array.isArray(o.msg_type_urls) && (!o.msg_type_urls.length || typeof o.msg_type_urls[0] === "string")); + }, + isAmino(o: any): o is GrantQueueItem { + return o && (o.$typeUrl === GrantQueueItem.typeUrl || Array.isArray(o.msg_type_urls) && (!o.msg_type_urls.length || typeof o.msg_type_urls[0] === "string")); + }, encode(message: GrantQueueItem, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { for (const v of message.msgTypeUrls) { writer.uint32(10).string(v!); @@ -340,6 +516,29 @@ export const GrantQueueItem = { message.msgTypeUrls = object.msgTypeUrls?.map(e => e) || []; return message; }, + fromAmino(object: GrantQueueItemAmino): GrantQueueItem { + return { + msgTypeUrls: Array.isArray(object?.msg_type_urls) ? object.msg_type_urls.map((e: any) => e) : [] + }; + }, + toAmino(message: GrantQueueItem): GrantQueueItemAmino { + const obj: any = {}; + if (message.msgTypeUrls) { + obj.msg_type_urls = message.msgTypeUrls.map(e => e); + } else { + obj.msg_type_urls = []; + } + return obj; + }, + fromAminoMsg(object: GrantQueueItemAminoMsg): GrantQueueItem { + return GrantQueueItem.fromAmino(object.value); + }, + toAminoMsg(message: GrantQueueItem): GrantQueueItemAminoMsg { + return { + type: "cosmos-sdk/GrantQueueItem", + value: GrantQueueItem.toAmino(message) + }; + }, fromProtoMsg(message: GrantQueueItemProtoMsg): GrantQueueItem { return GrantQueueItem.decode(message.value); }, @@ -367,4 +566,46 @@ export const Authorization_InterfaceDecoder = (input: BinaryReader | Uint8Array) default: return data; } +}; +export const Authorization_FromAmino = (content: AnyAmino) => { + switch (content.type) { + case "/akash.deployment.v1beta1.DepositDeploymentAuthorization": + return Any.fromPartial({ + typeUrl: "/akash.deployment.v1beta1.DepositDeploymentAuthorization", + value: DepositDeploymentAuthorization.encode(DepositDeploymentAuthorization.fromPartial(DepositDeploymentAuthorization.fromAmino(content.value))).finish() + }); + case "cosmos-sdk/GenericAuthorization": + return Any.fromPartial({ + typeUrl: "/cosmos.authz.v1beta1.GenericAuthorization", + value: GenericAuthorization.encode(GenericAuthorization.fromPartial(GenericAuthorization.fromAmino(content.value))).finish() + }); + case "cosmos-sdk/SendAuthorization": + return Any.fromPartial({ + typeUrl: "/cosmos.bank.v1beta1.SendAuthorization", + value: SendAuthorization.encode(SendAuthorization.fromPartial(SendAuthorization.fromAmino(content.value))).finish() + }); + default: + return Any.fromAmino(content); + } +}; +export const Authorization_ToAmino = (content: Any) => { + switch (content.typeUrl) { + case "/akash.deployment.v1beta1.DepositDeploymentAuthorization": + return { + type: "/akash.deployment.v1beta1.DepositDeploymentAuthorization", + value: DepositDeploymentAuthorization.toAmino(DepositDeploymentAuthorization.decode(content.value, undefined)) + }; + case "/cosmos.authz.v1beta1.GenericAuthorization": + return { + type: "cosmos-sdk/GenericAuthorization", + value: GenericAuthorization.toAmino(GenericAuthorization.decode(content.value, undefined)) + }; + case "/cosmos.bank.v1beta1.SendAuthorization": + return { + type: "cosmos-sdk/SendAuthorization", + value: SendAuthorization.toAmino(SendAuthorization.decode(content.value, undefined)) + }; + default: + return Any.toAmino(content); + } }; \ No newline at end of file diff --git a/__fixtures__/misc/output-impl-interfaces-gen/cosmos/bank/v1beta1/authz.ts b/__fixtures__/misc/output-impl-interfaces-gen/cosmos/bank/v1beta1/authz.ts index 638018c0d..b98dccb66 100644 --- a/__fixtures__/misc/output-impl-interfaces-gen/cosmos/bank/v1beta1/authz.ts +++ b/__fixtures__/misc/output-impl-interfaces-gen/cosmos/bank/v1beta1/authz.ts @@ -1,4 +1,4 @@ -import { Coin } from "../../base/v1beta1/coin"; +import { Coin, CoinAmino, CoinSDKType } from "../../base/v1beta1/coin"; import { BinaryReader, BinaryWriter } from "../../../binary"; import { DeepPartial } from "../../../helpers"; import { GlobalDecoderRegistry } from "../../../registry"; @@ -16,6 +16,28 @@ export interface SendAuthorizationProtoMsg { typeUrl: "/cosmos.bank.v1beta1.SendAuthorization"; value: Uint8Array; } +/** + * SendAuthorization allows the grantee to spend up to spend_limit coins from + * the granter's account. + * + * Since: cosmos-sdk 0.43 + */ +export interface SendAuthorizationAmino { + spend_limit: CoinAmino[]; +} +export interface SendAuthorizationAminoMsg { + type: "cosmos-sdk/SendAuthorization"; + value: SendAuthorizationAmino; +} +/** + * SendAuthorization allows the grantee to spend up to spend_limit coins from + * the granter's account. + * + * Since: cosmos-sdk 0.43 + */ +export interface SendAuthorizationSDKType { + spend_limit: CoinSDKType[]; +} function createBaseSendAuthorization(): SendAuthorization { return { spendLimit: [] @@ -26,6 +48,12 @@ export const SendAuthorization = { is(o: any): o is SendAuthorization { return o && (o.$typeUrl === SendAuthorization.typeUrl || Array.isArray(o.spendLimit) && (!o.spendLimit.length || Coin.is(o.spendLimit[0]))); }, + isSDK(o: any): o is SendAuthorization { + return o && (o.$typeUrl === SendAuthorization.typeUrl || Array.isArray(o.spend_limit) && (!o.spend_limit.length || Coin.isSDK(o.spend_limit[0]))); + }, + isAmino(o: any): o is SendAuthorization { + return o && (o.$typeUrl === SendAuthorization.typeUrl || Array.isArray(o.spend_limit) && (!o.spend_limit.length || Coin.isAmino(o.spend_limit[0]))); + }, encode(message: SendAuthorization, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { for (const v of message.spendLimit) { Coin.encode(v!, writer.uint32(10).fork()).ldelim(); @@ -68,6 +96,29 @@ export const SendAuthorization = { message.spendLimit = object.spendLimit?.map(e => Coin.fromPartial(e)) || []; return message; }, + fromAmino(object: SendAuthorizationAmino): SendAuthorization { + return { + spendLimit: Array.isArray(object?.spend_limit) ? object.spend_limit.map((e: any) => Coin.fromAmino(e)) : [] + }; + }, + toAmino(message: SendAuthorization): SendAuthorizationAmino { + const obj: any = {}; + if (message.spendLimit) { + obj.spend_limit = message.spendLimit.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.spend_limit = []; + } + return obj; + }, + fromAminoMsg(object: SendAuthorizationAminoMsg): SendAuthorization { + return SendAuthorization.fromAmino(object.value); + }, + toAminoMsg(message: SendAuthorization): SendAuthorizationAminoMsg { + return { + type: "cosmos-sdk/SendAuthorization", + value: SendAuthorization.toAmino(message) + }; + }, fromProtoMsg(message: SendAuthorizationProtoMsg): SendAuthorization { return SendAuthorization.decode(message.value); }, diff --git a/__fixtures__/misc/output-impl-interfaces-gen/cosmos/base/v1beta1/coin.ts b/__fixtures__/misc/output-impl-interfaces-gen/cosmos/base/v1beta1/coin.ts index 572a4d3cf..75f452cda 100644 --- a/__fixtures__/misc/output-impl-interfaces-gen/cosmos/base/v1beta1/coin.ts +++ b/__fixtures__/misc/output-impl-interfaces-gen/cosmos/base/v1beta1/coin.ts @@ -16,6 +16,30 @@ export interface CoinProtoMsg { typeUrl: "/cosmos.base.v1beta1.Coin"; value: Uint8Array; } +/** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ +export interface CoinAmino { + denom: string; + amount: string; +} +export interface CoinAminoMsg { + type: "cosmos-sdk/Coin"; + value: CoinAmino; +} +/** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ +export interface CoinSDKType { + denom: string; + amount: string; +} /** * DecCoin defines a token with a denomination and a decimal amount. * @@ -30,6 +54,30 @@ export interface DecCoinProtoMsg { typeUrl: "/cosmos.base.v1beta1.DecCoin"; value: Uint8Array; } +/** + * DecCoin defines a token with a denomination and a decimal amount. + * + * NOTE: The amount field is an Dec which implements the custom method + * signatures required by gogoproto. + */ +export interface DecCoinAmino { + denom: string; + amount: string; +} +export interface DecCoinAminoMsg { + type: "cosmos-sdk/DecCoin"; + value: DecCoinAmino; +} +/** + * DecCoin defines a token with a denomination and a decimal amount. + * + * NOTE: The amount field is an Dec which implements the custom method + * signatures required by gogoproto. + */ +export interface DecCoinSDKType { + denom: string; + amount: string; +} /** IntProto defines a Protobuf wrapper around an Int object. */ export interface IntProto { int: string; @@ -38,6 +86,18 @@ export interface IntProtoProtoMsg { typeUrl: "/cosmos.base.v1beta1.IntProto"; value: Uint8Array; } +/** IntProto defines a Protobuf wrapper around an Int object. */ +export interface IntProtoAmino { + int: string; +} +export interface IntProtoAminoMsg { + type: "cosmos-sdk/IntProto"; + value: IntProtoAmino; +} +/** IntProto defines a Protobuf wrapper around an Int object. */ +export interface IntProtoSDKType { + int: string; +} /** DecProto defines a Protobuf wrapper around a Dec object. */ export interface DecProto { dec: string; @@ -46,6 +106,18 @@ export interface DecProtoProtoMsg { typeUrl: "/cosmos.base.v1beta1.DecProto"; value: Uint8Array; } +/** DecProto defines a Protobuf wrapper around a Dec object. */ +export interface DecProtoAmino { + dec: string; +} +export interface DecProtoAminoMsg { + type: "cosmos-sdk/DecProto"; + value: DecProtoAmino; +} +/** DecProto defines a Protobuf wrapper around a Dec object. */ +export interface DecProtoSDKType { + dec: string; +} function createBaseCoin(): Coin { return { denom: "", @@ -57,6 +129,12 @@ export const Coin = { is(o: any): o is Coin { return o && (o.$typeUrl === Coin.typeUrl || typeof o.denom === "string" && typeof o.amount === "string"); }, + isSDK(o: any): o is Coin { + return o && (o.$typeUrl === Coin.typeUrl || typeof o.denom === "string" && typeof o.amount === "string"); + }, + isAmino(o: any): o is Coin { + return o && (o.$typeUrl === Coin.typeUrl || typeof o.denom === "string" && typeof o.amount === "string"); + }, encode(message: Coin, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.denom !== "") { writer.uint32(10).string(message.denom); @@ -104,6 +182,27 @@ export const Coin = { message.amount = object.amount ?? ""; return message; }, + fromAmino(object: CoinAmino): Coin { + return { + denom: object.denom, + amount: object.amount + }; + }, + toAmino(message: Coin): CoinAmino { + const obj: any = {}; + obj.denom = message.denom; + obj.amount = message.amount; + return obj; + }, + fromAminoMsg(object: CoinAminoMsg): Coin { + return Coin.fromAmino(object.value); + }, + toAminoMsg(message: Coin): CoinAminoMsg { + return { + type: "cosmos-sdk/Coin", + value: Coin.toAmino(message) + }; + }, fromProtoMsg(message: CoinProtoMsg): Coin { return Coin.decode(message.value); }, @@ -129,6 +228,12 @@ export const DecCoin = { is(o: any): o is DecCoin { return o && (o.$typeUrl === DecCoin.typeUrl || typeof o.denom === "string" && typeof o.amount === "string"); }, + isSDK(o: any): o is DecCoin { + return o && (o.$typeUrl === DecCoin.typeUrl || typeof o.denom === "string" && typeof o.amount === "string"); + }, + isAmino(o: any): o is DecCoin { + return o && (o.$typeUrl === DecCoin.typeUrl || typeof o.denom === "string" && typeof o.amount === "string"); + }, encode(message: DecCoin, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.denom !== "") { writer.uint32(10).string(message.denom); @@ -176,6 +281,27 @@ export const DecCoin = { message.amount = object.amount ?? ""; return message; }, + fromAmino(object: DecCoinAmino): DecCoin { + return { + denom: object.denom, + amount: object.amount + }; + }, + toAmino(message: DecCoin): DecCoinAmino { + const obj: any = {}; + obj.denom = message.denom; + obj.amount = message.amount; + return obj; + }, + fromAminoMsg(object: DecCoinAminoMsg): DecCoin { + return DecCoin.fromAmino(object.value); + }, + toAminoMsg(message: DecCoin): DecCoinAminoMsg { + return { + type: "cosmos-sdk/DecCoin", + value: DecCoin.toAmino(message) + }; + }, fromProtoMsg(message: DecCoinProtoMsg): DecCoin { return DecCoin.decode(message.value); }, @@ -200,6 +326,12 @@ export const IntProto = { is(o: any): o is IntProto { return o && (o.$typeUrl === IntProto.typeUrl || typeof o.int === "string"); }, + isSDK(o: any): o is IntProto { + return o && (o.$typeUrl === IntProto.typeUrl || typeof o.int === "string"); + }, + isAmino(o: any): o is IntProto { + return o && (o.$typeUrl === IntProto.typeUrl || typeof o.int === "string"); + }, encode(message: IntProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.int !== "") { writer.uint32(10).string(message.int); @@ -238,6 +370,25 @@ export const IntProto = { message.int = object.int ?? ""; return message; }, + fromAmino(object: IntProtoAmino): IntProto { + return { + int: object.int + }; + }, + toAmino(message: IntProto): IntProtoAmino { + const obj: any = {}; + obj.int = message.int; + return obj; + }, + fromAminoMsg(object: IntProtoAminoMsg): IntProto { + return IntProto.fromAmino(object.value); + }, + toAminoMsg(message: IntProto): IntProtoAminoMsg { + return { + type: "cosmos-sdk/IntProto", + value: IntProto.toAmino(message) + }; + }, fromProtoMsg(message: IntProtoProtoMsg): IntProto { return IntProto.decode(message.value); }, @@ -262,6 +413,12 @@ export const DecProto = { is(o: any): o is DecProto { return o && (o.$typeUrl === DecProto.typeUrl || typeof o.dec === "string"); }, + isSDK(o: any): o is DecProto { + return o && (o.$typeUrl === DecProto.typeUrl || typeof o.dec === "string"); + }, + isAmino(o: any): o is DecProto { + return o && (o.$typeUrl === DecProto.typeUrl || typeof o.dec === "string"); + }, encode(message: DecProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.dec !== "") { writer.uint32(10).string(message.dec); @@ -300,6 +457,25 @@ export const DecProto = { message.dec = object.dec ?? ""; return message; }, + fromAmino(object: DecProtoAmino): DecProto { + return { + dec: object.dec + }; + }, + toAmino(message: DecProto): DecProtoAmino { + const obj: any = {}; + obj.dec = message.dec; + return obj; + }, + fromAminoMsg(object: DecProtoAminoMsg): DecProto { + return DecProto.fromAmino(object.value); + }, + toAminoMsg(message: DecProto): DecProtoAminoMsg { + return { + type: "cosmos-sdk/DecProto", + value: DecProto.toAmino(message) + }; + }, fromProtoMsg(message: DecProtoProtoMsg): DecProto { return DecProto.decode(message.value); }, diff --git a/__fixtures__/misc/output-impl-interfaces-gen/cosmos_proto/cosmos.ts b/__fixtures__/misc/output-impl-interfaces-gen/cosmos_proto/cosmos.ts index c1ce6d216..da2b0e0c0 100644 --- a/__fixtures__/misc/output-impl-interfaces-gen/cosmos_proto/cosmos.ts +++ b/__fixtures__/misc/output-impl-interfaces-gen/cosmos_proto/cosmos.ts @@ -8,6 +8,8 @@ export enum ScalarType { SCALAR_TYPE_BYTES = 2, UNRECOGNIZED = -1, } +export const ScalarTypeSDKType = ScalarType; +export const ScalarTypeAmino = ScalarType; export function scalarTypeFromJSON(object: any): ScalarType { switch (object) { case 0: @@ -60,6 +62,36 @@ export interface InterfaceDescriptorProtoMsg { typeUrl: "/cosmos_proto.InterfaceDescriptor"; value: Uint8Array; } +/** + * InterfaceDescriptor describes an interface type to be used with + * accepts_interface and implements_interface and declared by declare_interface. + */ +export interface InterfaceDescriptorAmino { + /** + * name is the name of the interface. It should be a short-name (without + * a period) such that the fully qualified name of the interface will be + * package.name, ex. for the package a.b and interface named C, the + * fully-qualified name will be a.b.C. + */ + name: string; + /** + * description is a human-readable description of the interface and its + * purpose. + */ + description: string; +} +export interface InterfaceDescriptorAminoMsg { + type: "/cosmos_proto.InterfaceDescriptor"; + value: InterfaceDescriptorAmino; +} +/** + * InterfaceDescriptor describes an interface type to be used with + * accepts_interface and implements_interface and declared by declare_interface. + */ +export interface InterfaceDescriptorSDKType { + name: string; + description: string; +} /** * ScalarDescriptor describes an scalar type to be used with * the scalar field option and declared by declare_scalar. @@ -95,6 +127,55 @@ export interface ScalarDescriptorProtoMsg { typeUrl: "/cosmos_proto.ScalarDescriptor"; value: Uint8Array; } +/** + * ScalarDescriptor describes an scalar type to be used with + * the scalar field option and declared by declare_scalar. + * Scalars extend simple protobuf built-in types with additional + * syntax and semantics, for instance to represent big integers. + * Scalars should ideally define an encoding such that there is only one + * valid syntactical representation for a given semantic meaning, + * i.e. the encoding should be deterministic. + */ +export interface ScalarDescriptorAmino { + /** + * name is the name of the scalar. It should be a short-name (without + * a period) such that the fully qualified name of the scalar will be + * package.name, ex. for the package a.b and scalar named C, the + * fully-qualified name will be a.b.C. + */ + name: string; + /** + * description is a human-readable description of the scalar and its + * encoding format. For instance a big integer or decimal scalar should + * specify precisely the expected encoding format. + */ + description: string; + /** + * field_type is the type of field with which this scalar can be used. + * Scalars can be used with one and only one type of field so that + * encoding standards and simple and clear. Currently only string and + * bytes fields are supported for scalars. + */ + field_type: ScalarType[]; +} +export interface ScalarDescriptorAminoMsg { + type: "/cosmos_proto.ScalarDescriptor"; + value: ScalarDescriptorAmino; +} +/** + * ScalarDescriptor describes an scalar type to be used with + * the scalar field option and declared by declare_scalar. + * Scalars extend simple protobuf built-in types with additional + * syntax and semantics, for instance to represent big integers. + * Scalars should ideally define an encoding such that there is only one + * valid syntactical representation for a given semantic meaning, + * i.e. the encoding should be deterministic. + */ +export interface ScalarDescriptorSDKType { + name: string; + description: string; + field_type: ScalarType[]; +} function createBaseInterfaceDescriptor(): InterfaceDescriptor { return { name: "", @@ -106,6 +187,12 @@ export const InterfaceDescriptor = { is(o: any): o is InterfaceDescriptor { return o && (o.$typeUrl === InterfaceDescriptor.typeUrl || typeof o.name === "string" && typeof o.description === "string"); }, + isSDK(o: any): o is InterfaceDescriptor { + return o && (o.$typeUrl === InterfaceDescriptor.typeUrl || typeof o.name === "string" && typeof o.description === "string"); + }, + isAmino(o: any): o is InterfaceDescriptor { + return o && (o.$typeUrl === InterfaceDescriptor.typeUrl || typeof o.name === "string" && typeof o.description === "string"); + }, encode(message: InterfaceDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.name !== "") { writer.uint32(10).string(message.name); @@ -153,6 +240,21 @@ export const InterfaceDescriptor = { message.description = object.description ?? ""; return message; }, + fromAmino(object: InterfaceDescriptorAmino): InterfaceDescriptor { + return { + name: object.name, + description: object.description + }; + }, + toAmino(message: InterfaceDescriptor): InterfaceDescriptorAmino { + const obj: any = {}; + obj.name = message.name; + obj.description = message.description; + return obj; + }, + fromAminoMsg(object: InterfaceDescriptorAminoMsg): InterfaceDescriptor { + return InterfaceDescriptor.fromAmino(object.value); + }, fromProtoMsg(message: InterfaceDescriptorProtoMsg): InterfaceDescriptor { return InterfaceDescriptor.decode(message.value); }, @@ -179,6 +281,12 @@ export const ScalarDescriptor = { is(o: any): o is ScalarDescriptor { return o && (o.$typeUrl === ScalarDescriptor.typeUrl || typeof o.name === "string" && typeof o.description === "string" && Array.isArray(o.fieldType)); }, + isSDK(o: any): o is ScalarDescriptor { + return o && (o.$typeUrl === ScalarDescriptor.typeUrl || typeof o.name === "string" && typeof o.description === "string" && Array.isArray(o.field_type)); + }, + isAmino(o: any): o is ScalarDescriptor { + return o && (o.$typeUrl === ScalarDescriptor.typeUrl || typeof o.name === "string" && typeof o.description === "string" && Array.isArray(o.field_type)); + }, encode(message: ScalarDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.name !== "") { writer.uint32(10).string(message.name); @@ -248,6 +356,27 @@ export const ScalarDescriptor = { message.fieldType = object.fieldType?.map(e => e) || []; return message; }, + fromAmino(object: ScalarDescriptorAmino): ScalarDescriptor { + return { + name: object.name, + description: object.description, + fieldType: Array.isArray(object?.field_type) ? object.field_type.map((e: any) => scalarTypeFromJSON(e)) : [] + }; + }, + toAmino(message: ScalarDescriptor): ScalarDescriptorAmino { + const obj: any = {}; + obj.name = message.name; + obj.description = message.description; + if (message.fieldType) { + obj.field_type = message.fieldType.map(e => scalarTypeToJSON(e)); + } else { + obj.field_type = []; + } + return obj; + }, + fromAminoMsg(object: ScalarDescriptorAminoMsg): ScalarDescriptor { + return ScalarDescriptor.fromAmino(object.value); + }, fromProtoMsg(message: ScalarDescriptorProtoMsg): ScalarDescriptor { return ScalarDescriptor.decode(message.value); }, diff --git a/__fixtures__/misc/output-impl-interfaces-gen/google/protobuf/any.ts b/__fixtures__/misc/output-impl-interfaces-gen/google/protobuf/any.ts index 98193f15d..7620273a6 100644 --- a/__fixtures__/misc/output-impl-interfaces-gen/google/protobuf/any.ts +++ b/__fixtures__/misc/output-impl-interfaces-gen/google/protobuf/any.ts @@ -121,6 +121,210 @@ export interface AnyProtoMsg { typeUrl: "/google.protobuf.Any"; value: Uint8Array; } +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := ptypes.MarshalAny(foo) + * ... + * foo := &pb.Foo{} + * if err := ptypes.UnmarshalAny(any, foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface AnyAmino { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + type: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: any; +} +export interface AnyAminoMsg { + type: string; + value: AnyAmino; +} +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := ptypes.MarshalAny(foo) + * ... + * foo := &pb.Foo{} + * if err := ptypes.UnmarshalAny(any, foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface AnySDKType { + type_url: string; + value: Uint8Array; +} function createBaseAny(): Any { return { typeUrl: "", @@ -132,6 +336,12 @@ export const Any = { is(o: any): o is Any { return o && (o.$typeUrl === Any.typeUrl || typeof o.typeUrl === "string" && o.value instanceof Uint8Array); }, + isSDK(o: any): o is Any { + return o && (o.$typeUrl === Any.typeUrl || typeof o.type_url === "string" && o.value instanceof Uint8Array); + }, + isAmino(o: any): o is Any { + return o && (o.$typeUrl === Any.typeUrl || typeof o.type === "string" && o.value instanceof Uint8Array); + }, encode(message: Any, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.typeUrl !== "") { writer.uint32(10).string(message.typeUrl); @@ -179,6 +389,21 @@ export const Any = { message.value = object.value ?? new Uint8Array(); return message; }, + fromAmino(object: AnyAmino): Any { + return { + typeUrl: object.type, + value: object.value + }; + }, + toAmino(message: Any): AnyAmino { + const obj: any = {}; + obj.type = message.typeUrl; + obj.value = message.value; + return obj; + }, + fromAminoMsg(object: AnyAminoMsg): Any { + return Any.fromAmino(object.value); + }, fromProtoMsg(message: AnyProtoMsg): Any { return Any.decode(message.value); }, diff --git a/__fixtures__/misc/output-impl-interfaces-gen/google/protobuf/descriptor.ts b/__fixtures__/misc/output-impl-interfaces-gen/google/protobuf/descriptor.ts index 412fed6fe..a2abc7895 100644 --- a/__fixtures__/misc/output-impl-interfaces-gen/google/protobuf/descriptor.ts +++ b/__fixtures__/misc/output-impl-interfaces-gen/google/protobuf/descriptor.ts @@ -44,6 +44,8 @@ export enum FieldDescriptorProto_Type { TYPE_SINT64 = 18, UNRECOGNIZED = -1, } +export const FieldDescriptorProto_TypeSDKType = FieldDescriptorProto_Type; +export const FieldDescriptorProto_TypeAmino = FieldDescriptorProto_Type; export function fieldDescriptorProto_TypeFromJSON(object: any): FieldDescriptorProto_Type { switch (object) { case 1: @@ -156,6 +158,8 @@ export enum FieldDescriptorProto_Label { LABEL_REPEATED = 3, UNRECOGNIZED = -1, } +export const FieldDescriptorProto_LabelSDKType = FieldDescriptorProto_Label; +export const FieldDescriptorProto_LabelAmino = FieldDescriptorProto_Label; export function fieldDescriptorProto_LabelFromJSON(object: any): FieldDescriptorProto_Label { switch (object) { case 1: @@ -199,6 +203,8 @@ export enum FileOptions_OptimizeMode { LITE_RUNTIME = 3, UNRECOGNIZED = -1, } +export const FileOptions_OptimizeModeSDKType = FileOptions_OptimizeMode; +export const FileOptions_OptimizeModeAmino = FileOptions_OptimizeMode; export function fileOptions_OptimizeModeFromJSON(object: any): FileOptions_OptimizeMode { switch (object) { case 1: @@ -236,6 +242,8 @@ export enum FieldOptions_CType { STRING_PIECE = 2, UNRECOGNIZED = -1, } +export const FieldOptions_CTypeSDKType = FieldOptions_CType; +export const FieldOptions_CTypeAmino = FieldOptions_CType; export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { switch (object) { case 0: @@ -275,6 +283,8 @@ export enum FieldOptions_JSType { JS_NUMBER = 2, UNRECOGNIZED = -1, } +export const FieldOptions_JSTypeSDKType = FieldOptions_JSType; +export const FieldOptions_JSTypeAmino = FieldOptions_JSType; export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { switch (object) { case 0: @@ -318,6 +328,8 @@ export enum MethodOptions_IdempotencyLevel { IDEMPOTENT = 2, UNRECOGNIZED = -1, } +export const MethodOptions_IdempotencyLevelSDKType = MethodOptions_IdempotencyLevel; +export const MethodOptions_IdempotencyLevelAmino = MethodOptions_IdempotencyLevel; export function methodOptions_IdempotencyLevelFromJSON(object: any): MethodOptions_IdempotencyLevel { switch (object) { case 0: @@ -359,6 +371,24 @@ export interface FileDescriptorSetProtoMsg { typeUrl: "/google.protobuf.FileDescriptorSet"; value: Uint8Array; } +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSetAmino { + file: FileDescriptorProtoAmino[]; +} +export interface FileDescriptorSetAminoMsg { + type: "/google.protobuf.FileDescriptorSet"; + value: FileDescriptorSetAmino; +} +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSetSDKType { + file: FileDescriptorProtoSDKType[]; +} /** Describes a complete .proto file. */ export interface FileDescriptorProto { /** file name, relative to root of source tree */ @@ -396,6 +426,58 @@ export interface FileDescriptorProtoProtoMsg { typeUrl: "/google.protobuf.FileDescriptorProto"; value: Uint8Array; } +/** Describes a complete .proto file. */ +export interface FileDescriptorProtoAmino { + /** file name, relative to root of source tree */ + name: string; + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + public_dependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weak_dependency: number[]; + /** All top-level definitions in this file. */ + message_type: DescriptorProtoAmino[]; + enum_type: EnumDescriptorProtoAmino[]; + service: ServiceDescriptorProtoAmino[]; + extension: FieldDescriptorProtoAmino[]; + options?: FileOptionsAmino; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + source_code_info?: SourceCodeInfoAmino; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} +export interface FileDescriptorProtoAminoMsg { + type: "/google.protobuf.FileDescriptorProto"; + value: FileDescriptorProtoAmino; +} +/** Describes a complete .proto file. */ +export interface FileDescriptorProtoSDKType { + name: string; + package: string; + dependency: string[]; + public_dependency: number[]; + weak_dependency: number[]; + message_type: DescriptorProtoSDKType[]; + enum_type: EnumDescriptorProtoSDKType[]; + service: ServiceDescriptorProtoSDKType[]; + extension: FieldDescriptorProtoSDKType[]; + options?: FileOptionsSDKType; + source_code_info?: SourceCodeInfoSDKType; + syntax: string; +} /** Describes a message type. */ export interface DescriptorProto { name: string; @@ -417,6 +499,40 @@ export interface DescriptorProtoProtoMsg { typeUrl: "/google.protobuf.DescriptorProto"; value: Uint8Array; } +/** Describes a message type. */ +export interface DescriptorProtoAmino { + name: string; + field: FieldDescriptorProtoAmino[]; + extension: FieldDescriptorProtoAmino[]; + nested_type: DescriptorProtoAmino[]; + enum_type: EnumDescriptorProtoAmino[]; + extension_range: DescriptorProto_ExtensionRangeAmino[]; + oneof_decl: OneofDescriptorProtoAmino[]; + options?: MessageOptionsAmino; + reserved_range: DescriptorProto_ReservedRangeAmino[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reserved_name: string[]; +} +export interface DescriptorProtoAminoMsg { + type: "/google.protobuf.DescriptorProto"; + value: DescriptorProtoAmino; +} +/** Describes a message type. */ +export interface DescriptorProtoSDKType { + name: string; + field: FieldDescriptorProtoSDKType[]; + extension: FieldDescriptorProtoSDKType[]; + nested_type: DescriptorProtoSDKType[]; + enum_type: EnumDescriptorProtoSDKType[]; + extension_range: DescriptorProto_ExtensionRangeSDKType[]; + oneof_decl: OneofDescriptorProtoSDKType[]; + options?: MessageOptionsSDKType; + reserved_range: DescriptorProto_ReservedRangeSDKType[]; + reserved_name: string[]; +} export interface DescriptorProto_ExtensionRange { /** Inclusive. */ start: number; @@ -428,6 +544,22 @@ export interface DescriptorProto_ExtensionRangeProtoMsg { typeUrl: "/google.protobuf.ExtensionRange"; value: Uint8Array; } +export interface DescriptorProto_ExtensionRangeAmino { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options?: ExtensionRangeOptionsAmino; +} +export interface DescriptorProto_ExtensionRangeAminoMsg { + type: "/google.protobuf.ExtensionRange"; + value: DescriptorProto_ExtensionRangeAmino; +} +export interface DescriptorProto_ExtensionRangeSDKType { + start: number; + end: number; + options?: ExtensionRangeOptionsSDKType; +} /** * Range of reserved tag numbers. Reserved tag numbers may not be used by * fields or extension ranges in the same message. Reserved ranges may @@ -443,6 +575,30 @@ export interface DescriptorProto_ReservedRangeProtoMsg { typeUrl: "/google.protobuf.ReservedRange"; value: Uint8Array; } +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRangeAmino { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} +export interface DescriptorProto_ReservedRangeAminoMsg { + type: "/google.protobuf.ReservedRange"; + value: DescriptorProto_ReservedRangeAmino; +} +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRangeSDKType { + start: number; + end: number; +} export interface ExtensionRangeOptions { /** The parser stores options it doesn't recognize here. See above. */ uninterpretedOption: UninterpretedOption[]; @@ -451,6 +607,17 @@ export interface ExtensionRangeOptionsProtoMsg { typeUrl: "/google.protobuf.ExtensionRangeOptions"; value: Uint8Array; } +export interface ExtensionRangeOptionsAmino { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOptionAmino[]; +} +export interface ExtensionRangeOptionsAminoMsg { + type: "/google.protobuf.ExtensionRangeOptions"; + value: ExtensionRangeOptionsAmino; +} +export interface ExtensionRangeOptionsSDKType { + uninterpreted_option: UninterpretedOptionSDKType[]; +} /** Describes a field within a message. */ export interface FieldDescriptorProto { name: string; @@ -500,6 +667,68 @@ export interface FieldDescriptorProtoProtoMsg { typeUrl: "/google.protobuf.FieldDescriptorProto"; value: Uint8Array; } +/** Describes a field within a message. */ +export interface FieldDescriptorProtoAmino { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + type_name: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + default_value: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneof_index: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + json_name: string; + options?: FieldOptionsAmino; +} +export interface FieldDescriptorProtoAminoMsg { + type: "/google.protobuf.FieldDescriptorProto"; + value: FieldDescriptorProtoAmino; +} +/** Describes a field within a message. */ +export interface FieldDescriptorProtoSDKType { + name: string; + number: number; + label: FieldDescriptorProto_Label; + type: FieldDescriptorProto_Type; + type_name: string; + extendee: string; + default_value: string; + oneof_index: number; + json_name: string; + options?: FieldOptionsSDKType; +} /** Describes a oneof. */ export interface OneofDescriptorProto { name: string; @@ -509,6 +738,20 @@ export interface OneofDescriptorProtoProtoMsg { typeUrl: "/google.protobuf.OneofDescriptorProto"; value: Uint8Array; } +/** Describes a oneof. */ +export interface OneofDescriptorProtoAmino { + name: string; + options?: OneofOptionsAmino; +} +export interface OneofDescriptorProtoAminoMsg { + type: "/google.protobuf.OneofDescriptorProto"; + value: OneofDescriptorProtoAmino; +} +/** Describes a oneof. */ +export interface OneofDescriptorProtoSDKType { + name: string; + options?: OneofOptionsSDKType; +} /** Describes an enum type. */ export interface EnumDescriptorProto { name: string; @@ -530,6 +773,35 @@ export interface EnumDescriptorProtoProtoMsg { typeUrl: "/google.protobuf.EnumDescriptorProto"; value: Uint8Array; } +/** Describes an enum type. */ +export interface EnumDescriptorProtoAmino { + name: string; + value: EnumValueDescriptorProtoAmino[]; + options?: EnumOptionsAmino; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reserved_range: EnumDescriptorProto_EnumReservedRangeAmino[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reserved_name: string[]; +} +export interface EnumDescriptorProtoAminoMsg { + type: "/google.protobuf.EnumDescriptorProto"; + value: EnumDescriptorProtoAmino; +} +/** Describes an enum type. */ +export interface EnumDescriptorProtoSDKType { + name: string; + value: EnumValueDescriptorProtoSDKType[]; + options?: EnumOptionsSDKType; + reserved_range: EnumDescriptorProto_EnumReservedRangeSDKType[]; + reserved_name: string[]; +} /** * Range of reserved numeric values. Reserved values may not be used by * entries in the same enum. Reserved ranges may not overlap. @@ -548,6 +820,36 @@ export interface EnumDescriptorProto_EnumReservedRangeProtoMsg { typeUrl: "/google.protobuf.EnumReservedRange"; value: Uint8Array; } +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRangeAmino { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} +export interface EnumDescriptorProto_EnumReservedRangeAminoMsg { + type: "/google.protobuf.EnumReservedRange"; + value: EnumDescriptorProto_EnumReservedRangeAmino; +} +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRangeSDKType { + start: number; + end: number; +} /** Describes a value within an enum. */ export interface EnumValueDescriptorProto { name: string; @@ -558,6 +860,22 @@ export interface EnumValueDescriptorProtoProtoMsg { typeUrl: "/google.protobuf.EnumValueDescriptorProto"; value: Uint8Array; } +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProtoAmino { + name: string; + number: number; + options?: EnumValueOptionsAmino; +} +export interface EnumValueDescriptorProtoAminoMsg { + type: "/google.protobuf.EnumValueDescriptorProto"; + value: EnumValueDescriptorProtoAmino; +} +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProtoSDKType { + name: string; + number: number; + options?: EnumValueOptionsSDKType; +} /** Describes a service. */ export interface ServiceDescriptorProto { name: string; @@ -568,6 +886,22 @@ export interface ServiceDescriptorProtoProtoMsg { typeUrl: "/google.protobuf.ServiceDescriptorProto"; value: Uint8Array; } +/** Describes a service. */ +export interface ServiceDescriptorProtoAmino { + name: string; + method: MethodDescriptorProtoAmino[]; + options?: ServiceOptionsAmino; +} +export interface ServiceDescriptorProtoAminoMsg { + type: "/google.protobuf.ServiceDescriptorProto"; + value: ServiceDescriptorProtoAmino; +} +/** Describes a service. */ +export interface ServiceDescriptorProtoSDKType { + name: string; + method: MethodDescriptorProtoSDKType[]; + options?: ServiceOptionsSDKType; +} /** Describes a method of a service. */ export interface MethodDescriptorProto { name: string; @@ -587,6 +921,34 @@ export interface MethodDescriptorProtoProtoMsg { typeUrl: "/google.protobuf.MethodDescriptorProto"; value: Uint8Array; } +/** Describes a method of a service. */ +export interface MethodDescriptorProtoAmino { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + input_type: string; + output_type: string; + options?: MethodOptionsAmino; + /** Identifies if client streams multiple client messages */ + client_streaming: boolean; + /** Identifies if server streams multiple server messages */ + server_streaming: boolean; +} +export interface MethodDescriptorProtoAminoMsg { + type: "/google.protobuf.MethodDescriptorProto"; + value: MethodDescriptorProtoAmino; +} +/** Describes a method of a service. */ +export interface MethodDescriptorProtoSDKType { + name: string; + input_type: string; + output_type: string; + options?: MethodOptionsSDKType; + client_streaming: boolean; + server_streaming: boolean; +} export interface FileOptions { /** * Sets the Java package where classes generated from this .proto will be @@ -708,43 +1070,188 @@ export interface FileOptionsProtoMsg { typeUrl: "/google.protobuf.FileOptions"; value: Uint8Array; } -export interface MessageOptions { +export interface FileOptionsAmino { /** - * Set true to use the old proto1 MessageSet wire format for extensions. - * This is provided for backwards-compatibility with the MessageSet wire - * format. You should not use this for any other reason: It's less - * efficient, has fewer features, and is more complicated. - * - * The message must be defined exactly as follows: - * message Foo { - * option message_set_wire_format = true; - * extensions 4 to max; - * } - * Note that the message cannot have any defined fields; MessageSets only - * have extensions. - * - * All extensions of your type must be singular messages; e.g. they cannot - * be int32s, enums, or repeated messages. - * - * Because this is an option, the above two restrictions are not enforced by - * the protocol compiler. + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. */ - messageSetWireFormat: boolean; + java_package: string; /** - * Disables the generation of the standard "descriptor()" accessor, which can - * conflict with a field of the same name. This is meant to make migration - * from proto1 easier; new code should avoid fields named "descriptor". + * If set, all the classes from the .proto file are wrapped in a single + * outer class with the given name. This applies to both Proto1 + * (equivalent to the old "--one_java_file" option) and Proto2 (where + * a .proto always translates to a single class, but you may want to + * explicitly choose the class name). */ - noStandardDescriptorAccessor: boolean; + java_outer_classname: string; /** - * Is this message deprecated? - * Depending on the target platform, this can emit Deprecated annotations - * for the message, or it will be completely ignored; in the very least, - * this is a formalization for deprecating messages. + * If set true, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the outer class + * named by java_outer_classname. However, the outer class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. */ - deprecated: boolean; + java_multiple_files: boolean; + /** This option does nothing. */ + /** @deprecated */ + java_generate_equals_and_hash: boolean; /** - * Whether the message is an automatically generated map entry type for the + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + java_string_check_utf8: boolean; + optimize_for: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + go_package: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + cc_generic_services: boolean; + java_generic_services: boolean; + py_generic_services: boolean; + php_generic_services: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + cc_enable_arenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objc_class_prefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharp_namespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swift_prefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + php_class_prefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + php_namespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + php_metadata_namespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + ruby_package: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpreted_option: UninterpretedOptionAmino[]; +} +export interface FileOptionsAminoMsg { + type: "/google.protobuf.FileOptions"; + value: FileOptionsAmino; +} +export interface FileOptionsSDKType { + java_package: string; + java_outer_classname: string; + java_multiple_files: boolean; + /** @deprecated */ + java_generate_equals_and_hash: boolean; + java_string_check_utf8: boolean; + optimize_for: FileOptions_OptimizeMode; + go_package: string; + cc_generic_services: boolean; + java_generic_services: boolean; + py_generic_services: boolean; + php_generic_services: boolean; + deprecated: boolean; + cc_enable_arenas: boolean; + objc_class_prefix: string; + csharp_namespace: string; + swift_prefix: string; + php_class_prefix: string; + php_namespace: string; + php_metadata_namespace: string; + ruby_package: string; + uninterpreted_option: UninterpretedOptionSDKType[]; +} +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the * maps field. * * For maps fields: @@ -774,6 +1281,79 @@ export interface MessageOptionsProtoMsg { typeUrl: "/google.protobuf.MessageOptions"; value: Uint8Array; } +export interface MessageOptionsAmino { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + message_set_wire_format: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + no_standard_descriptor_accessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + map_entry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOptionAmino[]; +} +export interface MessageOptionsAminoMsg { + type: "/google.protobuf.MessageOptions"; + value: MessageOptionsAmino; +} +export interface MessageOptionsSDKType { + message_set_wire_format: boolean; + no_standard_descriptor_accessor: boolean; + deprecated: boolean; + map_entry: boolean; + uninterpreted_option: UninterpretedOptionSDKType[]; +} export interface FieldOptions { /** * The ctype option instructs the C++ code generator to use a different @@ -851,6 +1431,92 @@ export interface FieldOptionsProtoMsg { typeUrl: "/google.protobuf.FieldOptions"; value: Uint8Array; } +export interface FieldOptionsAmino { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOptionAmino[]; +} +export interface FieldOptionsAminoMsg { + type: "/google.protobuf.FieldOptions"; + value: FieldOptionsAmino; +} +export interface FieldOptionsSDKType { + ctype: FieldOptions_CType; + packed: boolean; + jstype: FieldOptions_JSType; + lazy: boolean; + deprecated: boolean; + weak: boolean; + uninterpreted_option: UninterpretedOptionSDKType[]; +} export interface OneofOptions { /** The parser stores options it doesn't recognize here. See above. */ uninterpretedOption: UninterpretedOption[]; @@ -859,6 +1525,17 @@ export interface OneofOptionsProtoMsg { typeUrl: "/google.protobuf.OneofOptions"; value: Uint8Array; } +export interface OneofOptionsAmino { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOptionAmino[]; +} +export interface OneofOptionsAminoMsg { + type: "/google.protobuf.OneofOptions"; + value: OneofOptionsAmino; +} +export interface OneofOptionsSDKType { + uninterpreted_option: UninterpretedOptionSDKType[]; +} export interface EnumOptions { /** * Set this option to true to allow mapping different tag names to the same @@ -879,6 +1556,31 @@ export interface EnumOptionsProtoMsg { typeUrl: "/google.protobuf.EnumOptions"; value: Uint8Array; } +export interface EnumOptionsAmino { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allow_alias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOptionAmino[]; +} +export interface EnumOptionsAminoMsg { + type: "/google.protobuf.EnumOptions"; + value: EnumOptionsAmino; +} +export interface EnumOptionsSDKType { + allow_alias: boolean; + deprecated: boolean; + uninterpreted_option: UninterpretedOptionSDKType[]; +} export interface EnumValueOptions { /** * Is this enum value deprecated? @@ -894,6 +1596,25 @@ export interface EnumValueOptionsProtoMsg { typeUrl: "/google.protobuf.EnumValueOptions"; value: Uint8Array; } +export interface EnumValueOptionsAmino { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOptionAmino[]; +} +export interface EnumValueOptionsAminoMsg { + type: "/google.protobuf.EnumValueOptions"; + value: EnumValueOptionsAmino; +} +export interface EnumValueOptionsSDKType { + deprecated: boolean; + uninterpreted_option: UninterpretedOptionSDKType[]; +} export interface ServiceOptions { /** * Is this service deprecated? @@ -909,6 +1630,25 @@ export interface ServiceOptionsProtoMsg { typeUrl: "/google.protobuf.ServiceOptions"; value: Uint8Array; } +export interface ServiceOptionsAmino { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOptionAmino[]; +} +export interface ServiceOptionsAminoMsg { + type: "/google.protobuf.ServiceOptions"; + value: ServiceOptionsAmino; +} +export interface ServiceOptionsSDKType { + deprecated: boolean; + uninterpreted_option: UninterpretedOptionSDKType[]; +} export interface MethodOptions { /** * Is this method deprecated? @@ -925,6 +1665,27 @@ export interface MethodOptionsProtoMsg { typeUrl: "/google.protobuf.MethodOptions"; value: Uint8Array; } +export interface MethodOptionsAmino { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotency_level: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOptionAmino[]; +} +export interface MethodOptionsAminoMsg { + type: "/google.protobuf.MethodOptions"; + value: MethodOptionsAmino; +} +export interface MethodOptionsSDKType { + deprecated: boolean; + idempotency_level: MethodOptions_IdempotencyLevel; + uninterpreted_option: UninterpretedOptionSDKType[]; +} /** * A message representing a option the parser does not recognize. This only * appears in options protos created by the compiler::Parser class. @@ -950,6 +1711,48 @@ export interface UninterpretedOptionProtoMsg { typeUrl: "/google.protobuf.UninterpretedOption"; value: Uint8Array; } +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOptionAmino { + name: UninterpretedOption_NamePartAmino[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifier_value: string; + positive_int_value: string; + negative_int_value: string; + double_value: number; + string_value: Uint8Array; + aggregate_value: string; +} +export interface UninterpretedOptionAminoMsg { + type: "/google.protobuf.UninterpretedOption"; + value: UninterpretedOptionAmino; +} +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOptionSDKType { + name: UninterpretedOption_NamePartSDKType[]; + identifier_value: string; + positive_int_value: bigint; + negative_int_value: bigint; + double_value: number; + string_value: Uint8Array; + aggregate_value: string; +} /** * The name of the uninterpreted option. Each string represents a segment in * a dot-separated name. is_extension is true iff a segment represents an @@ -965,6 +1768,32 @@ export interface UninterpretedOption_NamePartProtoMsg { typeUrl: "/google.protobuf.NamePart"; value: Uint8Array; } +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePartAmino { + name_part: string; + is_extension: boolean; +} +export interface UninterpretedOption_NamePartAminoMsg { + type: "/google.protobuf.NamePart"; + value: UninterpretedOption_NamePartAmino; +} +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePartSDKType { + name_part: string; + is_extension: boolean; +} /** * Encapsulates information about the original source file from which a * FileDescriptorProto was generated. @@ -1017,9 +1846,72 @@ export interface SourceCodeInfo { */ location: SourceCodeInfo_Location[]; } -export interface SourceCodeInfoProtoMsg { - typeUrl: "/google.protobuf.SourceCodeInfo"; - value: Uint8Array; +export interface SourceCodeInfoProtoMsg { + typeUrl: "/google.protobuf.SourceCodeInfo"; + value: Uint8Array; +} +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfoAmino { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_LocationAmino[]; +} +export interface SourceCodeInfoAminoMsg { + type: "/google.protobuf.SourceCodeInfo"; + value: SourceCodeInfoAmino; +} +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfoSDKType { + location: SourceCodeInfo_LocationSDKType[]; } export interface SourceCodeInfo_Location { /** @@ -1113,6 +2005,105 @@ export interface SourceCodeInfo_LocationProtoMsg { typeUrl: "/google.protobuf.Location"; value: Uint8Array; } +export interface SourceCodeInfo_LocationAmino { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. *\/ + * /* Block comment attached to + * * grault. *\/ + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leading_comments: string; + trailing_comments: string; + leading_detached_comments: string[]; +} +export interface SourceCodeInfo_LocationAminoMsg { + type: "/google.protobuf.Location"; + value: SourceCodeInfo_LocationAmino; +} +export interface SourceCodeInfo_LocationSDKType { + path: number[]; + span: number[]; + leading_comments: string; + trailing_comments: string; + leading_detached_comments: string[]; +} /** * Describes the relationship between generated code and its original source * file. A GeneratedCodeInfo message is associated with only one generated @@ -1129,6 +2120,30 @@ export interface GeneratedCodeInfoProtoMsg { typeUrl: "/google.protobuf.GeneratedCodeInfo"; value: Uint8Array; } +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfoAmino { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_AnnotationAmino[]; +} +export interface GeneratedCodeInfoAminoMsg { + type: "/google.protobuf.GeneratedCodeInfo"; + value: GeneratedCodeInfoAmino; +} +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfoSDKType { + annotation: GeneratedCodeInfo_AnnotationSDKType[]; +} export interface GeneratedCodeInfo_Annotation { /** * Identifies the element in the original source .proto file. This field @@ -1153,6 +2168,36 @@ export interface GeneratedCodeInfo_AnnotationProtoMsg { typeUrl: "/google.protobuf.Annotation"; value: Uint8Array; } +export interface GeneratedCodeInfo_AnnotationAmino { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + source_file: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} +export interface GeneratedCodeInfo_AnnotationAminoMsg { + type: "/google.protobuf.Annotation"; + value: GeneratedCodeInfo_AnnotationAmino; +} +export interface GeneratedCodeInfo_AnnotationSDKType { + path: number[]; + source_file: string; + begin: number; + end: number; +} function createBaseFileDescriptorSet(): FileDescriptorSet { return { file: [] @@ -1163,6 +2208,12 @@ export const FileDescriptorSet = { is(o: any): o is FileDescriptorSet { return o && (o.$typeUrl === FileDescriptorSet.typeUrl || Array.isArray(o.file) && (!o.file.length || FileDescriptorProto.is(o.file[0]))); }, + isSDK(o: any): o is FileDescriptorSet { + return o && (o.$typeUrl === FileDescriptorSet.typeUrl || Array.isArray(o.file) && (!o.file.length || FileDescriptorProto.isSDK(o.file[0]))); + }, + isAmino(o: any): o is FileDescriptorSet { + return o && (o.$typeUrl === FileDescriptorSet.typeUrl || Array.isArray(o.file) && (!o.file.length || FileDescriptorProto.isAmino(o.file[0]))); + }, encode(message: FileDescriptorSet, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { for (const v of message.file) { FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); @@ -1205,6 +2256,23 @@ export const FileDescriptorSet = { message.file = object.file?.map(e => FileDescriptorProto.fromPartial(e)) || []; return message; }, + fromAmino(object: FileDescriptorSetAmino): FileDescriptorSet { + return { + file: Array.isArray(object?.file) ? object.file.map((e: any) => FileDescriptorProto.fromAmino(e)) : [] + }; + }, + toAmino(message: FileDescriptorSet): FileDescriptorSetAmino { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map(e => e ? FileDescriptorProto.toAmino(e) : undefined); + } else { + obj.file = []; + } + return obj; + }, + fromAminoMsg(object: FileDescriptorSetAminoMsg): FileDescriptorSet { + return FileDescriptorSet.fromAmino(object.value); + }, fromProtoMsg(message: FileDescriptorSetProtoMsg): FileDescriptorSet { return FileDescriptorSet.decode(message.value); }, @@ -1240,6 +2308,12 @@ export const FileDescriptorProto = { is(o: any): o is FileDescriptorProto { return o && (o.$typeUrl === FileDescriptorProto.typeUrl || typeof o.name === "string" && typeof o.package === "string" && Array.isArray(o.dependency) && (!o.dependency.length || typeof o.dependency[0] === "string") && Array.isArray(o.publicDependency) && (!o.publicDependency.length || typeof o.publicDependency[0] === "number") && Array.isArray(o.weakDependency) && (!o.weakDependency.length || typeof o.weakDependency[0] === "number") && Array.isArray(o.messageType) && (!o.messageType.length || DescriptorProto.is(o.messageType[0])) && Array.isArray(o.enumType) && (!o.enumType.length || EnumDescriptorProto.is(o.enumType[0])) && Array.isArray(o.service) && (!o.service.length || ServiceDescriptorProto.is(o.service[0])) && Array.isArray(o.extension) && (!o.extension.length || FieldDescriptorProto.is(o.extension[0])) && typeof o.syntax === "string"); }, + isSDK(o: any): o is FileDescriptorProto { + return o && (o.$typeUrl === FileDescriptorProto.typeUrl || typeof o.name === "string" && typeof o.package === "string" && Array.isArray(o.dependency) && (!o.dependency.length || typeof o.dependency[0] === "string") && Array.isArray(o.public_dependency) && (!o.public_dependency.length || typeof o.public_dependency[0] === "number") && Array.isArray(o.weak_dependency) && (!o.weak_dependency.length || typeof o.weak_dependency[0] === "number") && Array.isArray(o.message_type) && (!o.message_type.length || DescriptorProto.isSDK(o.message_type[0])) && Array.isArray(o.enum_type) && (!o.enum_type.length || EnumDescriptorProto.isSDK(o.enum_type[0])) && Array.isArray(o.service) && (!o.service.length || ServiceDescriptorProto.isSDK(o.service[0])) && Array.isArray(o.extension) && (!o.extension.length || FieldDescriptorProto.isSDK(o.extension[0])) && typeof o.syntax === "string"); + }, + isAmino(o: any): o is FileDescriptorProto { + return o && (o.$typeUrl === FileDescriptorProto.typeUrl || typeof o.name === "string" && typeof o.package === "string" && Array.isArray(o.dependency) && (!o.dependency.length || typeof o.dependency[0] === "string") && Array.isArray(o.public_dependency) && (!o.public_dependency.length || typeof o.public_dependency[0] === "number") && Array.isArray(o.weak_dependency) && (!o.weak_dependency.length || typeof o.weak_dependency[0] === "number") && Array.isArray(o.message_type) && (!o.message_type.length || DescriptorProto.isAmino(o.message_type[0])) && Array.isArray(o.enum_type) && (!o.enum_type.length || EnumDescriptorProto.isAmino(o.enum_type[0])) && Array.isArray(o.service) && (!o.service.length || ServiceDescriptorProto.isAmino(o.service[0])) && Array.isArray(o.extension) && (!o.extension.length || FieldDescriptorProto.isAmino(o.extension[0])) && typeof o.syntax === "string"); + }, encode(message: FileDescriptorProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.name !== "") { writer.uint32(10).string(message.name); @@ -1427,6 +2501,69 @@ export const FileDescriptorProto = { message.syntax = object.syntax ?? ""; return message; }, + fromAmino(object: FileDescriptorProtoAmino): FileDescriptorProto { + return { + name: object.name, + package: object.package, + dependency: Array.isArray(object?.dependency) ? object.dependency.map((e: any) => e) : [], + publicDependency: Array.isArray(object?.public_dependency) ? object.public_dependency.map((e: any) => e) : [], + weakDependency: Array.isArray(object?.weak_dependency) ? object.weak_dependency.map((e: any) => e) : [], + messageType: Array.isArray(object?.message_type) ? object.message_type.map((e: any) => DescriptorProto.fromAmino(e)) : [], + enumType: Array.isArray(object?.enum_type) ? object.enum_type.map((e: any) => EnumDescriptorProto.fromAmino(e)) : [], + service: Array.isArray(object?.service) ? object.service.map((e: any) => ServiceDescriptorProto.fromAmino(e)) : [], + extension: Array.isArray(object?.extension) ? object.extension.map((e: any) => FieldDescriptorProto.fromAmino(e)) : [], + options: object?.options ? FileOptions.fromAmino(object.options) : undefined, + sourceCodeInfo: object?.source_code_info ? SourceCodeInfo.fromAmino(object.source_code_info) : undefined, + syntax: object.syntax + }; + }, + toAmino(message: FileDescriptorProto): FileDescriptorProtoAmino { + const obj: any = {}; + obj.name = message.name; + obj.package = message.package; + if (message.dependency) { + obj.dependency = message.dependency.map(e => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.public_dependency = message.publicDependency.map(e => e); + } else { + obj.public_dependency = []; + } + if (message.weakDependency) { + obj.weak_dependency = message.weakDependency.map(e => e); + } else { + obj.weak_dependency = []; + } + if (message.messageType) { + obj.message_type = message.messageType.map(e => e ? DescriptorProto.toAmino(e) : undefined); + } else { + obj.message_type = []; + } + if (message.enumType) { + obj.enum_type = message.enumType.map(e => e ? EnumDescriptorProto.toAmino(e) : undefined); + } else { + obj.enum_type = []; + } + if (message.service) { + obj.service = message.service.map(e => e ? ServiceDescriptorProto.toAmino(e) : undefined); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map(e => e ? FieldDescriptorProto.toAmino(e) : undefined); + } else { + obj.extension = []; + } + obj.options = message.options ? FileOptions.toAmino(message.options) : undefined; + obj.source_code_info = message.sourceCodeInfo ? SourceCodeInfo.toAmino(message.sourceCodeInfo) : undefined; + obj.syntax = message.syntax; + return obj; + }, + fromAminoMsg(object: FileDescriptorProtoAminoMsg): FileDescriptorProto { + return FileDescriptorProto.fromAmino(object.value); + }, fromProtoMsg(message: FileDescriptorProtoProtoMsg): FileDescriptorProto { return FileDescriptorProto.decode(message.value); }, @@ -1460,6 +2597,12 @@ export const DescriptorProto = { is(o: any): o is DescriptorProto { return o && (o.$typeUrl === DescriptorProto.typeUrl || typeof o.name === "string" && Array.isArray(o.field) && (!o.field.length || FieldDescriptorProto.is(o.field[0])) && Array.isArray(o.extension) && (!o.extension.length || FieldDescriptorProto.is(o.extension[0])) && Array.isArray(o.nestedType) && (!o.nestedType.length || DescriptorProto.is(o.nestedType[0])) && Array.isArray(o.enumType) && (!o.enumType.length || EnumDescriptorProto.is(o.enumType[0])) && Array.isArray(o.extensionRange) && (!o.extensionRange.length || DescriptorProto_ExtensionRange.is(o.extensionRange[0])) && Array.isArray(o.oneofDecl) && (!o.oneofDecl.length || OneofDescriptorProto.is(o.oneofDecl[0])) && Array.isArray(o.reservedRange) && (!o.reservedRange.length || DescriptorProto_ReservedRange.is(o.reservedRange[0])) && Array.isArray(o.reservedName) && (!o.reservedName.length || typeof o.reservedName[0] === "string")); }, + isSDK(o: any): o is DescriptorProto { + return o && (o.$typeUrl === DescriptorProto.typeUrl || typeof o.name === "string" && Array.isArray(o.field) && (!o.field.length || FieldDescriptorProto.isSDK(o.field[0])) && Array.isArray(o.extension) && (!o.extension.length || FieldDescriptorProto.isSDK(o.extension[0])) && Array.isArray(o.nested_type) && (!o.nested_type.length || DescriptorProto.isSDK(o.nested_type[0])) && Array.isArray(o.enum_type) && (!o.enum_type.length || EnumDescriptorProto.isSDK(o.enum_type[0])) && Array.isArray(o.extension_range) && (!o.extension_range.length || DescriptorProto_ExtensionRange.isSDK(o.extension_range[0])) && Array.isArray(o.oneof_decl) && (!o.oneof_decl.length || OneofDescriptorProto.isSDK(o.oneof_decl[0])) && Array.isArray(o.reserved_range) && (!o.reserved_range.length || DescriptorProto_ReservedRange.isSDK(o.reserved_range[0])) && Array.isArray(o.reserved_name) && (!o.reserved_name.length || typeof o.reserved_name[0] === "string")); + }, + isAmino(o: any): o is DescriptorProto { + return o && (o.$typeUrl === DescriptorProto.typeUrl || typeof o.name === "string" && Array.isArray(o.field) && (!o.field.length || FieldDescriptorProto.isAmino(o.field[0])) && Array.isArray(o.extension) && (!o.extension.length || FieldDescriptorProto.isAmino(o.extension[0])) && Array.isArray(o.nested_type) && (!o.nested_type.length || DescriptorProto.isAmino(o.nested_type[0])) && Array.isArray(o.enum_type) && (!o.enum_type.length || EnumDescriptorProto.isAmino(o.enum_type[0])) && Array.isArray(o.extension_range) && (!o.extension_range.length || DescriptorProto_ExtensionRange.isAmino(o.extension_range[0])) && Array.isArray(o.oneof_decl) && (!o.oneof_decl.length || OneofDescriptorProto.isAmino(o.oneof_decl[0])) && Array.isArray(o.reserved_range) && (!o.reserved_range.length || DescriptorProto_ReservedRange.isAmino(o.reserved_range[0])) && Array.isArray(o.reserved_name) && (!o.reserved_name.length || typeof o.reserved_name[0] === "string")); + }, encode(message: DescriptorProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.name !== "") { writer.uint32(10).string(message.name); @@ -1613,6 +2756,69 @@ export const DescriptorProto = { message.reservedName = object.reservedName?.map(e => e) || []; return message; }, + fromAmino(object: DescriptorProtoAmino): DescriptorProto { + return { + name: object.name, + field: Array.isArray(object?.field) ? object.field.map((e: any) => FieldDescriptorProto.fromAmino(e)) : [], + extension: Array.isArray(object?.extension) ? object.extension.map((e: any) => FieldDescriptorProto.fromAmino(e)) : [], + nestedType: Array.isArray(object?.nested_type) ? object.nested_type.map((e: any) => DescriptorProto.fromAmino(e)) : [], + enumType: Array.isArray(object?.enum_type) ? object.enum_type.map((e: any) => EnumDescriptorProto.fromAmino(e)) : [], + extensionRange: Array.isArray(object?.extension_range) ? object.extension_range.map((e: any) => DescriptorProto_ExtensionRange.fromAmino(e)) : [], + oneofDecl: Array.isArray(object?.oneof_decl) ? object.oneof_decl.map((e: any) => OneofDescriptorProto.fromAmino(e)) : [], + options: object?.options ? MessageOptions.fromAmino(object.options) : undefined, + reservedRange: Array.isArray(object?.reserved_range) ? object.reserved_range.map((e: any) => DescriptorProto_ReservedRange.fromAmino(e)) : [], + reservedName: Array.isArray(object?.reserved_name) ? object.reserved_name.map((e: any) => e) : [] + }; + }, + toAmino(message: DescriptorProto): DescriptorProtoAmino { + const obj: any = {}; + obj.name = message.name; + if (message.field) { + obj.field = message.field.map(e => e ? FieldDescriptorProto.toAmino(e) : undefined); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map(e => e ? FieldDescriptorProto.toAmino(e) : undefined); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nested_type = message.nestedType.map(e => e ? DescriptorProto.toAmino(e) : undefined); + } else { + obj.nested_type = []; + } + if (message.enumType) { + obj.enum_type = message.enumType.map(e => e ? EnumDescriptorProto.toAmino(e) : undefined); + } else { + obj.enum_type = []; + } + if (message.extensionRange) { + obj.extension_range = message.extensionRange.map(e => e ? DescriptorProto_ExtensionRange.toAmino(e) : undefined); + } else { + obj.extension_range = []; + } + if (message.oneofDecl) { + obj.oneof_decl = message.oneofDecl.map(e => e ? OneofDescriptorProto.toAmino(e) : undefined); + } else { + obj.oneof_decl = []; + } + obj.options = message.options ? MessageOptions.toAmino(message.options) : undefined; + if (message.reservedRange) { + obj.reserved_range = message.reservedRange.map(e => e ? DescriptorProto_ReservedRange.toAmino(e) : undefined); + } else { + obj.reserved_range = []; + } + if (message.reservedName) { + obj.reserved_name = message.reservedName.map(e => e); + } else { + obj.reserved_name = []; + } + return obj; + }, + fromAminoMsg(object: DescriptorProtoAminoMsg): DescriptorProto { + return DescriptorProto.fromAmino(object.value); + }, fromProtoMsg(message: DescriptorProtoProtoMsg): DescriptorProto { return DescriptorProto.decode(message.value); }, @@ -1639,6 +2845,12 @@ export const DescriptorProto_ExtensionRange = { is(o: any): o is DescriptorProto_ExtensionRange { return o && (o.$typeUrl === DescriptorProto_ExtensionRange.typeUrl || typeof o.start === "number" && typeof o.end === "number"); }, + isSDK(o: any): o is DescriptorProto_ExtensionRange { + return o && (o.$typeUrl === DescriptorProto_ExtensionRange.typeUrl || typeof o.start === "number" && typeof o.end === "number"); + }, + isAmino(o: any): o is DescriptorProto_ExtensionRange { + return o && (o.$typeUrl === DescriptorProto_ExtensionRange.typeUrl || typeof o.start === "number" && typeof o.end === "number"); + }, encode(message: DescriptorProto_ExtensionRange, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.start !== 0) { writer.uint32(8).int32(message.start); @@ -1697,6 +2909,23 @@ export const DescriptorProto_ExtensionRange = { } return message; }, + fromAmino(object: DescriptorProto_ExtensionRangeAmino): DescriptorProto_ExtensionRange { + return { + start: object.start, + end: object.end, + options: object?.options ? ExtensionRangeOptions.fromAmino(object.options) : undefined + }; + }, + toAmino(message: DescriptorProto_ExtensionRange): DescriptorProto_ExtensionRangeAmino { + const obj: any = {}; + obj.start = message.start; + obj.end = message.end; + obj.options = message.options ? ExtensionRangeOptions.toAmino(message.options) : undefined; + return obj; + }, + fromAminoMsg(object: DescriptorProto_ExtensionRangeAminoMsg): DescriptorProto_ExtensionRange { + return DescriptorProto_ExtensionRange.fromAmino(object.value); + }, fromProtoMsg(message: DescriptorProto_ExtensionRangeProtoMsg): DescriptorProto_ExtensionRange { return DescriptorProto_ExtensionRange.decode(message.value); }, @@ -1722,6 +2951,12 @@ export const DescriptorProto_ReservedRange = { is(o: any): o is DescriptorProto_ReservedRange { return o && (o.$typeUrl === DescriptorProto_ReservedRange.typeUrl || typeof o.start === "number" && typeof o.end === "number"); }, + isSDK(o: any): o is DescriptorProto_ReservedRange { + return o && (o.$typeUrl === DescriptorProto_ReservedRange.typeUrl || typeof o.start === "number" && typeof o.end === "number"); + }, + isAmino(o: any): o is DescriptorProto_ReservedRange { + return o && (o.$typeUrl === DescriptorProto_ReservedRange.typeUrl || typeof o.start === "number" && typeof o.end === "number"); + }, encode(message: DescriptorProto_ReservedRange, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.start !== 0) { writer.uint32(8).int32(message.start); @@ -1769,6 +3004,21 @@ export const DescriptorProto_ReservedRange = { message.end = object.end ?? 0; return message; }, + fromAmino(object: DescriptorProto_ReservedRangeAmino): DescriptorProto_ReservedRange { + return { + start: object.start, + end: object.end + }; + }, + toAmino(message: DescriptorProto_ReservedRange): DescriptorProto_ReservedRangeAmino { + const obj: any = {}; + obj.start = message.start; + obj.end = message.end; + return obj; + }, + fromAminoMsg(object: DescriptorProto_ReservedRangeAminoMsg): DescriptorProto_ReservedRange { + return DescriptorProto_ReservedRange.fromAmino(object.value); + }, fromProtoMsg(message: DescriptorProto_ReservedRangeProtoMsg): DescriptorProto_ReservedRange { return DescriptorProto_ReservedRange.decode(message.value); }, @@ -1793,6 +3043,12 @@ export const ExtensionRangeOptions = { is(o: any): o is ExtensionRangeOptions { return o && (o.$typeUrl === ExtensionRangeOptions.typeUrl || Array.isArray(o.uninterpretedOption) && (!o.uninterpretedOption.length || UninterpretedOption.is(o.uninterpretedOption[0]))); }, + isSDK(o: any): o is ExtensionRangeOptions { + return o && (o.$typeUrl === ExtensionRangeOptions.typeUrl || Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isSDK(o.uninterpreted_option[0]))); + }, + isAmino(o: any): o is ExtensionRangeOptions { + return o && (o.$typeUrl === ExtensionRangeOptions.typeUrl || Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isAmino(o.uninterpreted_option[0]))); + }, encode(message: ExtensionRangeOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); @@ -1835,6 +3091,23 @@ export const ExtensionRangeOptions = { message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; return message; }, + fromAmino(object: ExtensionRangeOptionsAmino): ExtensionRangeOptions { + return { + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromAmino(e)) : [] + }; + }, + toAmino(message: ExtensionRangeOptions): ExtensionRangeOptionsAmino { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAminoMsg(object: ExtensionRangeOptionsAminoMsg): ExtensionRangeOptions { + return ExtensionRangeOptions.fromAmino(object.value); + }, fromProtoMsg(message: ExtensionRangeOptionsProtoMsg): ExtensionRangeOptions { return ExtensionRangeOptions.decode(message.value); }, @@ -1868,6 +3141,12 @@ export const FieldDescriptorProto = { is(o: any): o is FieldDescriptorProto { return o && (o.$typeUrl === FieldDescriptorProto.typeUrl || typeof o.name === "string" && typeof o.number === "number" && o.label && o.type && typeof o.typeName === "string" && typeof o.extendee === "string" && typeof o.defaultValue === "string" && typeof o.oneofIndex === "number" && typeof o.jsonName === "string"); }, + isSDK(o: any): o is FieldDescriptorProto { + return o && (o.$typeUrl === FieldDescriptorProto.typeUrl || typeof o.name === "string" && typeof o.number === "number" && o.label && o.type && typeof o.type_name === "string" && typeof o.extendee === "string" && typeof o.default_value === "string" && typeof o.oneof_index === "number" && typeof o.json_name === "string"); + }, + isAmino(o: any): o is FieldDescriptorProto { + return o && (o.$typeUrl === FieldDescriptorProto.typeUrl || typeof o.name === "string" && typeof o.number === "number" && o.label && o.type && typeof o.type_name === "string" && typeof o.extendee === "string" && typeof o.default_value === "string" && typeof o.oneof_index === "number" && typeof o.json_name === "string"); + }, encode(message: FieldDescriptorProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.name !== "") { writer.uint32(10).string(message.name); @@ -1989,6 +3268,37 @@ export const FieldDescriptorProto = { } return message; }, + fromAmino(object: FieldDescriptorProtoAmino): FieldDescriptorProto { + return { + name: object.name, + number: object.number, + label: isSet(object.label) ? fieldDescriptorProto_LabelFromJSON(object.label) : -1, + type: isSet(object.type) ? fieldDescriptorProto_TypeFromJSON(object.type) : -1, + typeName: object.type_name, + extendee: object.extendee, + defaultValue: object.default_value, + oneofIndex: object.oneof_index, + jsonName: object.json_name, + options: object?.options ? FieldOptions.fromAmino(object.options) : undefined + }; + }, + toAmino(message: FieldDescriptorProto): FieldDescriptorProtoAmino { + const obj: any = {}; + obj.name = message.name; + obj.number = message.number; + obj.label = message.label; + obj.type = message.type; + obj.type_name = message.typeName; + obj.extendee = message.extendee; + obj.default_value = message.defaultValue; + obj.oneof_index = message.oneofIndex; + obj.json_name = message.jsonName; + obj.options = message.options ? FieldOptions.toAmino(message.options) : undefined; + return obj; + }, + fromAminoMsg(object: FieldDescriptorProtoAminoMsg): FieldDescriptorProto { + return FieldDescriptorProto.fromAmino(object.value); + }, fromProtoMsg(message: FieldDescriptorProtoProtoMsg): FieldDescriptorProto { return FieldDescriptorProto.decode(message.value); }, @@ -2014,6 +3324,12 @@ export const OneofDescriptorProto = { is(o: any): o is OneofDescriptorProto { return o && (o.$typeUrl === OneofDescriptorProto.typeUrl || typeof o.name === "string"); }, + isSDK(o: any): o is OneofDescriptorProto { + return o && (o.$typeUrl === OneofDescriptorProto.typeUrl || typeof o.name === "string"); + }, + isAmino(o: any): o is OneofDescriptorProto { + return o && (o.$typeUrl === OneofDescriptorProto.typeUrl || typeof o.name === "string"); + }, encode(message: OneofDescriptorProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.name !== "") { writer.uint32(10).string(message.name); @@ -2063,6 +3379,21 @@ export const OneofDescriptorProto = { } return message; }, + fromAmino(object: OneofDescriptorProtoAmino): OneofDescriptorProto { + return { + name: object.name, + options: object?.options ? OneofOptions.fromAmino(object.options) : undefined + }; + }, + toAmino(message: OneofDescriptorProto): OneofDescriptorProtoAmino { + const obj: any = {}; + obj.name = message.name; + obj.options = message.options ? OneofOptions.toAmino(message.options) : undefined; + return obj; + }, + fromAminoMsg(object: OneofDescriptorProtoAminoMsg): OneofDescriptorProto { + return OneofDescriptorProto.fromAmino(object.value); + }, fromProtoMsg(message: OneofDescriptorProtoProtoMsg): OneofDescriptorProto { return OneofDescriptorProto.decode(message.value); }, @@ -2091,6 +3422,12 @@ export const EnumDescriptorProto = { is(o: any): o is EnumDescriptorProto { return o && (o.$typeUrl === EnumDescriptorProto.typeUrl || typeof o.name === "string" && Array.isArray(o.value) && (!o.value.length || EnumValueDescriptorProto.is(o.value[0])) && Array.isArray(o.reservedRange) && (!o.reservedRange.length || EnumDescriptorProto_EnumReservedRange.is(o.reservedRange[0])) && Array.isArray(o.reservedName) && (!o.reservedName.length || typeof o.reservedName[0] === "string")); }, + isSDK(o: any): o is EnumDescriptorProto { + return o && (o.$typeUrl === EnumDescriptorProto.typeUrl || typeof o.name === "string" && Array.isArray(o.value) && (!o.value.length || EnumValueDescriptorProto.isSDK(o.value[0])) && Array.isArray(o.reserved_range) && (!o.reserved_range.length || EnumDescriptorProto_EnumReservedRange.isSDK(o.reserved_range[0])) && Array.isArray(o.reserved_name) && (!o.reserved_name.length || typeof o.reserved_name[0] === "string")); + }, + isAmino(o: any): o is EnumDescriptorProto { + return o && (o.$typeUrl === EnumDescriptorProto.typeUrl || typeof o.name === "string" && Array.isArray(o.value) && (!o.value.length || EnumValueDescriptorProto.isAmino(o.value[0])) && Array.isArray(o.reserved_range) && (!o.reserved_range.length || EnumDescriptorProto_EnumReservedRange.isAmino(o.reserved_range[0])) && Array.isArray(o.reserved_name) && (!o.reserved_name.length || typeof o.reserved_name[0] === "string")); + }, encode(message: EnumDescriptorProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.name !== "") { writer.uint32(10).string(message.name); @@ -2179,6 +3516,39 @@ export const EnumDescriptorProto = { message.reservedName = object.reservedName?.map(e => e) || []; return message; }, + fromAmino(object: EnumDescriptorProtoAmino): EnumDescriptorProto { + return { + name: object.name, + value: Array.isArray(object?.value) ? object.value.map((e: any) => EnumValueDescriptorProto.fromAmino(e)) : [], + options: object?.options ? EnumOptions.fromAmino(object.options) : undefined, + reservedRange: Array.isArray(object?.reserved_range) ? object.reserved_range.map((e: any) => EnumDescriptorProto_EnumReservedRange.fromAmino(e)) : [], + reservedName: Array.isArray(object?.reserved_name) ? object.reserved_name.map((e: any) => e) : [] + }; + }, + toAmino(message: EnumDescriptorProto): EnumDescriptorProtoAmino { + const obj: any = {}; + obj.name = message.name; + if (message.value) { + obj.value = message.value.map(e => e ? EnumValueDescriptorProto.toAmino(e) : undefined); + } else { + obj.value = []; + } + obj.options = message.options ? EnumOptions.toAmino(message.options) : undefined; + if (message.reservedRange) { + obj.reserved_range = message.reservedRange.map(e => e ? EnumDescriptorProto_EnumReservedRange.toAmino(e) : undefined); + } else { + obj.reserved_range = []; + } + if (message.reservedName) { + obj.reserved_name = message.reservedName.map(e => e); + } else { + obj.reserved_name = []; + } + return obj; + }, + fromAminoMsg(object: EnumDescriptorProtoAminoMsg): EnumDescriptorProto { + return EnumDescriptorProto.fromAmino(object.value); + }, fromProtoMsg(message: EnumDescriptorProtoProtoMsg): EnumDescriptorProto { return EnumDescriptorProto.decode(message.value); }, @@ -2204,6 +3574,12 @@ export const EnumDescriptorProto_EnumReservedRange = { is(o: any): o is EnumDescriptorProto_EnumReservedRange { return o && (o.$typeUrl === EnumDescriptorProto_EnumReservedRange.typeUrl || typeof o.start === "number" && typeof o.end === "number"); }, + isSDK(o: any): o is EnumDescriptorProto_EnumReservedRange { + return o && (o.$typeUrl === EnumDescriptorProto_EnumReservedRange.typeUrl || typeof o.start === "number" && typeof o.end === "number"); + }, + isAmino(o: any): o is EnumDescriptorProto_EnumReservedRange { + return o && (o.$typeUrl === EnumDescriptorProto_EnumReservedRange.typeUrl || typeof o.start === "number" && typeof o.end === "number"); + }, encode(message: EnumDescriptorProto_EnumReservedRange, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.start !== 0) { writer.uint32(8).int32(message.start); @@ -2251,6 +3627,21 @@ export const EnumDescriptorProto_EnumReservedRange = { message.end = object.end ?? 0; return message; }, + fromAmino(object: EnumDescriptorProto_EnumReservedRangeAmino): EnumDescriptorProto_EnumReservedRange { + return { + start: object.start, + end: object.end + }; + }, + toAmino(message: EnumDescriptorProto_EnumReservedRange): EnumDescriptorProto_EnumReservedRangeAmino { + const obj: any = {}; + obj.start = message.start; + obj.end = message.end; + return obj; + }, + fromAminoMsg(object: EnumDescriptorProto_EnumReservedRangeAminoMsg): EnumDescriptorProto_EnumReservedRange { + return EnumDescriptorProto_EnumReservedRange.fromAmino(object.value); + }, fromProtoMsg(message: EnumDescriptorProto_EnumReservedRangeProtoMsg): EnumDescriptorProto_EnumReservedRange { return EnumDescriptorProto_EnumReservedRange.decode(message.value); }, @@ -2277,6 +3668,12 @@ export const EnumValueDescriptorProto = { is(o: any): o is EnumValueDescriptorProto { return o && (o.$typeUrl === EnumValueDescriptorProto.typeUrl || typeof o.name === "string" && typeof o.number === "number"); }, + isSDK(o: any): o is EnumValueDescriptorProto { + return o && (o.$typeUrl === EnumValueDescriptorProto.typeUrl || typeof o.name === "string" && typeof o.number === "number"); + }, + isAmino(o: any): o is EnumValueDescriptorProto { + return o && (o.$typeUrl === EnumValueDescriptorProto.typeUrl || typeof o.name === "string" && typeof o.number === "number"); + }, encode(message: EnumValueDescriptorProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.name !== "") { writer.uint32(10).string(message.name); @@ -2335,6 +3732,23 @@ export const EnumValueDescriptorProto = { } return message; }, + fromAmino(object: EnumValueDescriptorProtoAmino): EnumValueDescriptorProto { + return { + name: object.name, + number: object.number, + options: object?.options ? EnumValueOptions.fromAmino(object.options) : undefined + }; + }, + toAmino(message: EnumValueDescriptorProto): EnumValueDescriptorProtoAmino { + const obj: any = {}; + obj.name = message.name; + obj.number = message.number; + obj.options = message.options ? EnumValueOptions.toAmino(message.options) : undefined; + return obj; + }, + fromAminoMsg(object: EnumValueDescriptorProtoAminoMsg): EnumValueDescriptorProto { + return EnumValueDescriptorProto.fromAmino(object.value); + }, fromProtoMsg(message: EnumValueDescriptorProtoProtoMsg): EnumValueDescriptorProto { return EnumValueDescriptorProto.decode(message.value); }, @@ -2361,6 +3775,12 @@ export const ServiceDescriptorProto = { is(o: any): o is ServiceDescriptorProto { return o && (o.$typeUrl === ServiceDescriptorProto.typeUrl || typeof o.name === "string" && Array.isArray(o.method) && (!o.method.length || MethodDescriptorProto.is(o.method[0]))); }, + isSDK(o: any): o is ServiceDescriptorProto { + return o && (o.$typeUrl === ServiceDescriptorProto.typeUrl || typeof o.name === "string" && Array.isArray(o.method) && (!o.method.length || MethodDescriptorProto.isSDK(o.method[0]))); + }, + isAmino(o: any): o is ServiceDescriptorProto { + return o && (o.$typeUrl === ServiceDescriptorProto.typeUrl || typeof o.name === "string" && Array.isArray(o.method) && (!o.method.length || MethodDescriptorProto.isAmino(o.method[0]))); + }, encode(message: ServiceDescriptorProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.name !== "") { writer.uint32(10).string(message.name); @@ -2423,6 +3843,27 @@ export const ServiceDescriptorProto = { } return message; }, + fromAmino(object: ServiceDescriptorProtoAmino): ServiceDescriptorProto { + return { + name: object.name, + method: Array.isArray(object?.method) ? object.method.map((e: any) => MethodDescriptorProto.fromAmino(e)) : [], + options: object?.options ? ServiceOptions.fromAmino(object.options) : undefined + }; + }, + toAmino(message: ServiceDescriptorProto): ServiceDescriptorProtoAmino { + const obj: any = {}; + obj.name = message.name; + if (message.method) { + obj.method = message.method.map(e => e ? MethodDescriptorProto.toAmino(e) : undefined); + } else { + obj.method = []; + } + obj.options = message.options ? ServiceOptions.toAmino(message.options) : undefined; + return obj; + }, + fromAminoMsg(object: ServiceDescriptorProtoAminoMsg): ServiceDescriptorProto { + return ServiceDescriptorProto.fromAmino(object.value); + }, fromProtoMsg(message: ServiceDescriptorProtoProtoMsg): ServiceDescriptorProto { return ServiceDescriptorProto.decode(message.value); }, @@ -2452,6 +3893,12 @@ export const MethodDescriptorProto = { is(o: any): o is MethodDescriptorProto { return o && (o.$typeUrl === MethodDescriptorProto.typeUrl || typeof o.name === "string" && typeof o.inputType === "string" && typeof o.outputType === "string" && typeof o.clientStreaming === "boolean" && typeof o.serverStreaming === "boolean"); }, + isSDK(o: any): o is MethodDescriptorProto { + return o && (o.$typeUrl === MethodDescriptorProto.typeUrl || typeof o.name === "string" && typeof o.input_type === "string" && typeof o.output_type === "string" && typeof o.client_streaming === "boolean" && typeof o.server_streaming === "boolean"); + }, + isAmino(o: any): o is MethodDescriptorProto { + return o && (o.$typeUrl === MethodDescriptorProto.typeUrl || typeof o.name === "string" && typeof o.input_type === "string" && typeof o.output_type === "string" && typeof o.client_streaming === "boolean" && typeof o.server_streaming === "boolean"); + }, encode(message: MethodDescriptorProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.name !== "") { writer.uint32(10).string(message.name); @@ -2537,6 +3984,29 @@ export const MethodDescriptorProto = { message.serverStreaming = object.serverStreaming ?? false; return message; }, + fromAmino(object: MethodDescriptorProtoAmino): MethodDescriptorProto { + return { + name: object.name, + inputType: object.input_type, + outputType: object.output_type, + options: object?.options ? MethodOptions.fromAmino(object.options) : undefined, + clientStreaming: object.client_streaming, + serverStreaming: object.server_streaming + }; + }, + toAmino(message: MethodDescriptorProto): MethodDescriptorProtoAmino { + const obj: any = {}; + obj.name = message.name; + obj.input_type = message.inputType; + obj.output_type = message.outputType; + obj.options = message.options ? MethodOptions.toAmino(message.options) : undefined; + obj.client_streaming = message.clientStreaming; + obj.server_streaming = message.serverStreaming; + return obj; + }, + fromAminoMsg(object: MethodDescriptorProtoAminoMsg): MethodDescriptorProto { + return MethodDescriptorProto.fromAmino(object.value); + }, fromProtoMsg(message: MethodDescriptorProtoProtoMsg): MethodDescriptorProto { return MethodDescriptorProto.decode(message.value); }, @@ -2581,6 +4051,12 @@ export const FileOptions = { is(o: any): o is FileOptions { return o && (o.$typeUrl === FileOptions.typeUrl || typeof o.javaPackage === "string" && typeof o.javaOuterClassname === "string" && typeof o.javaMultipleFiles === "boolean" && typeof o.javaGenerateEqualsAndHash === "boolean" && typeof o.javaStringCheckUtf8 === "boolean" && o.optimizeFor && typeof o.goPackage === "string" && typeof o.ccGenericServices === "boolean" && typeof o.javaGenericServices === "boolean" && typeof o.pyGenericServices === "boolean" && typeof o.phpGenericServices === "boolean" && typeof o.deprecated === "boolean" && typeof o.ccEnableArenas === "boolean" && typeof o.objcClassPrefix === "string" && typeof o.csharpNamespace === "string" && typeof o.swiftPrefix === "string" && typeof o.phpClassPrefix === "string" && typeof o.phpNamespace === "string" && typeof o.phpMetadataNamespace === "string" && typeof o.rubyPackage === "string" && Array.isArray(o.uninterpretedOption) && (!o.uninterpretedOption.length || UninterpretedOption.is(o.uninterpretedOption[0]))); }, + isSDK(o: any): o is FileOptions { + return o && (o.$typeUrl === FileOptions.typeUrl || typeof o.java_package === "string" && typeof o.java_outer_classname === "string" && typeof o.java_multiple_files === "boolean" && typeof o.java_generate_equals_and_hash === "boolean" && typeof o.java_string_check_utf8 === "boolean" && o.optimize_for && typeof o.go_package === "string" && typeof o.cc_generic_services === "boolean" && typeof o.java_generic_services === "boolean" && typeof o.py_generic_services === "boolean" && typeof o.php_generic_services === "boolean" && typeof o.deprecated === "boolean" && typeof o.cc_enable_arenas === "boolean" && typeof o.objc_class_prefix === "string" && typeof o.csharp_namespace === "string" && typeof o.swift_prefix === "string" && typeof o.php_class_prefix === "string" && typeof o.php_namespace === "string" && typeof o.php_metadata_namespace === "string" && typeof o.ruby_package === "string" && Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isSDK(o.uninterpreted_option[0]))); + }, + isAmino(o: any): o is FileOptions { + return o && (o.$typeUrl === FileOptions.typeUrl || typeof o.java_package === "string" && typeof o.java_outer_classname === "string" && typeof o.java_multiple_files === "boolean" && typeof o.java_generate_equals_and_hash === "boolean" && typeof o.java_string_check_utf8 === "boolean" && o.optimize_for && typeof o.go_package === "string" && typeof o.cc_generic_services === "boolean" && typeof o.java_generic_services === "boolean" && typeof o.py_generic_services === "boolean" && typeof o.php_generic_services === "boolean" && typeof o.deprecated === "boolean" && typeof o.cc_enable_arenas === "boolean" && typeof o.objc_class_prefix === "string" && typeof o.csharp_namespace === "string" && typeof o.swift_prefix === "string" && typeof o.php_class_prefix === "string" && typeof o.php_namespace === "string" && typeof o.php_metadata_namespace === "string" && typeof o.ruby_package === "string" && Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isAmino(o.uninterpreted_option[0]))); + }, encode(message: FileOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.javaPackage !== "") { writer.uint32(10).string(message.javaPackage); @@ -2803,6 +4279,63 @@ export const FileOptions = { message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; return message; }, + fromAmino(object: FileOptionsAmino): FileOptions { + return { + javaPackage: object.java_package, + javaOuterClassname: object.java_outer_classname, + javaMultipleFiles: object.java_multiple_files, + javaGenerateEqualsAndHash: object.java_generate_equals_and_hash, + javaStringCheckUtf8: object.java_string_check_utf8, + optimizeFor: isSet(object.optimize_for) ? fileOptions_OptimizeModeFromJSON(object.optimize_for) : -1, + goPackage: object.go_package, + ccGenericServices: object.cc_generic_services, + javaGenericServices: object.java_generic_services, + pyGenericServices: object.py_generic_services, + phpGenericServices: object.php_generic_services, + deprecated: object.deprecated, + ccEnableArenas: object.cc_enable_arenas, + objcClassPrefix: object.objc_class_prefix, + csharpNamespace: object.csharp_namespace, + swiftPrefix: object.swift_prefix, + phpClassPrefix: object.php_class_prefix, + phpNamespace: object.php_namespace, + phpMetadataNamespace: object.php_metadata_namespace, + rubyPackage: object.ruby_package, + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromAmino(e)) : [] + }; + }, + toAmino(message: FileOptions): FileOptionsAmino { + const obj: any = {}; + obj.java_package = message.javaPackage; + obj.java_outer_classname = message.javaOuterClassname; + obj.java_multiple_files = message.javaMultipleFiles; + obj.java_generate_equals_and_hash = message.javaGenerateEqualsAndHash; + obj.java_string_check_utf8 = message.javaStringCheckUtf8; + obj.optimize_for = message.optimizeFor; + obj.go_package = message.goPackage; + obj.cc_generic_services = message.ccGenericServices; + obj.java_generic_services = message.javaGenericServices; + obj.py_generic_services = message.pyGenericServices; + obj.php_generic_services = message.phpGenericServices; + obj.deprecated = message.deprecated; + obj.cc_enable_arenas = message.ccEnableArenas; + obj.objc_class_prefix = message.objcClassPrefix; + obj.csharp_namespace = message.csharpNamespace; + obj.swift_prefix = message.swiftPrefix; + obj.php_class_prefix = message.phpClassPrefix; + obj.php_namespace = message.phpNamespace; + obj.php_metadata_namespace = message.phpMetadataNamespace; + obj.ruby_package = message.rubyPackage; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAminoMsg(object: FileOptionsAminoMsg): FileOptions { + return FileOptions.fromAmino(object.value); + }, fromProtoMsg(message: FileOptionsProtoMsg): FileOptions { return FileOptions.decode(message.value); }, @@ -2831,6 +4364,12 @@ export const MessageOptions = { is(o: any): o is MessageOptions { return o && (o.$typeUrl === MessageOptions.typeUrl || typeof o.messageSetWireFormat === "boolean" && typeof o.noStandardDescriptorAccessor === "boolean" && typeof o.deprecated === "boolean" && typeof o.mapEntry === "boolean" && Array.isArray(o.uninterpretedOption) && (!o.uninterpretedOption.length || UninterpretedOption.is(o.uninterpretedOption[0]))); }, + isSDK(o: any): o is MessageOptions { + return o && (o.$typeUrl === MessageOptions.typeUrl || typeof o.message_set_wire_format === "boolean" && typeof o.no_standard_descriptor_accessor === "boolean" && typeof o.deprecated === "boolean" && typeof o.map_entry === "boolean" && Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isSDK(o.uninterpreted_option[0]))); + }, + isAmino(o: any): o is MessageOptions { + return o && (o.$typeUrl === MessageOptions.typeUrl || typeof o.message_set_wire_format === "boolean" && typeof o.no_standard_descriptor_accessor === "boolean" && typeof o.deprecated === "boolean" && typeof o.map_entry === "boolean" && Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isAmino(o.uninterpreted_option[0]))); + }, encode(message: MessageOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.messageSetWireFormat === true) { writer.uint32(8).bool(message.messageSetWireFormat); @@ -2909,6 +4448,31 @@ export const MessageOptions = { message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; return message; }, + fromAmino(object: MessageOptionsAmino): MessageOptions { + return { + messageSetWireFormat: object.message_set_wire_format, + noStandardDescriptorAccessor: object.no_standard_descriptor_accessor, + deprecated: object.deprecated, + mapEntry: object.map_entry, + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromAmino(e)) : [] + }; + }, + toAmino(message: MessageOptions): MessageOptionsAmino { + const obj: any = {}; + obj.message_set_wire_format = message.messageSetWireFormat; + obj.no_standard_descriptor_accessor = message.noStandardDescriptorAccessor; + obj.deprecated = message.deprecated; + obj.map_entry = message.mapEntry; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAminoMsg(object: MessageOptionsAminoMsg): MessageOptions { + return MessageOptions.fromAmino(object.value); + }, fromProtoMsg(message: MessageOptionsProtoMsg): MessageOptions { return MessageOptions.decode(message.value); }, @@ -2939,6 +4503,12 @@ export const FieldOptions = { is(o: any): o is FieldOptions { return o && (o.$typeUrl === FieldOptions.typeUrl || o.ctype && typeof o.packed === "boolean" && o.jstype && typeof o.lazy === "boolean" && typeof o.deprecated === "boolean" && typeof o.weak === "boolean" && Array.isArray(o.uninterpretedOption) && (!o.uninterpretedOption.length || UninterpretedOption.is(o.uninterpretedOption[0]))); }, + isSDK(o: any): o is FieldOptions { + return o && (o.$typeUrl === FieldOptions.typeUrl || o.ctype && typeof o.packed === "boolean" && o.jstype && typeof o.lazy === "boolean" && typeof o.deprecated === "boolean" && typeof o.weak === "boolean" && Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isSDK(o.uninterpreted_option[0]))); + }, + isAmino(o: any): o is FieldOptions { + return o && (o.$typeUrl === FieldOptions.typeUrl || o.ctype && typeof o.packed === "boolean" && o.jstype && typeof o.lazy === "boolean" && typeof o.deprecated === "boolean" && typeof o.weak === "boolean" && Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isAmino(o.uninterpreted_option[0]))); + }, encode(message: FieldOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.ctype !== 1) { writer.uint32(8).int32(message.ctype); @@ -3035,6 +4605,35 @@ export const FieldOptions = { message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; return message; }, + fromAmino(object: FieldOptionsAmino): FieldOptions { + return { + ctype: isSet(object.ctype) ? fieldOptions_CTypeFromJSON(object.ctype) : -1, + packed: object.packed, + jstype: isSet(object.jstype) ? fieldOptions_JSTypeFromJSON(object.jstype) : -1, + lazy: object.lazy, + deprecated: object.deprecated, + weak: object.weak, + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromAmino(e)) : [] + }; + }, + toAmino(message: FieldOptions): FieldOptionsAmino { + const obj: any = {}; + obj.ctype = message.ctype; + obj.packed = message.packed; + obj.jstype = message.jstype; + obj.lazy = message.lazy; + obj.deprecated = message.deprecated; + obj.weak = message.weak; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAminoMsg(object: FieldOptionsAminoMsg): FieldOptions { + return FieldOptions.fromAmino(object.value); + }, fromProtoMsg(message: FieldOptionsProtoMsg): FieldOptions { return FieldOptions.decode(message.value); }, @@ -3059,6 +4658,12 @@ export const OneofOptions = { is(o: any): o is OneofOptions { return o && (o.$typeUrl === OneofOptions.typeUrl || Array.isArray(o.uninterpretedOption) && (!o.uninterpretedOption.length || UninterpretedOption.is(o.uninterpretedOption[0]))); }, + isSDK(o: any): o is OneofOptions { + return o && (o.$typeUrl === OneofOptions.typeUrl || Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isSDK(o.uninterpreted_option[0]))); + }, + isAmino(o: any): o is OneofOptions { + return o && (o.$typeUrl === OneofOptions.typeUrl || Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isAmino(o.uninterpreted_option[0]))); + }, encode(message: OneofOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); @@ -3101,6 +4706,23 @@ export const OneofOptions = { message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; return message; }, + fromAmino(object: OneofOptionsAmino): OneofOptions { + return { + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromAmino(e)) : [] + }; + }, + toAmino(message: OneofOptions): OneofOptionsAmino { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAminoMsg(object: OneofOptionsAminoMsg): OneofOptions { + return OneofOptions.fromAmino(object.value); + }, fromProtoMsg(message: OneofOptionsProtoMsg): OneofOptions { return OneofOptions.decode(message.value); }, @@ -3127,6 +4749,12 @@ export const EnumOptions = { is(o: any): o is EnumOptions { return o && (o.$typeUrl === EnumOptions.typeUrl || typeof o.allowAlias === "boolean" && typeof o.deprecated === "boolean" && Array.isArray(o.uninterpretedOption) && (!o.uninterpretedOption.length || UninterpretedOption.is(o.uninterpretedOption[0]))); }, + isSDK(o: any): o is EnumOptions { + return o && (o.$typeUrl === EnumOptions.typeUrl || typeof o.allow_alias === "boolean" && typeof o.deprecated === "boolean" && Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isSDK(o.uninterpreted_option[0]))); + }, + isAmino(o: any): o is EnumOptions { + return o && (o.$typeUrl === EnumOptions.typeUrl || typeof o.allow_alias === "boolean" && typeof o.deprecated === "boolean" && Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isAmino(o.uninterpreted_option[0]))); + }, encode(message: EnumOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.allowAlias === true) { writer.uint32(16).bool(message.allowAlias); @@ -3187,6 +4815,27 @@ export const EnumOptions = { message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; return message; }, + fromAmino(object: EnumOptionsAmino): EnumOptions { + return { + allowAlias: object.allow_alias, + deprecated: object.deprecated, + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromAmino(e)) : [] + }; + }, + toAmino(message: EnumOptions): EnumOptionsAmino { + const obj: any = {}; + obj.allow_alias = message.allowAlias; + obj.deprecated = message.deprecated; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAminoMsg(object: EnumOptionsAminoMsg): EnumOptions { + return EnumOptions.fromAmino(object.value); + }, fromProtoMsg(message: EnumOptionsProtoMsg): EnumOptions { return EnumOptions.decode(message.value); }, @@ -3212,6 +4861,12 @@ export const EnumValueOptions = { is(o: any): o is EnumValueOptions { return o && (o.$typeUrl === EnumValueOptions.typeUrl || typeof o.deprecated === "boolean" && Array.isArray(o.uninterpretedOption) && (!o.uninterpretedOption.length || UninterpretedOption.is(o.uninterpretedOption[0]))); }, + isSDK(o: any): o is EnumValueOptions { + return o && (o.$typeUrl === EnumValueOptions.typeUrl || typeof o.deprecated === "boolean" && Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isSDK(o.uninterpreted_option[0]))); + }, + isAmino(o: any): o is EnumValueOptions { + return o && (o.$typeUrl === EnumValueOptions.typeUrl || typeof o.deprecated === "boolean" && Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isAmino(o.uninterpreted_option[0]))); + }, encode(message: EnumValueOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.deprecated === true) { writer.uint32(8).bool(message.deprecated); @@ -3263,6 +4918,25 @@ export const EnumValueOptions = { message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; return message; }, + fromAmino(object: EnumValueOptionsAmino): EnumValueOptions { + return { + deprecated: object.deprecated, + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromAmino(e)) : [] + }; + }, + toAmino(message: EnumValueOptions): EnumValueOptionsAmino { + const obj: any = {}; + obj.deprecated = message.deprecated; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAminoMsg(object: EnumValueOptionsAminoMsg): EnumValueOptions { + return EnumValueOptions.fromAmino(object.value); + }, fromProtoMsg(message: EnumValueOptionsProtoMsg): EnumValueOptions { return EnumValueOptions.decode(message.value); }, @@ -3288,6 +4962,12 @@ export const ServiceOptions = { is(o: any): o is ServiceOptions { return o && (o.$typeUrl === ServiceOptions.typeUrl || typeof o.deprecated === "boolean" && Array.isArray(o.uninterpretedOption) && (!o.uninterpretedOption.length || UninterpretedOption.is(o.uninterpretedOption[0]))); }, + isSDK(o: any): o is ServiceOptions { + return o && (o.$typeUrl === ServiceOptions.typeUrl || typeof o.deprecated === "boolean" && Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isSDK(o.uninterpreted_option[0]))); + }, + isAmino(o: any): o is ServiceOptions { + return o && (o.$typeUrl === ServiceOptions.typeUrl || typeof o.deprecated === "boolean" && Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isAmino(o.uninterpreted_option[0]))); + }, encode(message: ServiceOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.deprecated === true) { writer.uint32(264).bool(message.deprecated); @@ -3339,6 +5019,25 @@ export const ServiceOptions = { message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; return message; }, + fromAmino(object: ServiceOptionsAmino): ServiceOptions { + return { + deprecated: object.deprecated, + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromAmino(e)) : [] + }; + }, + toAmino(message: ServiceOptions): ServiceOptionsAmino { + const obj: any = {}; + obj.deprecated = message.deprecated; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAminoMsg(object: ServiceOptionsAminoMsg): ServiceOptions { + return ServiceOptions.fromAmino(object.value); + }, fromProtoMsg(message: ServiceOptionsProtoMsg): ServiceOptions { return ServiceOptions.decode(message.value); }, @@ -3365,6 +5064,12 @@ export const MethodOptions = { is(o: any): o is MethodOptions { return o && (o.$typeUrl === MethodOptions.typeUrl || typeof o.deprecated === "boolean" && o.idempotencyLevel && Array.isArray(o.uninterpretedOption) && (!o.uninterpretedOption.length || UninterpretedOption.is(o.uninterpretedOption[0]))); }, + isSDK(o: any): o is MethodOptions { + return o && (o.$typeUrl === MethodOptions.typeUrl || typeof o.deprecated === "boolean" && o.idempotency_level && Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isSDK(o.uninterpreted_option[0]))); + }, + isAmino(o: any): o is MethodOptions { + return o && (o.$typeUrl === MethodOptions.typeUrl || typeof o.deprecated === "boolean" && o.idempotency_level && Array.isArray(o.uninterpreted_option) && (!o.uninterpreted_option.length || UninterpretedOption.isAmino(o.uninterpreted_option[0]))); + }, encode(message: MethodOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.deprecated === true) { writer.uint32(264).bool(message.deprecated); @@ -3425,6 +5130,27 @@ export const MethodOptions = { message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; return message; }, + fromAmino(object: MethodOptionsAmino): MethodOptions { + return { + deprecated: object.deprecated, + idempotencyLevel: isSet(object.idempotency_level) ? methodOptions_IdempotencyLevelFromJSON(object.idempotency_level) : -1, + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromAmino(e)) : [] + }; + }, + toAmino(message: MethodOptions): MethodOptionsAmino { + const obj: any = {}; + obj.deprecated = message.deprecated; + obj.idempotency_level = message.idempotencyLevel; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAminoMsg(object: MethodOptionsAminoMsg): MethodOptions { + return MethodOptions.fromAmino(object.value); + }, fromProtoMsg(message: MethodOptionsProtoMsg): MethodOptions { return MethodOptions.decode(message.value); }, @@ -3455,6 +5181,12 @@ export const UninterpretedOption = { is(o: any): o is UninterpretedOption { return o && (o.$typeUrl === UninterpretedOption.typeUrl || Array.isArray(o.name) && (!o.name.length || UninterpretedOption_NamePart.is(o.name[0])) && typeof o.identifierValue === "string" && typeof o.positiveIntValue === "bigint" && typeof o.negativeIntValue === "bigint" && typeof o.doubleValue === "number" && o.stringValue instanceof Uint8Array && typeof o.aggregateValue === "string"); }, + isSDK(o: any): o is UninterpretedOption { + return o && (o.$typeUrl === UninterpretedOption.typeUrl || Array.isArray(o.name) && (!o.name.length || UninterpretedOption_NamePart.isSDK(o.name[0])) && typeof o.identifier_value === "string" && typeof o.positive_int_value === "bigint" && typeof o.negative_int_value === "bigint" && typeof o.double_value === "number" && o.string_value instanceof Uint8Array && typeof o.aggregate_value === "string"); + }, + isAmino(o: any): o is UninterpretedOption { + return o && (o.$typeUrl === UninterpretedOption.typeUrl || Array.isArray(o.name) && (!o.name.length || UninterpretedOption_NamePart.isAmino(o.name[0])) && typeof o.identifier_value === "string" && typeof o.positive_int_value === "bigint" && typeof o.negative_int_value === "bigint" && typeof o.double_value === "number" && o.string_value instanceof Uint8Array && typeof o.aggregate_value === "string"); + }, encode(message: UninterpretedOption, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { for (const v of message.name) { UninterpretedOption_NamePart.encode(v!, writer.uint32(18).fork()).ldelim(); @@ -3555,6 +5287,35 @@ export const UninterpretedOption = { message.aggregateValue = object.aggregateValue ?? ""; return message; }, + fromAmino(object: UninterpretedOptionAmino): UninterpretedOption { + return { + name: Array.isArray(object?.name) ? object.name.map((e: any) => UninterpretedOption_NamePart.fromAmino(e)) : [], + identifierValue: object.identifier_value, + positiveIntValue: BigInt(object.positive_int_value), + negativeIntValue: BigInt(object.negative_int_value), + doubleValue: object.double_value, + stringValue: object.string_value, + aggregateValue: object.aggregate_value + }; + }, + toAmino(message: UninterpretedOption): UninterpretedOptionAmino { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map(e => e ? UninterpretedOption_NamePart.toAmino(e) : undefined); + } else { + obj.name = []; + } + obj.identifier_value = message.identifierValue; + obj.positive_int_value = message.positiveIntValue ? message.positiveIntValue.toString() : undefined; + obj.negative_int_value = message.negativeIntValue ? message.negativeIntValue.toString() : undefined; + obj.double_value = message.doubleValue; + obj.string_value = message.stringValue; + obj.aggregate_value = message.aggregateValue; + return obj; + }, + fromAminoMsg(object: UninterpretedOptionAminoMsg): UninterpretedOption { + return UninterpretedOption.fromAmino(object.value); + }, fromProtoMsg(message: UninterpretedOptionProtoMsg): UninterpretedOption { return UninterpretedOption.decode(message.value); }, @@ -3580,6 +5341,12 @@ export const UninterpretedOption_NamePart = { is(o: any): o is UninterpretedOption_NamePart { return o && (o.$typeUrl === UninterpretedOption_NamePart.typeUrl || typeof o.namePart === "string" && typeof o.isExtension === "boolean"); }, + isSDK(o: any): o is UninterpretedOption_NamePart { + return o && (o.$typeUrl === UninterpretedOption_NamePart.typeUrl || typeof o.name_part === "string" && typeof o.is_extension === "boolean"); + }, + isAmino(o: any): o is UninterpretedOption_NamePart { + return o && (o.$typeUrl === UninterpretedOption_NamePart.typeUrl || typeof o.name_part === "string" && typeof o.is_extension === "boolean"); + }, encode(message: UninterpretedOption_NamePart, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.namePart !== "") { writer.uint32(10).string(message.namePart); @@ -3627,6 +5394,21 @@ export const UninterpretedOption_NamePart = { message.isExtension = object.isExtension ?? false; return message; }, + fromAmino(object: UninterpretedOption_NamePartAmino): UninterpretedOption_NamePart { + return { + namePart: object.name_part, + isExtension: object.is_extension + }; + }, + toAmino(message: UninterpretedOption_NamePart): UninterpretedOption_NamePartAmino { + const obj: any = {}; + obj.name_part = message.namePart; + obj.is_extension = message.isExtension; + return obj; + }, + fromAminoMsg(object: UninterpretedOption_NamePartAminoMsg): UninterpretedOption_NamePart { + return UninterpretedOption_NamePart.fromAmino(object.value); + }, fromProtoMsg(message: UninterpretedOption_NamePartProtoMsg): UninterpretedOption_NamePart { return UninterpretedOption_NamePart.decode(message.value); }, @@ -3651,6 +5433,12 @@ export const SourceCodeInfo = { is(o: any): o is SourceCodeInfo { return o && (o.$typeUrl === SourceCodeInfo.typeUrl || Array.isArray(o.location) && (!o.location.length || SourceCodeInfo_Location.is(o.location[0]))); }, + isSDK(o: any): o is SourceCodeInfo { + return o && (o.$typeUrl === SourceCodeInfo.typeUrl || Array.isArray(o.location) && (!o.location.length || SourceCodeInfo_Location.isSDK(o.location[0]))); + }, + isAmino(o: any): o is SourceCodeInfo { + return o && (o.$typeUrl === SourceCodeInfo.typeUrl || Array.isArray(o.location) && (!o.location.length || SourceCodeInfo_Location.isAmino(o.location[0]))); + }, encode(message: SourceCodeInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { for (const v of message.location) { SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); @@ -3693,6 +5481,23 @@ export const SourceCodeInfo = { message.location = object.location?.map(e => SourceCodeInfo_Location.fromPartial(e)) || []; return message; }, + fromAmino(object: SourceCodeInfoAmino): SourceCodeInfo { + return { + location: Array.isArray(object?.location) ? object.location.map((e: any) => SourceCodeInfo_Location.fromAmino(e)) : [] + }; + }, + toAmino(message: SourceCodeInfo): SourceCodeInfoAmino { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map(e => e ? SourceCodeInfo_Location.toAmino(e) : undefined); + } else { + obj.location = []; + } + return obj; + }, + fromAminoMsg(object: SourceCodeInfoAminoMsg): SourceCodeInfo { + return SourceCodeInfo.fromAmino(object.value); + }, fromProtoMsg(message: SourceCodeInfoProtoMsg): SourceCodeInfo { return SourceCodeInfo.decode(message.value); }, @@ -3721,6 +5526,12 @@ export const SourceCodeInfo_Location = { is(o: any): o is SourceCodeInfo_Location { return o && (o.$typeUrl === SourceCodeInfo_Location.typeUrl || Array.isArray(o.path) && (!o.path.length || typeof o.path[0] === "number") && Array.isArray(o.span) && (!o.span.length || typeof o.span[0] === "number") && typeof o.leadingComments === "string" && typeof o.trailingComments === "string" && Array.isArray(o.leadingDetachedComments) && (!o.leadingDetachedComments.length || typeof o.leadingDetachedComments[0] === "string")); }, + isSDK(o: any): o is SourceCodeInfo_Location { + return o && (o.$typeUrl === SourceCodeInfo_Location.typeUrl || Array.isArray(o.path) && (!o.path.length || typeof o.path[0] === "number") && Array.isArray(o.span) && (!o.span.length || typeof o.span[0] === "number") && typeof o.leading_comments === "string" && typeof o.trailing_comments === "string" && Array.isArray(o.leading_detached_comments) && (!o.leading_detached_comments.length || typeof o.leading_detached_comments[0] === "string")); + }, + isAmino(o: any): o is SourceCodeInfo_Location { + return o && (o.$typeUrl === SourceCodeInfo_Location.typeUrl || Array.isArray(o.path) && (!o.path.length || typeof o.path[0] === "number") && Array.isArray(o.span) && (!o.span.length || typeof o.span[0] === "number") && typeof o.leading_comments === "string" && typeof o.trailing_comments === "string" && Array.isArray(o.leading_detached_comments) && (!o.leading_detached_comments.length || typeof o.leading_detached_comments[0] === "string")); + }, encode(message: SourceCodeInfo_Location, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { writer.uint32(10).fork(); for (const v of message.path) { @@ -3825,6 +5636,39 @@ export const SourceCodeInfo_Location = { message.leadingDetachedComments = object.leadingDetachedComments?.map(e => e) || []; return message; }, + fromAmino(object: SourceCodeInfo_LocationAmino): SourceCodeInfo_Location { + return { + path: Array.isArray(object?.path) ? object.path.map((e: any) => e) : [], + span: Array.isArray(object?.span) ? object.span.map((e: any) => e) : [], + leadingComments: object.leading_comments, + trailingComments: object.trailing_comments, + leadingDetachedComments: Array.isArray(object?.leading_detached_comments) ? object.leading_detached_comments.map((e: any) => e) : [] + }; + }, + toAmino(message: SourceCodeInfo_Location): SourceCodeInfo_LocationAmino { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map(e => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map(e => e); + } else { + obj.span = []; + } + obj.leading_comments = message.leadingComments; + obj.trailing_comments = message.trailingComments; + if (message.leadingDetachedComments) { + obj.leading_detached_comments = message.leadingDetachedComments.map(e => e); + } else { + obj.leading_detached_comments = []; + } + return obj; + }, + fromAminoMsg(object: SourceCodeInfo_LocationAminoMsg): SourceCodeInfo_Location { + return SourceCodeInfo_Location.fromAmino(object.value); + }, fromProtoMsg(message: SourceCodeInfo_LocationProtoMsg): SourceCodeInfo_Location { return SourceCodeInfo_Location.decode(message.value); }, @@ -3849,6 +5693,12 @@ export const GeneratedCodeInfo = { is(o: any): o is GeneratedCodeInfo { return o && (o.$typeUrl === GeneratedCodeInfo.typeUrl || Array.isArray(o.annotation) && (!o.annotation.length || GeneratedCodeInfo_Annotation.is(o.annotation[0]))); }, + isSDK(o: any): o is GeneratedCodeInfo { + return o && (o.$typeUrl === GeneratedCodeInfo.typeUrl || Array.isArray(o.annotation) && (!o.annotation.length || GeneratedCodeInfo_Annotation.isSDK(o.annotation[0]))); + }, + isAmino(o: any): o is GeneratedCodeInfo { + return o && (o.$typeUrl === GeneratedCodeInfo.typeUrl || Array.isArray(o.annotation) && (!o.annotation.length || GeneratedCodeInfo_Annotation.isAmino(o.annotation[0]))); + }, encode(message: GeneratedCodeInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { for (const v of message.annotation) { GeneratedCodeInfo_Annotation.encode(v!, writer.uint32(10).fork()).ldelim(); @@ -3891,6 +5741,23 @@ export const GeneratedCodeInfo = { message.annotation = object.annotation?.map(e => GeneratedCodeInfo_Annotation.fromPartial(e)) || []; return message; }, + fromAmino(object: GeneratedCodeInfoAmino): GeneratedCodeInfo { + return { + annotation: Array.isArray(object?.annotation) ? object.annotation.map((e: any) => GeneratedCodeInfo_Annotation.fromAmino(e)) : [] + }; + }, + toAmino(message: GeneratedCodeInfo): GeneratedCodeInfoAmino { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map(e => e ? GeneratedCodeInfo_Annotation.toAmino(e) : undefined); + } else { + obj.annotation = []; + } + return obj; + }, + fromAminoMsg(object: GeneratedCodeInfoAminoMsg): GeneratedCodeInfo { + return GeneratedCodeInfo.fromAmino(object.value); + }, fromProtoMsg(message: GeneratedCodeInfoProtoMsg): GeneratedCodeInfo { return GeneratedCodeInfo.decode(message.value); }, @@ -3918,6 +5785,12 @@ export const GeneratedCodeInfo_Annotation = { is(o: any): o is GeneratedCodeInfo_Annotation { return o && (o.$typeUrl === GeneratedCodeInfo_Annotation.typeUrl || Array.isArray(o.path) && (!o.path.length || typeof o.path[0] === "number") && typeof o.sourceFile === "string" && typeof o.begin === "number" && typeof o.end === "number"); }, + isSDK(o: any): o is GeneratedCodeInfo_Annotation { + return o && (o.$typeUrl === GeneratedCodeInfo_Annotation.typeUrl || Array.isArray(o.path) && (!o.path.length || typeof o.path[0] === "number") && typeof o.source_file === "string" && typeof o.begin === "number" && typeof o.end === "number"); + }, + isAmino(o: any): o is GeneratedCodeInfo_Annotation { + return o && (o.$typeUrl === GeneratedCodeInfo_Annotation.typeUrl || Array.isArray(o.path) && (!o.path.length || typeof o.path[0] === "number") && typeof o.source_file === "string" && typeof o.begin === "number" && typeof o.end === "number"); + }, encode(message: GeneratedCodeInfo_Annotation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { writer.uint32(10).fork(); for (const v of message.path) { @@ -3996,6 +5869,29 @@ export const GeneratedCodeInfo_Annotation = { message.end = object.end ?? 0; return message; }, + fromAmino(object: GeneratedCodeInfo_AnnotationAmino): GeneratedCodeInfo_Annotation { + return { + path: Array.isArray(object?.path) ? object.path.map((e: any) => e) : [], + sourceFile: object.source_file, + begin: object.begin, + end: object.end + }; + }, + toAmino(message: GeneratedCodeInfo_Annotation): GeneratedCodeInfo_AnnotationAmino { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map(e => e); + } else { + obj.path = []; + } + obj.source_file = message.sourceFile; + obj.begin = message.begin; + obj.end = message.end; + return obj; + }, + fromAminoMsg(object: GeneratedCodeInfo_AnnotationAminoMsg): GeneratedCodeInfo_Annotation { + return GeneratedCodeInfo_Annotation.fromAmino(object.value); + }, fromProtoMsg(message: GeneratedCodeInfo_AnnotationProtoMsg): GeneratedCodeInfo_Annotation { return GeneratedCodeInfo_Annotation.decode(message.value); }, diff --git a/__fixtures__/misc/output-impl-interfaces-gen/google/protobuf/timestamp.ts b/__fixtures__/misc/output-impl-interfaces-gen/google/protobuf/timestamp.ts index 1c17fd3bb..9565cf066 100644 --- a/__fixtures__/misc/output-impl-interfaces-gen/google/protobuf/timestamp.ts +++ b/__fixtures__/misc/output-impl-interfaces-gen/google/protobuf/timestamp.ts @@ -1,5 +1,5 @@ import { BinaryReader, BinaryWriter } from "../../binary"; -import { isSet, DeepPartial } from "../../helpers"; +import { isSet, DeepPartial, fromJsonTimestamp, fromTimestamp } from "../../helpers"; import { GlobalDecoderRegistry } from "../../registry"; export const protobufPackage = "google.protobuf"; /** @@ -105,6 +105,183 @@ export interface TimestampProtoMsg { typeUrl: "/google.protobuf.Timestamp"; value: Uint8Array; } +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export type TimestampAmino = string; +export interface TimestampAminoMsg { + type: "/google.protobuf.Timestamp"; + value: TimestampAmino; +} +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface TimestampSDKType { + seconds: bigint; + nanos: number; +} function createBaseTimestamp(): Timestamp { return { seconds: BigInt(0), @@ -116,6 +293,12 @@ export const Timestamp = { is(o: any): o is Timestamp { return o && (o.$typeUrl === Timestamp.typeUrl || typeof o.seconds === "bigint" && typeof o.nanos === "number"); }, + isSDK(o: any): o is Timestamp { + return o && (o.$typeUrl === Timestamp.typeUrl || typeof o.seconds === "bigint" && typeof o.nanos === "number"); + }, + isAmino(o: any): o is Timestamp { + return o && (o.$typeUrl === Timestamp.typeUrl || typeof o.seconds === "bigint" && typeof o.nanos === "number"); + }, encode(message: Timestamp, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.seconds !== BigInt(0)) { writer.uint32(8).int64(message.seconds); @@ -165,6 +348,15 @@ export const Timestamp = { message.nanos = object.nanos ?? 0; return message; }, + fromAmino(object: TimestampAmino): Timestamp { + return fromJsonTimestamp(object); + }, + toAmino(message: Timestamp): TimestampAmino { + return fromTimestamp(message).toISOString().replace(/\.\d+Z$/, "Z"); + }, + fromAminoMsg(object: TimestampAminoMsg): Timestamp { + return Timestamp.fromAmino(object.value); + }, fromProtoMsg(message: TimestampProtoMsg): Timestamp { return Timestamp.decode(message.value); }, diff --git a/packages/ast/src/encoding/__tests__/__snapshots__/misc.overall.test.ts.snap b/packages/ast/src/encoding/__tests__/__snapshots__/misc.overall.test.ts.snap index e7fc22b17..ed09e821e 100644 --- a/packages/ast/src/encoding/__tests__/__snapshots__/misc.overall.test.ts.snap +++ b/packages/ast/src/encoding/__tests__/__snapshots__/misc.overall.test.ts.snap @@ -6,6 +6,12 @@ exports[`misc/eval_request date 1`] = ` is(o: any): o is EvalRequest { return o && (o.$typeUrl === EvalRequest.typeUrl || o.bindings && o.refs && typeof o.testNum === "number" && typeof o.testString === "string" && typeof o.testBool === "boolean" && Array.isArray(o.testArray) && (!o.testArray.length || typeof o.testArray[0] === "string")); }, + isSDK(o: any): o is EvalRequest { + return o && (o.$typeUrl === EvalRequest.typeUrl || o.bindings && o.refs && typeof o.test_num === "number" && typeof o.test_string === "string" && typeof o.test_bool === "boolean" && Array.isArray(o.test_array) && (!o.test_array.length || typeof o.test_array[0] === "string")); + }, + isAmino(o: any): o is EvalRequest { + return o && (o.$typeUrl === EvalRequest.typeUrl || o.bindings && o.refs && typeof o.test_num === "number" && typeof o.test_string === "string" && typeof o.test_bool === "boolean" && Array.isArray(o.test_array) && (!o.test_array.length || typeof o.test_array[0] === "string")); + }, encode(message: EvalRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { Object.entries(message.bindings).forEach(([key, value]) => { EvalRequest_BindingsEntry.encode({ @@ -290,6 +296,12 @@ exports[`misc/eval_request timestamp 1`] = ` is(o: any): o is EvalRequest { return o && (o.$typeUrl === EvalRequest.typeUrl || o.bindings && o.refs && typeof o.testNum === "number" && typeof o.testString === "string" && typeof o.testBool === "boolean" && Array.isArray(o.testArray) && (!o.testArray.length || typeof o.testArray[0] === "string")); }, + isSDK(o: any): o is EvalRequest { + return o && (o.$typeUrl === EvalRequest.typeUrl || o.bindings && o.refs && typeof o.test_num === "number" && typeof o.test_string === "string" && typeof o.test_bool === "boolean" && Array.isArray(o.test_array) && (!o.test_array.length || typeof o.test_array[0] === "string")); + }, + isAmino(o: any): o is EvalRequest { + return o && (o.$typeUrl === EvalRequest.typeUrl || o.bindings && o.refs && typeof o.test_num === "number" && typeof o.test_string === "string" && typeof o.test_bool === "boolean" && Array.isArray(o.test_array) && (!o.test_array.length || typeof o.test_array[0] === "string")); + }, encode(message: EvalRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { Object.entries(message.bindings).forEach(([key, value]) => { EvalRequest_BindingsEntry.encode({ diff --git a/packages/ast/src/encoding/object.ts b/packages/ast/src/encoding/object.ts index bdc9922c5..73e61d762 100644 --- a/packages/ast/src/encoding/object.ts +++ b/packages/ast/src/encoding/object.ts @@ -12,7 +12,7 @@ import { fromSDKMethod } from './proto/from-sdk'; import { ProtoParseContext } from './context'; import { createAminoTypeProperty, createTypeUrlProperty, fromProtoMsgMethod, fromSDKJSONMethod, toProtoMethod, toProtoMsgMethod } from './proto'; import { isMethod } from './proto/is'; -import { getAminoFieldName, getSdkFieldName } from 'src/utils'; +import { getAminoFieldName, getSdkFieldName } from '../utils'; export const createObjectWithMethods = ( context: ProtoParseContext, @@ -24,8 +24,8 @@ export const createObjectWithMethods = ( ( context.pluginValue('prototypes.addTypeUrlToObjects') || context.pluginValue('interfaces.enabled') && context.pluginValue('interfaces.useGlobalDecoderRegistry') ) && createTypeUrlProperty(context, proto), context.pluginValue('prototypes.addAminoTypeToObjects') && createAminoTypeProperty(context, proto), context.pluginValue('interfaces.enabled') && context.pluginValue('interfaces.useGlobalDecoderRegistry') && isMethod({context, name, proto}), - context.pluginValue('interfaces.enabled') && context.pluginValue('interfaces.useGlobalDecoderRegistry') && context.pluginValue('useSDKTypes') && isMethod({context, name, proto, getFieldName: getSdkFieldName}), - context.pluginValue('interfaces.enabled') && context.pluginValue('interfaces.useGlobalDecoderRegistry') && context.pluginValue('aminoEncoding.enabled') && !context.pluginValue('aminoEncoding.useLegacyInlineEncoding') && isMethod({context, name, proto, getFieldName: getAminoFieldName}), + context.pluginValue('interfaces.enabled') && context.pluginValue('interfaces.useGlobalDecoderRegistry') && context.pluginValue('useSDKTypes') && isMethod({context, name, proto, methodName: "isSDK", getFieldName: getSdkFieldName}), + context.pluginValue('interfaces.enabled') && context.pluginValue('interfaces.useGlobalDecoderRegistry') && context.pluginValue('aminoEncoding.enabled') && !context.pluginValue('aminoEncoding.useLegacyInlineEncoding') && isMethod({context, name, proto, methodName: "isAmino", getFieldName: getAminoFieldName}), context.pluginValue('prototypes.methods.encode') && encodeMethod(context, name, proto), context.pluginValue('prototypes.methods.decode') && decodeMethod(context, name, proto), context.pluginValue('prototypes.methods.fromJSON') && fromJSONMethod(context, name, proto), diff --git a/packages/ast/src/encoding/proto/is/index.ts b/packages/ast/src/encoding/proto/is/index.ts index 30c76de4d..1033e5167 100644 --- a/packages/ast/src/encoding/proto/is/index.ts +++ b/packages/ast/src/encoding/proto/is/index.ts @@ -52,10 +52,11 @@ export const createFieldExistingTest = (args: { export const createProtoTypeComparison = (args: { context: ProtoParseContext; + methodName: string; fieldName: t.Expression; field: ProtoField; }) => { - const { context, fieldName, field } = args; + const { context, fieldName, field, methodName } = args; switch (field.type) { case "google.protobuf.Duration": @@ -107,7 +108,7 @@ export const createProtoTypeComparison = (args: { const current = t.callExpression( t.memberExpression( t.identifier(acceptedTypeName), - t.identifier("is") + t.identifier(methodName) ), [fieldName] ); @@ -123,7 +124,7 @@ export const createProtoTypeComparison = (args: { const typeName = context.getTypeName(field); return t.callExpression( - t.memberExpression(t.identifier(typeName), t.identifier("is")), + t.memberExpression(t.identifier(typeName), t.identifier(methodName)), [fieldName] ); }; @@ -223,10 +224,11 @@ function getScalarExpression(args: { export const createFieldTypeComparison = (args: { context: ProtoParseContext; + methodName: string; fieldName: string; field: ProtoField; }): t.Expression => { - const { context, field, fieldName } = args; + const { context, field, fieldName, methodName } = args; if (field.keyType) { return createFieldExistingTest({ @@ -265,6 +267,7 @@ export const createFieldTypeComparison = (args: { fieldName, typeComparison: createProtoTypeComparison({ context, + methodName, field, fieldName: t.memberExpression( t.memberExpression( @@ -279,6 +282,7 @@ export const createFieldTypeComparison = (args: { } else { return createProtoTypeComparison({ context, + methodName, fieldName: t.memberExpression( t.identifier(INPUT_PARAM), t.identifier(fieldName) @@ -330,6 +334,7 @@ export const isMethod = (args: { context: ProtoParseContext; name: string; proto: ProtoType; + methodName?: string; getFieldName?: ( fieldName: string, field: ProtoField, @@ -339,6 +344,8 @@ export const isMethod = (args: { }) => { const { context, name, proto, getFieldName } = args; + const methodName = args.methodName ?? "is"; + const returnType = t.tsTypeAnnotation( t.tsTypePredicate( t.identifier(INPUT_PARAM), @@ -364,6 +371,7 @@ export const isMethod = (args: { const current = createFieldTypeComparison({ context, + methodName, field, fieldName: fieldNameWithCase, }); @@ -381,7 +389,7 @@ export const isMethod = (args: { const method = objectMethod( "method", - t.identifier("is"), + t.identifier(methodName), [identifier(INPUT_PARAM, t.tsTypeAnnotation(t.tsAnyKeyword()), false)], t.blockStatement([ t.returnStatement( diff --git a/packages/ast/types/encoding/proto/is/index.d.ts b/packages/ast/types/encoding/proto/is/index.d.ts index 490024288..87f7589ee 100644 --- a/packages/ast/types/encoding/proto/is/index.d.ts +++ b/packages/ast/types/encoding/proto/is/index.d.ts @@ -20,6 +20,7 @@ export declare const createFieldExistingTest: (args: { }) => t.Expression; export declare const createProtoTypeComparison: (args: { context: ProtoParseContext; + methodName: string; fieldName: t.Expression; field: ProtoField; }) => t.Expression; @@ -31,6 +32,7 @@ export declare const createArrayTypeComparison: (args: { }) => t.CallExpression | t.LogicalExpression; export declare const createFieldTypeComparison: (args: { context: ProtoParseContext; + methodName: string; fieldName: string; field: ProtoField; }) => t.Expression; @@ -38,4 +40,6 @@ export declare const isMethod: (args: { context: ProtoParseContext; name: string; proto: ProtoType; + methodName?: string; + getFieldName?: (fieldName: string, field: ProtoField, interfaceName?: string, context?: ProtoParseContext) => string; }) => t.ObjectMethod; diff --git a/packages/ast/types/utils/utils.d.ts b/packages/ast/types/utils/utils.d.ts index 32dfe2294..860734023 100644 --- a/packages/ast/types/utils/utils.d.ts +++ b/packages/ast/types/utils/utils.d.ts @@ -16,3 +16,5 @@ export declare const memberExpressionOrIdentifierAminoCasing: (names: any, amino export declare const memberExpressionOrIdentifierAminoCaseField: (fields: ProtoField[], aminoCaseFunc: Function) => any; export declare const promiseTypeAnnotation: (name: any) => t.TSTypeAnnotation; export declare const getAcceptedInterfacesTypes: (context: ProtoParseContext, lookupInterface: string) => import("@cosmology/types").TraversalSymbol[]; +export declare const getSdkFieldName: (fieldName: string, field: ProtoField) => string; +export declare const getAminoFieldName: (fieldName: string, field: ProtoField, interfaceName: string, context: ProtoParseContext) => string; diff --git a/packages/telescope/__tests__/impl-interfaces.test.ts b/packages/telescope/__tests__/impl-interfaces.test.ts index 5ab0dcaef..ea90b7ae6 100644 --- a/packages/telescope/__tests__/impl-interfaces.test.ts +++ b/packages/telescope/__tests__/impl-interfaces.test.ts @@ -120,7 +120,7 @@ describe("implements interface works", () => { useUnionTypes: true, }, - useSDKTypes:false, + useSDKTypes:true, prototypes: { addTypeUrlToDecoders: false, @@ -136,7 +136,7 @@ describe("implements interface works", () => { }, aminoEncoding: { - enabled: false, + enabled: true, useLegacyInlineEncoding: false, }, }),