go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/milo/ui/src/proto/google/protobuf/any.pb.ts (about)

     1  /* eslint-disable */
     2  import _m0 from "protobufjs/minimal";
     3  
     4  export const protobufPackage = "google.protobuf";
     5  
     6  /**
     7   * `Any` contains an arbitrary serialized protocol buffer message along with a
     8   * URL that describes the type of the serialized message.
     9   *
    10   * Protobuf library provides support to pack/unpack Any values in the form
    11   * of utility functions or additional generated methods of the Any type.
    12   *
    13   * Example 1: Pack and unpack a message in C++.
    14   *
    15   *     Foo foo = ...;
    16   *     Any any;
    17   *     any.PackFrom(foo);
    18   *     ...
    19   *     if (any.UnpackTo(&foo)) {
    20   *       ...
    21   *     }
    22   *
    23   * Example 2: Pack and unpack a message in Java.
    24   *
    25   *     Foo foo = ...;
    26   *     Any any = Any.pack(foo);
    27   *     ...
    28   *     if (any.is(Foo.class)) {
    29   *       foo = any.unpack(Foo.class);
    30   *     }
    31   *
    32   * Example 3: Pack and unpack a message in Python.
    33   *
    34   *     foo = Foo(...)
    35   *     any = Any()
    36   *     any.Pack(foo)
    37   *     ...
    38   *     if any.Is(Foo.DESCRIPTOR):
    39   *       any.Unpack(foo)
    40   *       ...
    41   *
    42   * Example 4: Pack and unpack a message in Go
    43   *
    44   *      foo := &pb.Foo{...}
    45   *      any, err := anypb.New(foo)
    46   *      if err != nil {
    47   *        ...
    48   *      }
    49   *      ...
    50   *      foo := &pb.Foo{}
    51   *      if err := any.UnmarshalTo(foo); err != nil {
    52   *        ...
    53   *      }
    54   *
    55   * The pack methods provided by protobuf library will by default use
    56   * 'type.googleapis.com/full.type.name' as the type URL and the unpack
    57   * methods only use the fully qualified type name after the last '/'
    58   * in the type URL, for example "foo.bar.com/x/y.z" will yield type
    59   * name "y.z".
    60   *
    61   * JSON
    62   *
    63   * The JSON representation of an `Any` value uses the regular
    64   * representation of the deserialized, embedded message, with an
    65   * additional field `@type` which contains the type URL. Example:
    66   *
    67   *     package google.profile;
    68   *     message Person {
    69   *       string first_name = 1;
    70   *       string last_name = 2;
    71   *     }
    72   *
    73   *     {
    74   *       "@type": "type.googleapis.com/google.profile.Person",
    75   *       "firstName": <string>,
    76   *       "lastName": <string>
    77   *     }
    78   *
    79   * If the embedded message type is well-known and has a custom JSON
    80   * representation, that representation will be embedded adding a field
    81   * `value` which holds the custom JSON in addition to the `@type`
    82   * field. Example (for message [google.protobuf.Duration][]):
    83   *
    84   *     {
    85   *       "@type": "type.googleapis.com/google.protobuf.Duration",
    86   *       "value": "1.212s"
    87   *     }
    88   */
    89  export interface Any {
    90    /**
    91     * A URL/resource name that uniquely identifies the type of the serialized
    92     * protocol buffer message. This string must contain at least
    93     * one "/" character. The last segment of the URL's path must represent
    94     * the fully qualified name of the type (as in
    95     * `path/google.protobuf.Duration`). The name should be in a canonical form
    96     * (e.g., leading "." is not accepted).
    97     *
    98     * In practice, teams usually precompile into the binary all types that they
    99     * expect it to use in the context of Any. However, for URLs which use the
   100     * scheme `http`, `https`, or no scheme, one can optionally set up a type
   101     * server that maps type URLs to message definitions as follows:
   102     *
   103     * * If no scheme is provided, `https` is assumed.
   104     * * An HTTP GET on the URL must yield a [google.protobuf.Type][]
   105     *   value in binary format, or produce an error.
   106     * * Applications are allowed to cache lookup results based on the
   107     *   URL, or have them precompiled into a binary to avoid any
   108     *   lookup. Therefore, binary compatibility needs to be preserved
   109     *   on changes to types. (Use versioned type names to manage
   110     *   breaking changes.)
   111     *
   112     * Note: this functionality is not currently available in the official
   113     * protobuf release, and it is not used for type URLs beginning with
   114     * type.googleapis.com.
   115     *
   116     * Schemes other than `http`, `https` (or the empty scheme) might be
   117     * used with implementation specific semantics.
   118     */
   119    readonly typeUrl: string;
   120    /** Must be a valid serialized protocol buffer of the above specified type. */
   121    readonly value: Uint8Array;
   122  }
   123  
   124  function createBaseAny(): Any {
   125    return { typeUrl: "", value: new Uint8Array(0) };
   126  }
   127  
   128  export const Any = {
   129    encode(message: Any, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
   130      if (message.typeUrl !== "") {
   131        writer.uint32(10).string(message.typeUrl);
   132      }
   133      if (message.value.length !== 0) {
   134        writer.uint32(18).bytes(message.value);
   135      }
   136      return writer;
   137    },
   138  
   139    decode(input: _m0.Reader | Uint8Array, length?: number): Any {
   140      const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
   141      let end = length === undefined ? reader.len : reader.pos + length;
   142      const message = createBaseAny() as any;
   143      while (reader.pos < end) {
   144        const tag = reader.uint32();
   145        switch (tag >>> 3) {
   146          case 1:
   147            if (tag !== 10) {
   148              break;
   149            }
   150  
   151            message.typeUrl = reader.string();
   152            continue;
   153          case 2:
   154            if (tag !== 18) {
   155              break;
   156            }
   157  
   158            message.value = reader.bytes();
   159            continue;
   160        }
   161        if ((tag & 7) === 4 || tag === 0) {
   162          break;
   163        }
   164        reader.skipType(tag & 7);
   165      }
   166      return message;
   167    },
   168  
   169    fromJSON(object: any): Any {
   170      return {
   171        typeUrl: isSet(object.typeUrl) ? globalThis.String(object.typeUrl) : "",
   172        value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(0),
   173      };
   174    },
   175  
   176    toJSON(message: Any): unknown {
   177      const obj: any = {};
   178      if (message.typeUrl !== "") {
   179        obj.typeUrl = message.typeUrl;
   180      }
   181      if (message.value.length !== 0) {
   182        obj.value = base64FromBytes(message.value);
   183      }
   184      return obj;
   185    },
   186  
   187    create<I extends Exact<DeepPartial<Any>, I>>(base?: I): Any {
   188      return Any.fromPartial(base ?? ({} as any));
   189    },
   190    fromPartial<I extends Exact<DeepPartial<Any>, I>>(object: I): Any {
   191      const message = createBaseAny() as any;
   192      message.typeUrl = object.typeUrl ?? "";
   193      message.value = object.value ?? new Uint8Array(0);
   194      return message;
   195    },
   196  };
   197  
   198  function bytesFromBase64(b64: string): Uint8Array {
   199    if (globalThis.Buffer) {
   200      return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
   201    } else {
   202      const bin = globalThis.atob(b64);
   203      const arr = new Uint8Array(bin.length);
   204      for (let i = 0; i < bin.length; ++i) {
   205        arr[i] = bin.charCodeAt(i);
   206      }
   207      return arr;
   208    }
   209  }
   210  
   211  function base64FromBytes(arr: Uint8Array): string {
   212    if (globalThis.Buffer) {
   213      return globalThis.Buffer.from(arr).toString("base64");
   214    } else {
   215      const bin: string[] = [];
   216      arr.forEach((byte) => {
   217        bin.push(globalThis.String.fromCharCode(byte));
   218      });
   219      return globalThis.btoa(bin.join(""));
   220    }
   221  }
   222  
   223  type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
   224  
   225  export type DeepPartial<T> = T extends Builtin ? T
   226    : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
   227    : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
   228    : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
   229    : Partial<T>;
   230  
   231  type KeysOfUnion<T> = T extends T ? keyof T : never;
   232  export type Exact<P, I extends P> = P extends Builtin ? P
   233    : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
   234  
   235  function isSet(value: any): boolean {
   236    return value !== null && value !== undefined;
   237  }