| 1 |
import type { DescField, DescMessage } from "../descriptors.js"; |
| 2 |
import type { JsonObject, JsonValue } from "../json-value.js"; |
| 3 |
import type { Struct } from "../wkt/gen/google/protobuf/struct_pb.js"; |
| 4 |
/** |
| 5 |
* Mapper between the local representation of a message field value |
| 6 |
* and the message it represents. For most fields, the local value is the |
| 7 |
* message itself. Types from google/protobuf/wrappers.proto are unwrapped |
| 8 |
* to the wrapped scalar value when used in a singular field that is not |
| 9 |
* part of a oneof group, and google.protobuf.Struct is represented with |
| 10 |
* JsonObject when used in a field, except when used in |
| 11 |
* google.protobuf.Value. |
| 12 |
* |
| 13 |
* @private |
| 14 |
*/ |
| 15 |
export interface LocalMessageMapper { |
| 16 |
/** |
| 17 |
* Wrap a local value in the message it represents. For undefined - an |
| 18 |
* unset field - a new message is created. Like the reflect API, wrapping |
| 19 |
* an existing Struct field value creates a normalized copy, so that |
| 20 |
* merging does not mutate the previous value in place. |
| 21 |
*/ |
| 22 |
toMessage(local: unknown): Record<string, unknown>; |
| 23 |
/** |
| 24 |
* Convert a message to the local representation of the field value. |
| 25 |
*/ |
| 26 |
toLocal(message: Record<string, unknown>): unknown; |
| 27 |
} |
| 28 |
/** |
| 29 |
* Return the conversions between the local representation of the field |
| 30 |
* value and the message it represents. |
| 31 |
* |
| 32 |
* @private |
| 33 |
*/ |
| 34 |
export declare function localMessageMapper(field: DescField & { |
| 35 |
message: DescMessage; |
| 36 |
}): LocalMessageMapper; |
| 37 |
/** |
| 38 |
* Convert the JsonValue representation of a google.protobuf.Struct to the |
| 39 |
* message representation. |
| 40 |
* |
| 41 |
* @private |
| 42 |
*/ |
| 43 |
export declare function wktStructToReflect(json: JsonValue): Struct; |
| 44 |
/** |
| 45 |
* Convert a google.protobuf.Struct message to its JsonValue representation. |
| 46 |
* |
| 47 |
* @private |
| 48 |
*/ |
| 49 |
export declare function wktStructToLocal(val: Struct): JsonObject; |