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

     1  /* eslint-disable */
     2  import _m0 from "protobufjs/minimal";
     3  
     4  export const protobufPackage = "google.protobuf";
     5  
     6  /**
     7   * `NullValue` is a singleton enumeration to represent the null value for the
     8   * `Value` type union.
     9   *
    10   *  The JSON representation for `NullValue` is JSON `null`.
    11   */
    12  export enum NullValue {
    13    /** NULL_VALUE - Null value. */
    14    NULL_VALUE = 0,
    15  }
    16  
    17  export function nullValueFromJSON(object: any): NullValue {
    18    switch (object) {
    19      case 0:
    20      case "NULL_VALUE":
    21        return NullValue.NULL_VALUE;
    22      default:
    23        throw new globalThis.Error("Unrecognized enum value " + object + " for enum NullValue");
    24    }
    25  }
    26  
    27  export function nullValueToJSON(object: NullValue): string {
    28    switch (object) {
    29      case NullValue.NULL_VALUE:
    30        return "NULL_VALUE";
    31      default:
    32        throw new globalThis.Error("Unrecognized enum value " + object + " for enum NullValue");
    33    }
    34  }
    35  
    36  /**
    37   * `Struct` represents a structured data value, consisting of fields
    38   * which map to dynamically typed values. In some languages, `Struct`
    39   * might be supported by a native representation. For example, in
    40   * scripting languages like JS a struct is represented as an
    41   * object. The details of that representation are described together
    42   * with the proto support for the language.
    43   *
    44   * The JSON representation for `Struct` is JSON object.
    45   */
    46  export interface Struct {
    47    /** Unordered map of dynamically typed values. */
    48    readonly fields: { [key: string]: any | undefined };
    49  }
    50  
    51  export interface Struct_FieldsEntry {
    52    readonly key: string;
    53    readonly value: any | undefined;
    54  }
    55  
    56  /**
    57   * `Value` represents a dynamically typed value which can be either
    58   * null, a number, a string, a boolean, a recursive struct value, or a
    59   * list of values. A producer of value is expected to set one of these
    60   * variants. Absence of any variant indicates an error.
    61   *
    62   * The JSON representation for `Value` is JSON value.
    63   */
    64  export interface Value {
    65    /** Represents a null value. */
    66    readonly nullValue?:
    67      | NullValue
    68      | undefined;
    69    /** Represents a double value. */
    70    readonly numberValue?:
    71      | number
    72      | undefined;
    73    /** Represents a string value. */
    74    readonly stringValue?:
    75      | string
    76      | undefined;
    77    /** Represents a boolean value. */
    78    readonly boolValue?:
    79      | boolean
    80      | undefined;
    81    /** Represents a structured value. */
    82    readonly structValue?:
    83      | { readonly [key: string]: any }
    84      | undefined;
    85    /** Represents a repeated `Value`. */
    86    readonly listValue?: ReadonlyArray<any> | undefined;
    87  }
    88  
    89  /**
    90   * `ListValue` is a wrapper around a repeated field of values.
    91   *
    92   * The JSON representation for `ListValue` is JSON array.
    93   */
    94  export interface ListValue {
    95    /** Repeated field of dynamically typed values. */
    96    readonly values: readonly any[];
    97  }
    98  
    99  function createBaseStruct(): Struct {
   100    return { fields: {} };
   101  }
   102  
   103  export const Struct = {
   104    encode(message: Struct, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
   105      Object.entries(message.fields).forEach(([key, value]) => {
   106        if (value !== undefined) {
   107          Struct_FieldsEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).ldelim();
   108        }
   109      });
   110      return writer;
   111    },
   112  
   113    decode(input: _m0.Reader | Uint8Array, length?: number): Struct {
   114      const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
   115      let end = length === undefined ? reader.len : reader.pos + length;
   116      const message = createBaseStruct() as any;
   117      while (reader.pos < end) {
   118        const tag = reader.uint32();
   119        switch (tag >>> 3) {
   120          case 1:
   121            if (tag !== 10) {
   122              break;
   123            }
   124  
   125            const entry1 = Struct_FieldsEntry.decode(reader, reader.uint32());
   126            if (entry1.value !== undefined) {
   127              message.fields[entry1.key] = entry1.value;
   128            }
   129            continue;
   130        }
   131        if ((tag & 7) === 4 || tag === 0) {
   132          break;
   133        }
   134        reader.skipType(tag & 7);
   135      }
   136      return message;
   137    },
   138  
   139    fromJSON(object: any): Struct {
   140      return {
   141        fields: isObject(object.fields)
   142          ? Object.entries(object.fields).reduce<{ [key: string]: any | undefined }>((acc, [key, value]) => {
   143            acc[key] = value as any | undefined;
   144            return acc;
   145          }, {})
   146          : {},
   147      };
   148    },
   149  
   150    toJSON(message: Struct): unknown {
   151      const obj: any = {};
   152      if (message.fields) {
   153        const entries = Object.entries(message.fields);
   154        if (entries.length > 0) {
   155          obj.fields = {};
   156          entries.forEach(([k, v]) => {
   157            obj.fields[k] = v;
   158          });
   159        }
   160      }
   161      return obj;
   162    },
   163  
   164    create<I extends Exact<DeepPartial<Struct>, I>>(base?: I): Struct {
   165      return Struct.fromPartial(base ?? ({} as any));
   166    },
   167    fromPartial<I extends Exact<DeepPartial<Struct>, I>>(object: I): Struct {
   168      const message = createBaseStruct() as any;
   169      message.fields = Object.entries(object.fields ?? {}).reduce<{ [key: string]: any | undefined }>(
   170        (acc, [key, value]) => {
   171          if (value !== undefined) {
   172            acc[key] = value;
   173          }
   174          return acc;
   175        },
   176        {},
   177      );
   178      return message;
   179    },
   180  
   181    wrap(object: { [key: string]: any } | undefined): Struct {
   182      const struct = createBaseStruct();
   183      if (object !== undefined) {
   184        Object.keys(object).forEach((key) => {
   185          struct.fields[key] = object[key];
   186        });
   187      }
   188      return struct;
   189    },
   190  
   191    unwrap(message: Struct): { [key: string]: any } {
   192      const object: { [key: string]: any } = {};
   193      if (message.fields) {
   194        Object.keys(message.fields).forEach((key) => {
   195          object[key] = message.fields[key];
   196        });
   197      }
   198      return object;
   199    },
   200  };
   201  
   202  function createBaseStruct_FieldsEntry(): Struct_FieldsEntry {
   203    return { key: "", value: undefined };
   204  }
   205  
   206  export const Struct_FieldsEntry = {
   207    encode(message: Struct_FieldsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
   208      if (message.key !== "") {
   209        writer.uint32(10).string(message.key);
   210      }
   211      if (message.value !== undefined) {
   212        Value.encode(Value.wrap(message.value), writer.uint32(18).fork()).ldelim();
   213      }
   214      return writer;
   215    },
   216  
   217    decode(input: _m0.Reader | Uint8Array, length?: number): Struct_FieldsEntry {
   218      const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
   219      let end = length === undefined ? reader.len : reader.pos + length;
   220      const message = createBaseStruct_FieldsEntry() as any;
   221      while (reader.pos < end) {
   222        const tag = reader.uint32();
   223        switch (tag >>> 3) {
   224          case 1:
   225            if (tag !== 10) {
   226              break;
   227            }
   228  
   229            message.key = reader.string();
   230            continue;
   231          case 2:
   232            if (tag !== 18) {
   233              break;
   234            }
   235  
   236            message.value = Value.unwrap(Value.decode(reader, reader.uint32()));
   237            continue;
   238        }
   239        if ((tag & 7) === 4 || tag === 0) {
   240          break;
   241        }
   242        reader.skipType(tag & 7);
   243      }
   244      return message;
   245    },
   246  
   247    fromJSON(object: any): Struct_FieldsEntry {
   248      return {
   249        key: isSet(object.key) ? globalThis.String(object.key) : "",
   250        value: isSet(object?.value) ? object.value : undefined,
   251      };
   252    },
   253  
   254    toJSON(message: Struct_FieldsEntry): unknown {
   255      const obj: any = {};
   256      if (message.key !== "") {
   257        obj.key = message.key;
   258      }
   259      if (message.value !== undefined) {
   260        obj.value = message.value;
   261      }
   262      return obj;
   263    },
   264  
   265    create<I extends Exact<DeepPartial<Struct_FieldsEntry>, I>>(base?: I): Struct_FieldsEntry {
   266      return Struct_FieldsEntry.fromPartial(base ?? ({} as any));
   267    },
   268    fromPartial<I extends Exact<DeepPartial<Struct_FieldsEntry>, I>>(object: I): Struct_FieldsEntry {
   269      const message = createBaseStruct_FieldsEntry() as any;
   270      message.key = object.key ?? "";
   271      message.value = object.value ?? undefined;
   272      return message;
   273    },
   274  };
   275  
   276  function createBaseValue(): Value {
   277    return {
   278      nullValue: undefined,
   279      numberValue: undefined,
   280      stringValue: undefined,
   281      boolValue: undefined,
   282      structValue: undefined,
   283      listValue: undefined,
   284    };
   285  }
   286  
   287  export const Value = {
   288    encode(message: Value, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
   289      if (message.nullValue !== undefined) {
   290        writer.uint32(8).int32(message.nullValue);
   291      }
   292      if (message.numberValue !== undefined) {
   293        writer.uint32(17).double(message.numberValue);
   294      }
   295      if (message.stringValue !== undefined) {
   296        writer.uint32(26).string(message.stringValue);
   297      }
   298      if (message.boolValue !== undefined) {
   299        writer.uint32(32).bool(message.boolValue);
   300      }
   301      if (message.structValue !== undefined) {
   302        Struct.encode(Struct.wrap(message.structValue), writer.uint32(42).fork()).ldelim();
   303      }
   304      if (message.listValue !== undefined) {
   305        ListValue.encode(ListValue.wrap(message.listValue), writer.uint32(50).fork()).ldelim();
   306      }
   307      return writer;
   308    },
   309  
   310    decode(input: _m0.Reader | Uint8Array, length?: number): Value {
   311      const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
   312      let end = length === undefined ? reader.len : reader.pos + length;
   313      const message = createBaseValue() as any;
   314      while (reader.pos < end) {
   315        const tag = reader.uint32();
   316        switch (tag >>> 3) {
   317          case 1:
   318            if (tag !== 8) {
   319              break;
   320            }
   321  
   322            message.nullValue = reader.int32() as any;
   323            continue;
   324          case 2:
   325            if (tag !== 17) {
   326              break;
   327            }
   328  
   329            message.numberValue = reader.double();
   330            continue;
   331          case 3:
   332            if (tag !== 26) {
   333              break;
   334            }
   335  
   336            message.stringValue = reader.string();
   337            continue;
   338          case 4:
   339            if (tag !== 32) {
   340              break;
   341            }
   342  
   343            message.boolValue = reader.bool();
   344            continue;
   345          case 5:
   346            if (tag !== 42) {
   347              break;
   348            }
   349  
   350            message.structValue = Struct.unwrap(Struct.decode(reader, reader.uint32()));
   351            continue;
   352          case 6:
   353            if (tag !== 50) {
   354              break;
   355            }
   356  
   357            message.listValue = ListValue.unwrap(ListValue.decode(reader, reader.uint32()));
   358            continue;
   359        }
   360        if ((tag & 7) === 4 || tag === 0) {
   361          break;
   362        }
   363        reader.skipType(tag & 7);
   364      }
   365      return message;
   366    },
   367  
   368    fromJSON(object: any): Value {
   369      return {
   370        nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : undefined,
   371        numberValue: isSet(object.numberValue) ? globalThis.Number(object.numberValue) : undefined,
   372        stringValue: isSet(object.stringValue) ? globalThis.String(object.stringValue) : undefined,
   373        boolValue: isSet(object.boolValue) ? globalThis.Boolean(object.boolValue) : undefined,
   374        structValue: isObject(object.structValue) ? object.structValue : undefined,
   375        listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : undefined,
   376      };
   377    },
   378  
   379    toJSON(message: Value): unknown {
   380      const obj: any = {};
   381      if (message.nullValue !== undefined) {
   382        obj.nullValue = nullValueToJSON(message.nullValue);
   383      }
   384      if (message.numberValue !== undefined) {
   385        obj.numberValue = message.numberValue;
   386      }
   387      if (message.stringValue !== undefined) {
   388        obj.stringValue = message.stringValue;
   389      }
   390      if (message.boolValue !== undefined) {
   391        obj.boolValue = message.boolValue;
   392      }
   393      if (message.structValue !== undefined) {
   394        obj.structValue = message.structValue;
   395      }
   396      if (message.listValue !== undefined) {
   397        obj.listValue = message.listValue;
   398      }
   399      return obj;
   400    },
   401  
   402    create<I extends Exact<DeepPartial<Value>, I>>(base?: I): Value {
   403      return Value.fromPartial(base ?? ({} as any));
   404    },
   405    fromPartial<I extends Exact<DeepPartial<Value>, I>>(object: I): Value {
   406      const message = createBaseValue() as any;
   407      message.nullValue = object.nullValue ?? undefined;
   408      message.numberValue = object.numberValue ?? undefined;
   409      message.stringValue = object.stringValue ?? undefined;
   410      message.boolValue = object.boolValue ?? undefined;
   411      message.structValue = object.structValue ?? undefined;
   412      message.listValue = object.listValue ?? undefined;
   413      return message;
   414    },
   415  
   416    wrap(value: any): Value {
   417      const result = createBaseValue() as any;
   418      if (value === null) {
   419        result.nullValue = NullValue.NULL_VALUE;
   420      } else if (typeof value === "boolean") {
   421        result.boolValue = value;
   422      } else if (typeof value === "number") {
   423        result.numberValue = value;
   424      } else if (typeof value === "string") {
   425        result.stringValue = value;
   426      } else if (globalThis.Array.isArray(value)) {
   427        result.listValue = value;
   428      } else if (typeof value === "object") {
   429        result.structValue = value;
   430      } else if (typeof value !== "undefined") {
   431        throw new Error("Unsupported any value type: " + typeof value);
   432      }
   433      return result;
   434    },
   435  
   436    unwrap(message: any): string | number | boolean | Object | null | Array<any> | undefined {
   437      if (message.stringValue !== undefined) {
   438        return message.stringValue;
   439      } else if (message?.numberValue !== undefined) {
   440        return message.numberValue;
   441      } else if (message?.boolValue !== undefined) {
   442        return message.boolValue;
   443      } else if (message?.structValue !== undefined) {
   444        return message.structValue as any;
   445      } else if (message?.listValue !== undefined) {
   446        return message.listValue;
   447      } else if (message?.nullValue !== undefined) {
   448        return null;
   449      }
   450      return undefined;
   451    },
   452  };
   453  
   454  function createBaseListValue(): ListValue {
   455    return { values: [] };
   456  }
   457  
   458  export const ListValue = {
   459    encode(message: ListValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
   460      for (const v of message.values) {
   461        Value.encode(Value.wrap(v!), writer.uint32(10).fork()).ldelim();
   462      }
   463      return writer;
   464    },
   465  
   466    decode(input: _m0.Reader | Uint8Array, length?: number): ListValue {
   467      const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
   468      let end = length === undefined ? reader.len : reader.pos + length;
   469      const message = createBaseListValue() as any;
   470      while (reader.pos < end) {
   471        const tag = reader.uint32();
   472        switch (tag >>> 3) {
   473          case 1:
   474            if (tag !== 10) {
   475              break;
   476            }
   477  
   478            message.values.push(Value.unwrap(Value.decode(reader, reader.uint32())));
   479            continue;
   480        }
   481        if ((tag & 7) === 4 || tag === 0) {
   482          break;
   483        }
   484        reader.skipType(tag & 7);
   485      }
   486      return message;
   487    },
   488  
   489    fromJSON(object: any): ListValue {
   490      return { values: globalThis.Array.isArray(object?.values) ? [...object.values] : [] };
   491    },
   492  
   493    toJSON(message: ListValue): unknown {
   494      const obj: any = {};
   495      if (message.values?.length) {
   496        obj.values = message.values;
   497      }
   498      return obj;
   499    },
   500  
   501    create<I extends Exact<DeepPartial<ListValue>, I>>(base?: I): ListValue {
   502      return ListValue.fromPartial(base ?? ({} as any));
   503    },
   504    fromPartial<I extends Exact<DeepPartial<ListValue>, I>>(object: I): ListValue {
   505      const message = createBaseListValue() as any;
   506      message.values = object.values?.map((e) => e) || [];
   507      return message;
   508    },
   509  
   510    wrap(array: ReadonlyArray<any> | undefined): ListValue {
   511      const result = createBaseListValue() as any;
   512      result.values = array ?? [];
   513      return result;
   514    },
   515  
   516    unwrap(message: any): Array<any> {
   517      if (message?.hasOwnProperty("values") && globalThis.Array.isArray(message.values)) {
   518        return message.values;
   519      } else {
   520        return message as any;
   521      }
   522    },
   523  };
   524  
   525  type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
   526  
   527  export type DeepPartial<T> = T extends Builtin ? T
   528    : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
   529    : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
   530    : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
   531    : Partial<T>;
   532  
   533  type KeysOfUnion<T> = T extends T ? keyof T : never;
   534  export type Exact<P, I extends P> = P extends Builtin ? P
   535    : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
   536  
   537  function isObject(value: any): boolean {
   538    return typeof value === "object" && value !== null;
   539  }
   540  
   541  function isSet(value: any): boolean {
   542    return value !== null && value !== undefined;
   543  }