go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/analysis/frontend/ui/src/proto/google/protobuf/field_mask.pb.ts (about) 1 /* eslint-disable */ 2 import _m0 from "protobufjs/minimal"; 3 4 export const protobufPackage = "google.protobuf"; 5 6 /** 7 * `FieldMask` represents a set of symbolic field paths, for example: 8 * 9 * paths: "f.a" 10 * paths: "f.b.d" 11 * 12 * Here `f` represents a field in some root message, `a` and `b` 13 * fields in the message found in `f`, and `d` a field found in the 14 * message in `f.b`. 15 * 16 * Field masks are used to specify a subset of fields that should be 17 * returned by a get operation or modified by an update operation. 18 * Field masks also have a custom JSON encoding (see below). 19 * 20 * # Field Masks in Projections 21 * 22 * When used in the context of a projection, a response message or 23 * sub-message is filtered by the API to only contain those fields as 24 * specified in the mask. For example, if the mask in the previous 25 * example is applied to a response message as follows: 26 * 27 * f { 28 * a : 22 29 * b { 30 * d : 1 31 * x : 2 32 * } 33 * y : 13 34 * } 35 * z: 8 36 * 37 * The result will not contain specific values for fields x,y and z 38 * (their value will be set to the default, and omitted in proto text 39 * output): 40 * 41 * f { 42 * a : 22 43 * b { 44 * d : 1 45 * } 46 * } 47 * 48 * A repeated field is not allowed except at the last position of a 49 * paths string. 50 * 51 * If a FieldMask object is not present in a get operation, the 52 * operation applies to all fields (as if a FieldMask of all fields 53 * had been specified). 54 * 55 * Note that a field mask does not necessarily apply to the 56 * top-level response message. In case of a REST get operation, the 57 * field mask applies directly to the response, but in case of a REST 58 * list operation, the mask instead applies to each individual message 59 * in the returned resource list. In case of a REST custom method, 60 * other definitions may be used. Where the mask applies will be 61 * clearly documented together with its declaration in the API. In 62 * any case, the effect on the returned resource/resources is required 63 * behavior for APIs. 64 * 65 * # Field Masks in Update Operations 66 * 67 * A field mask in update operations specifies which fields of the 68 * targeted resource are going to be updated. The API is required 69 * to only change the values of the fields as specified in the mask 70 * and leave the others untouched. If a resource is passed in to 71 * describe the updated values, the API ignores the values of all 72 * fields not covered by the mask. 73 * 74 * If a repeated field is specified for an update operation, new values will 75 * be appended to the existing repeated field in the target resource. Note that 76 * a repeated field is only allowed in the last position of a `paths` string. 77 * 78 * If a sub-message is specified in the last position of the field mask for an 79 * update operation, then new value will be merged into the existing sub-message 80 * in the target resource. 81 * 82 * For example, given the target message: 83 * 84 * f { 85 * b { 86 * d: 1 87 * x: 2 88 * } 89 * c: [1] 90 * } 91 * 92 * And an update message: 93 * 94 * f { 95 * b { 96 * d: 10 97 * } 98 * c: [2] 99 * } 100 * 101 * then if the field mask is: 102 * 103 * paths: ["f.b", "f.c"] 104 * 105 * then the result will be: 106 * 107 * f { 108 * b { 109 * d: 10 110 * x: 2 111 * } 112 * c: [1, 2] 113 * } 114 * 115 * An implementation may provide options to override this default behavior for 116 * repeated and message fields. 117 * 118 * In order to reset a field's value to the default, the field must 119 * be in the mask and set to the default value in the provided resource. 120 * Hence, in order to reset all fields of a resource, provide a default 121 * instance of the resource and set all fields in the mask, or do 122 * not provide a mask as described below. 123 * 124 * If a field mask is not present on update, the operation applies to 125 * all fields (as if a field mask of all fields has been specified). 126 * Note that in the presence of schema evolution, this may mean that 127 * fields the client does not know and has therefore not filled into 128 * the request will be reset to their default. If this is unwanted 129 * behavior, a specific service may require a client to always specify 130 * a field mask, producing an error if not. 131 * 132 * As with get operations, the location of the resource which 133 * describes the updated values in the request message depends on the 134 * operation kind. In any case, the effect of the field mask is 135 * required to be honored by the API. 136 * 137 * ## Considerations for HTTP REST 138 * 139 * The HTTP kind of an update operation which uses a field mask must 140 * be set to PATCH instead of PUT in order to satisfy HTTP semantics 141 * (PUT must only be used for full updates). 142 * 143 * # JSON Encoding of Field Masks 144 * 145 * In JSON, a field mask is encoded as a single string where paths are 146 * separated by a comma. Fields name in each path are converted 147 * to/from lower-camel naming conventions. 148 * 149 * As an example, consider the following message declarations: 150 * 151 * message Profile { 152 * User user = 1; 153 * Photo photo = 2; 154 * } 155 * message User { 156 * string display_name = 1; 157 * string address = 2; 158 * } 159 * 160 * In proto a field mask for `Profile` may look as such: 161 * 162 * mask { 163 * paths: "user.display_name" 164 * paths: "photo" 165 * } 166 * 167 * In JSON, the same mask is represented as below: 168 * 169 * { 170 * mask: "user.displayName,photo" 171 * } 172 * 173 * # Field Masks and Oneof Fields 174 * 175 * Field masks treat fields in oneofs just as regular fields. Consider the 176 * following message: 177 * 178 * message SampleMessage { 179 * oneof test_oneof { 180 * string name = 4; 181 * SubMessage sub_message = 9; 182 * } 183 * } 184 * 185 * The field mask can be: 186 * 187 * mask { 188 * paths: "name" 189 * } 190 * 191 * Or: 192 * 193 * mask { 194 * paths: "sub_message" 195 * } 196 * 197 * Note that oneof type names ("test_oneof" in this case) cannot be used in 198 * paths. 199 * 200 * ## Field Mask Verification 201 * 202 * The implementation of any API method which has a FieldMask type field in the 203 * request should verify the included field paths, and return an 204 * `INVALID_ARGUMENT` error if any path is unmappable. 205 */ 206 export interface FieldMask { 207 /** The set of field mask paths. */ 208 readonly paths: readonly string[]; 209 } 210 211 function createBaseFieldMask(): FieldMask { 212 return { paths: [] }; 213 } 214 215 export const FieldMask = { 216 encode(message: FieldMask, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 217 for (const v of message.paths) { 218 writer.uint32(10).string(v!); 219 } 220 return writer; 221 }, 222 223 decode(input: _m0.Reader | Uint8Array, length?: number): FieldMask { 224 const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); 225 let end = length === undefined ? reader.len : reader.pos + length; 226 const message = createBaseFieldMask() as any; 227 while (reader.pos < end) { 228 const tag = reader.uint32(); 229 switch (tag >>> 3) { 230 case 1: 231 if (tag !== 10) { 232 break; 233 } 234 235 message.paths.push(reader.string()); 236 continue; 237 } 238 if ((tag & 7) === 4 || tag === 0) { 239 break; 240 } 241 reader.skipType(tag & 7); 242 } 243 return message; 244 }, 245 246 fromJSON(object: any): FieldMask { 247 return { 248 paths: typeof object === "string" 249 ? object.split(",").filter(globalThis.Boolean) 250 : globalThis.Array.isArray(object?.paths) 251 ? object.paths.map(globalThis.String) 252 : [], 253 }; 254 }, 255 256 toJSON(message: FieldMask): string { 257 return message.paths.join(","); 258 }, 259 260 create<I extends Exact<DeepPartial<FieldMask>, I>>(base?: I): FieldMask { 261 return FieldMask.fromPartial(base ?? ({} as any)); 262 }, 263 fromPartial<I extends Exact<DeepPartial<FieldMask>, I>>(object: I): FieldMask { 264 const message = createBaseFieldMask() as any; 265 message.paths = object.paths?.map((e) => e) || []; 266 return message; 267 }, 268 269 wrap(paths: readonly string[]): FieldMask { 270 const result = createBaseFieldMask() as any; 271 result.paths = paths; 272 return result; 273 }, 274 275 unwrap(message: any): string[] { 276 return message.paths; 277 }, 278 }; 279 280 type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 281 282 export type DeepPartial<T> = T extends Builtin ? T 283 : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> 284 : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> 285 : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> } 286 : Partial<T>; 287 288 type KeysOfUnion<T> = T extends T ? keyof T : never; 289 export type Exact<P, I extends P> = P extends Builtin ? P 290 : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };