// Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.8.3 // protoc unknown // source: google/protobuf/struct.proto /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; import Long from "long"; export const protobufPackage = "google.protobuf"; /** * `NullValue` is a singleton enumeration to represent the null value for the * `Value` type union. * * The JSON representation for `NullValue` is JSON `null`. */ export enum NullValue { /** NULL_VALUE - Null value. */ NULL_VALUE = 0, UNRECOGNIZED = -1, } export function nullValueFromJSON(object: any): NullValue { switch (object) { case 0: case "NULL_VALUE": return NullValue.NULL_VALUE; case -1: case "UNRECOGNIZED": default: return NullValue.UNRECOGNIZED; } } export function nullValueToJSON(object: NullValue): string { switch (object) { case NullValue.NULL_VALUE: return "NULL_VALUE"; case NullValue.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } /** * `Struct` represents a structured data value, consisting of fields * which map to dynamically typed values. In some languages, `Struct` * might be supported by a native representation. For example, in * scripting languages like JS a struct is represented as an * object. The details of that representation are described together * with the proto support for the language. * * The JSON representation for `Struct` is JSON object. */ export interface Struct { /** Unordered map of dynamically typed values. */ fields: { [key: string]: any | undefined }; } export interface Struct_FieldsEntry { key: string; value: any | undefined; } /** * `Value` represents a dynamically typed value which can be either * null, a number, a string, a boolean, a recursive struct value, or a * list of values. A producer of value is expected to set one of these * variants. Absence of any variant indicates an error. * * The JSON representation for `Value` is JSON value. */ export interface Value { /** The kind of value. */ kind?: | // /** Represents a null value. */ { $case: "nullValue"; nullValue: NullValue } | // /** Represents a double value. */ { $case: "numberValue"; numberValue: number } | // /** Represents a string value. */ { $case: "stringValue"; stringValue: string } | // /** Represents a boolean value. */ { $case: "boolValue"; boolValue: boolean } | // /** Represents a structured value. */ { $case: "structValue"; structValue: { [key: string]: any } | undefined } | // /** Represents a repeated `Value`. */ { $case: "listValue"; listValue: Array | undefined } | undefined; } /** * `ListValue` is a wrapper around a repeated field of values. * * The JSON representation for `ListValue` is JSON array. */ export interface ListValue { /** Repeated field of dynamically typed values. */ values: any[]; } function createBaseStruct(): Struct { return { fields: {} }; } export const Struct: MessageFns & StructWrapperFns = { encode(message: Struct, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { Object.entries(message.fields).forEach(([key, value]) => { if (value !== undefined) { Struct_FieldsEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).join(); } }); return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): Struct { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } const entry1 = Struct_FieldsEntry.decode(reader, reader.uint32()); if (entry1.value !== undefined) { message.fields[entry1.key] = entry1.value; } continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): Struct { return { fields: isObject(object.fields) ? Object.entries(object.fields).reduce<{ [key: string]: any | undefined }>((acc, [key, value]) => { acc[key] = value as any | undefined; return acc; }, {}) : {}, }; }, toJSON(message: Struct): unknown { const obj: any = {}; if (message.fields) { const entries = Object.entries(message.fields); if (entries.length > 0) { obj.fields = {}; entries.forEach(([k, v]) => { obj.fields[k] = v; }); } } return obj; }, create(base?: DeepPartial): Struct { return Struct.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): Struct { const message = createBaseStruct(); message.fields = Object.entries(object.fields ?? {}).reduce<{ [key: string]: any | undefined }>( (acc, [key, value]) => { if (value !== undefined) { acc[key] = value; } return acc; }, {}, ); return message; }, wrap(object: { [key: string]: any } | undefined): Struct { const struct = createBaseStruct(); if (object !== undefined) { for (const key of Object.keys(object)) { struct.fields[key] = object[key]; } } return struct; }, unwrap(message: Struct): { [key: string]: any } { const object: { [key: string]: any } = {}; if (message.fields) { for (const key of Object.keys(message.fields)) { object[key] = message.fields[key]; } } return object; }, }; function createBaseStruct_FieldsEntry(): Struct_FieldsEntry { return { key: "", value: undefined }; } export const Struct_FieldsEntry: MessageFns = { encode(message: Struct_FieldsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { Value.encode(Value.wrap(message.value), writer.uint32(18).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): Struct_FieldsEntry { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStruct_FieldsEntry(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.key = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.value = Value.unwrap(Value.decode(reader, reader.uint32())); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): Struct_FieldsEntry { return { key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object?.value) ? object.value : undefined, }; }, toJSON(message: Struct_FieldsEntry): unknown { const obj: any = {}; if (message.key !== "") { obj.key = message.key; } if (message.value !== undefined) { obj.value = message.value; } return obj; }, create(base?: DeepPartial): Struct_FieldsEntry { return Struct_FieldsEntry.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): Struct_FieldsEntry { const message = createBaseStruct_FieldsEntry(); message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, }; function createBaseValue(): Value { return { kind: undefined }; } export const Value: MessageFns & AnyValueWrapperFns = { encode(message: Value, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { switch (message.kind?.$case) { case "nullValue": writer.uint32(8).int32(message.kind.nullValue); break; case "numberValue": writer.uint32(17).double(message.kind.numberValue); break; case "stringValue": writer.uint32(26).string(message.kind.stringValue); break; case "boolValue": writer.uint32(32).bool(message.kind.boolValue); break; case "structValue": Struct.encode(Struct.wrap(message.kind.structValue), writer.uint32(42).fork()).join(); break; case "listValue": ListValue.encode(ListValue.wrap(message.kind.listValue), writer.uint32(50).fork()).join(); break; } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): Value { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseValue(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 8) { break; } message.kind = { $case: "nullValue", nullValue: reader.int32() as any }; continue; } case 2: { if (tag !== 17) { break; } message.kind = { $case: "numberValue", numberValue: reader.double() }; continue; } case 3: { if (tag !== 26) { break; } message.kind = { $case: "stringValue", stringValue: reader.string() }; continue; } case 4: { if (tag !== 32) { break; } message.kind = { $case: "boolValue", boolValue: reader.bool() }; continue; } case 5: { if (tag !== 42) { break; } message.kind = { $case: "structValue", structValue: Struct.unwrap(Struct.decode(reader, reader.uint32())) }; continue; } case 6: { if (tag !== 50) { break; } message.kind = { $case: "listValue", listValue: ListValue.unwrap(ListValue.decode(reader, reader.uint32())) }; continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): Value { return { kind: isSet(object.nullValue) ? { $case: "nullValue", nullValue: nullValueFromJSON(object.nullValue) } : isSet(object.numberValue) ? { $case: "numberValue", numberValue: globalThis.Number(object.numberValue) } : isSet(object.stringValue) ? { $case: "stringValue", stringValue: globalThis.String(object.stringValue) } : isSet(object.boolValue) ? { $case: "boolValue", boolValue: globalThis.Boolean(object.boolValue) } : isSet(object.structValue) ? { $case: "structValue", structValue: object.structValue } : isSet(object.listValue) ? { $case: "listValue", listValue: [...object.listValue] } : undefined, }; }, toJSON(message: Value): unknown { const obj: any = {}; if (message.kind?.$case === "nullValue") { obj.nullValue = nullValueToJSON(message.kind.nullValue); } else if (message.kind?.$case === "numberValue") { obj.numberValue = message.kind.numberValue; } else if (message.kind?.$case === "stringValue") { obj.stringValue = message.kind.stringValue; } else if (message.kind?.$case === "boolValue") { obj.boolValue = message.kind.boolValue; } else if (message.kind?.$case === "structValue") { obj.structValue = message.kind.structValue; } else if (message.kind?.$case === "listValue") { obj.listValue = message.kind.listValue; } return obj; }, create(base?: DeepPartial): Value { return Value.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): Value { const message = createBaseValue(); switch (object.kind?.$case) { case "nullValue": { if (object.kind?.nullValue !== undefined && object.kind?.nullValue !== null) { message.kind = { $case: "nullValue", nullValue: object.kind.nullValue }; } break; } case "numberValue": { if (object.kind?.numberValue !== undefined && object.kind?.numberValue !== null) { message.kind = { $case: "numberValue", numberValue: object.kind.numberValue }; } break; } case "stringValue": { if (object.kind?.stringValue !== undefined && object.kind?.stringValue !== null) { message.kind = { $case: "stringValue", stringValue: object.kind.stringValue }; } break; } case "boolValue": { if (object.kind?.boolValue !== undefined && object.kind?.boolValue !== null) { message.kind = { $case: "boolValue", boolValue: object.kind.boolValue }; } break; } case "structValue": { if (object.kind?.structValue !== undefined && object.kind?.structValue !== null) { message.kind = { $case: "structValue", structValue: object.kind.structValue }; } break; } case "listValue": { if (object.kind?.listValue !== undefined && object.kind?.listValue !== null) { message.kind = { $case: "listValue", listValue: object.kind.listValue }; } break; } } return message; }, wrap(value: any): Value { const result = createBaseValue(); if (value === null) { result.kind = { $case: "nullValue", nullValue: NullValue.NULL_VALUE }; } else if (typeof value === "boolean") { result.kind = { $case: "boolValue", boolValue: value }; } else if (typeof value === "number") { result.kind = { $case: "numberValue", numberValue: value }; } else if (typeof value === "string") { result.kind = { $case: "stringValue", stringValue: value }; } else if (globalThis.Array.isArray(value)) { result.kind = { $case: "listValue", listValue: value }; } else if (typeof value === "object") { result.kind = { $case: "structValue", structValue: value }; } else if (typeof value !== "undefined") { throw new globalThis.Error("Unsupported any value type: " + typeof value); } return result; }, unwrap(message: Value): string | number | boolean | Object | null | Array | undefined { if (message.kind?.$case === "nullValue") { return null; } else if (message.kind?.$case === "numberValue") { return message.kind?.numberValue; } else if (message.kind?.$case === "stringValue") { return message.kind?.stringValue; } else if (message.kind?.$case === "boolValue") { return message.kind?.boolValue; } else if (message.kind?.$case === "structValue") { return message.kind?.structValue; } else if (message.kind?.$case === "listValue") { return message.kind?.listValue; } else { return undefined; } }, }; function createBaseListValue(): ListValue { return { values: [] }; } export const ListValue: MessageFns & ListValueWrapperFns = { encode(message: ListValue, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { for (const v of message.values) { Value.encode(Value.wrap(v!), writer.uint32(10).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): ListValue { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseListValue(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.values.push(Value.unwrap(Value.decode(reader, reader.uint32()))); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): ListValue { return { values: globalThis.Array.isArray(object?.values) ? [...object.values] : [] }; }, toJSON(message: ListValue): unknown { const obj: any = {}; if (message.values?.length) { obj.values = message.values; } return obj; }, create(base?: DeepPartial): ListValue { return ListValue.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): ListValue { const message = createBaseListValue(); message.values = object.values?.map((e) => e) || []; return message; }, wrap(array: Array | undefined): ListValue { const result = createBaseListValue(); result.values = array ?? []; return result; }, unwrap(message: ListValue): Array { if (message?.hasOwnProperty("values") && globalThis.Array.isArray(message.values)) { return message.values; } else { return message as any; } }, }; type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T : T extends Long ? string | number | Long : T extends globalThis.Array ? globalThis.Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends { $case: string } ? { [K in keyof Omit]?: DeepPartial } & { $case: T["$case"] } : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; function isObject(value: any): boolean { return typeof value === "object" && value !== null; } function isSet(value: any): boolean { return value !== null && value !== undefined; } export interface MessageFns { encode(message: T, writer?: BinaryWriter): BinaryWriter; decode(input: BinaryReader | Uint8Array, length?: number): T; fromJSON(object: any): T; toJSON(message: T): unknown; create(base?: DeepPartial): T; fromPartial(object: DeepPartial): T; } export interface StructWrapperFns { wrap(object: { [key: string]: any } | undefined): Struct; unwrap(message: Struct): { [key: string]: any }; } export interface AnyValueWrapperFns { wrap(value: any): Value; unwrap(message: any): string | number | boolean | Object | null | Array | undefined; } export interface ListValueWrapperFns { wrap(array: Array | undefined): ListValue; unwrap(message: ListValue): Array; }