/** * Scalar value types. This is a subset of field types declared by protobuf * enum google.protobuf.FieldDescriptorProto.Type The types GROUP and MESSAGE * are omitted, but the numerical values are identical. */ export declare enum ScalarType { DOUBLE = 1, FLOAT = 2, INT64 = 3, UINT64 = 4, INT32 = 5, FIXED64 = 6, FIXED32 = 7, BOOL = 8, STRING = 9, BYTES = 12, UINT32 = 13, SFIXED32 = 15, SFIXED64 = 16, SINT32 = 17,// Uses ZigZag encoding. SINT64 = 18,// Uses ZigZag encoding. DATE = 100 } /** * JavaScript representation of fields with 64 bit integral types (int64, uint64, * sint64, fixed64, sfixed64). * * This is a subset of google.protobuf.FieldOptions.JSType, which defines JS_NORMAL, * JS_STRING, and JS_NUMBER. Protobuf-ES uses BigInt by default, but will use * String if `[jstype = JS_STRING]` is specified. * * ```protobuf * uint64 field_a = 1; // BigInt * uint64 field_b = 2 [jstype = JS_NORMAL]; // BigInt * uint64 field_b = 2 [jstype = JS_NUMBER]; // BigInt * uint64 field_b = 2 [jstype = JS_STRING]; // String * ``` */ export declare enum LongType { /** * Use JavaScript BigInt. */ BIGINT = 0, /** * Use JavaScript String. * * Field option `[jstype = JS_STRING]`. */ STRING = 1 } /** * ScalarValue maps from a scalar field type to a TypeScript value type. */ export type ScalarValue = T extends ScalarType.STRING ? string : T extends ScalarType.INT32 ? number : T extends ScalarType.UINT32 ? number : T extends ScalarType.UINT32 ? number : T extends ScalarType.SINT32 ? number : T extends ScalarType.FIXED32 ? number : T extends ScalarType.SFIXED32 ? number : T extends ScalarType.FLOAT ? number : T extends ScalarType.DOUBLE ? number : T extends ScalarType.INT64 ? (L extends LongType.STRING ? string : bigint) : T extends ScalarType.SINT64 ? (L extends LongType.STRING ? string : bigint) : T extends ScalarType.SFIXED64 ? (L extends LongType.STRING ? string : bigint) : T extends ScalarType.UINT64 ? (L extends LongType.STRING ? string : bigint) : T extends ScalarType.FIXED64 ? (L extends LongType.STRING ? string : bigint) : T extends ScalarType.BOOL ? boolean : T extends ScalarType.BYTES ? Uint8Array : T extends ScalarType.DATE ? null : never; /** * Returns true if both scalar values are equal. */ export declare function scalarEquals(type: ScalarType, a: string | boolean | number | bigint | Uint8Array | Date | null | undefined, b: string | boolean | number | bigint | Uint8Array | Date | null | undefined): boolean; /** * Returns the zero value for the given scalar type. */ export declare function scalarZeroValue(type: T, longType: L): ScalarValue; /** * Returns true for a zero-value. For example, an integer has the zero-value `0`, * a boolean is `false`, a string is `""`, and bytes is an empty Uint8Array. * * In proto3, zero-values are not written to the wire, unless the field is * optional or repeated. */ export declare function isScalarZeroValue(type: ScalarType, value: unknown): boolean; /** * Returns the normalized version of the scalar value. * Zero or null is cast to the zero value. * Bytes is cast to a Uint8Array. * The BigInt long type is used. * If clone is set, Uint8Array will always be copied to a new value. */ export declare function normalizeScalarValue(type: ScalarType, value: T | null | undefined, clone: boolean, longType?: LongType): T; export declare function toU8Arr(input: ArrayLike, clone: boolean): Uint8Array;