Debian Codegraph @

node/@bufbuild/protobuf/dist/commonjs/descriptors.d.ts

raw
1 import type { DescriptorProto, Edition, EnumDescriptorProto, EnumValueDescriptorProto, FeatureSet_FieldPresence, FieldDescriptorProto, FileDescriptorProto, MethodDescriptorProto, MethodOptions_IdempotencyLevel, OneofDescriptorProto, ServiceDescriptorProto } from "./wkt/gen/google/protobuf/descriptor_pb.js";
2 import type { ScalarValue } from "./reflect/scalar.js";
3 export type SupportedEdition = Extract<Edition, typeof Edition.EDITION_PROTO2 | typeof Edition.EDITION_PROTO3 | typeof Edition.EDITION_2023 | typeof Edition.EDITION_2024>;
4 type SupportedFieldPresence = Extract<FeatureSet_FieldPresence, typeof FeatureSet_FieldPresence.EXPLICIT | typeof FeatureSet_FieldPresence.IMPLICIT | typeof FeatureSet_FieldPresence.LEGACY_REQUIRED>;
5 /**
6 * Scalar value types. This is a subset of field types declared by protobuf
7 * enum google.protobuf.FieldDescriptorProto.Type The types GROUP and MESSAGE
8 * are omitted, but the numerical values are identical.
9 */
10 export declare enum ScalarType {
11 DOUBLE = 1,
12 FLOAT = 2,
13 INT64 = 3,
14 UINT64 = 4,
15 INT32 = 5,
16 FIXED64 = 6,
17 FIXED32 = 7,
18 BOOL = 8,
19 STRING = 9,
20 BYTES = 12,
21 UINT32 = 13,
22 SFIXED32 = 15,
23 SFIXED64 = 16,
24 SINT32 = 17,// Uses ZigZag encoding.
25 SINT64 = 18
26 }
27 /**
28 * A union of all descriptors, discriminated by a `kind` property.
29 */
30 export type AnyDesc = DescFile | DescEnum | DescEnumValue | DescMessage | DescField | DescExtension | DescOneof | DescService | DescMethod;
31 /**
32 * Describes a protobuf source file.
33 */
34 export interface DescFile {
35 readonly kind: "file";
36 /**
37 * The edition of the protobuf file. Will be EDITION_PROTO2 for syntax="proto2",
38 * EDITION_PROTO3 for syntax="proto3";
39 */
40 readonly edition: SupportedEdition;
41 /**
42 * The name of the file, excluding the .proto suffix.
43 * For a protobuf file `foo/bar.proto`, this is `foo/bar`.
44 */
45 readonly name: string;
46 /**
47 * Files imported by this file.
48 */
49 readonly dependencies: DescFile[];
50 /**
51 * Top-level enumerations declared in this file.
52 * Note that more enumerations might be declared within message declarations.
53 */
54 readonly enums: DescEnum[];
55 /**
56 * Top-level messages declared in this file.
57 * Note that more messages might be declared within message declarations.
58 */
59 readonly messages: DescMessage[];
60 /**
61 * Top-level extensions declared in this file.
62 * Note that more extensions might be declared within message declarations.
63 */
64 readonly extensions: DescExtension[];
65 /**
66 * Services declared in this file.
67 */
68 readonly services: DescService[];
69 /**
70 * Marked as deprecated in the protobuf source.
71 */
72 readonly deprecated: boolean;
73 /**
74 * The compiler-generated descriptor.
75 */
76 readonly proto: FileDescriptorProto;
77 toString(): string;
78 }
79 /**
80 * Describes an enumeration in a protobuf source file.
81 */
82 export interface DescEnum {
83 readonly kind: "enum";
84 /**
85 * The fully qualified name of the enumeration. (We omit the leading dot.)
86 */
87 readonly typeName: string;
88 /**
89 * The name of the enumeration, as declared in the protobuf source.
90 */
91 readonly name: string;
92 /**
93 * The file this enumeration was declared in.
94 */
95 readonly file: DescFile;
96 /**
97 * The parent message, if this enumeration was declared inside a message declaration.
98 */
99 readonly parent: DescMessage | undefined;
100 /**
101 * Enumerations can be open or closed.
102 * See https://protobuf.dev/programming-guides/enum/
103 */
104 readonly open: boolean;
105 /**
106 * Values declared for this enumeration.
107 */
108 readonly values: DescEnumValue[];
109 /**
110 * All values of this enum by their number.
111 */
112 readonly value: Record<number, DescEnumValue>;
113 /**
114 * A prefix shared by all enum values.
115 * For example, `my_enum_` for `enum MyEnum {MY_ENUM_A=0; MY_ENUM_B=1;}`
116 */
117 readonly sharedPrefix?: string | undefined;
118 /**
119 * Marked as deprecated in the protobuf source.
120 */
121 readonly deprecated: boolean;
122 /**
123 * The compiler-generated descriptor.
124 */
125 readonly proto: EnumDescriptorProto;
126 toString(): string;
127 }
128 /**
129 * Describes an individual value of an enumeration in a protobuf source file.
130 */
131 export interface DescEnumValue {
132 readonly kind: "enum_value";
133 /**
134 * The name of the enumeration value, as specified in the protobuf source.
135 */
136 readonly name: string;
137 /**
138 * A safe and idiomatic name for the value in a TypeScript enum.
139 */
140 readonly localName: string;
141 /**
142 * The enumeration this value belongs to.
143 */
144 readonly parent: DescEnum;
145 /**
146 * The numeric enumeration value, as specified in the protobuf source.
147 */
148 readonly number: number;
149 /**
150 * Marked as deprecated in the protobuf source.
151 */
152 readonly deprecated: boolean;
153 /**
154 * The compiler-generated descriptor.
155 */
156 readonly proto: EnumValueDescriptorProto;
157 toString(): string;
158 }
159 /**
160 * Describes a message declaration in a protobuf source file.
161 */
162 export interface DescMessage {
163 readonly kind: "message";
164 /**
165 * The fully qualified name of the message. (We omit the leading dot.)
166 */
167 readonly typeName: string;
168 /**
169 * The name of the message, as specified in the protobuf source.
170 */
171 readonly name: string;
172 /**
173 * The file this message was declared in.
174 */
175 readonly file: DescFile;
176 /**
177 * The parent message, if this message was declared inside a message declaration.
178 */
179 readonly parent: DescMessage | undefined;
180 /**
181 * Fields declared for this message, including fields declared in a oneof
182 * group.
183 */
184 readonly fields: DescField[];
185 /**
186 * All fields of this message by their "localName".
187 */
188 readonly field: Record<string, DescField>;
189 /**
190 * Oneof groups declared for this message.
191 * This does not include synthetic oneofs for proto3 optionals.
192 */
193 readonly oneofs: DescOneof[];
194 /**
195 * Standalone fields and oneof groups for this message, ordered by
196 * their appearance in the protobuf source.
197 */
198 readonly members: (DescField | DescOneof)[];
199 /**
200 * Enumerations declared within the message, if any.
201 */
202 readonly nestedEnums: DescEnum[];
203 /**
204 * Messages declared within the message, if any.
205 * This does not include synthetic messages like map entries.
206 */
207 readonly nestedMessages: DescMessage[];
208 /**
209 * Extensions declared within the message, if any.
210 */
211 readonly nestedExtensions: DescExtension[];
212 /**
213 * Marked as deprecated in the protobuf source.
214 */
215 readonly deprecated: boolean;
216 /**
217 * The compiler-generated descriptor.
218 */
219 readonly proto: DescriptorProto;
220 toString(): string;
221 }
222 /**
223 * Describes a field declaration in a protobuf source file.
224 */
225 export type DescField = (descFieldScalar & descFieldCommon) | (descFieldList & descFieldCommon) | (descFieldMessage & descFieldCommon) | (descFieldEnum & descFieldCommon) | (descFieldMap & descFieldCommon);
226 type descFieldCommon = descFieldAndExtensionShared & {
227 readonly kind: "field";
228 /**
229 * The message this field is declared on.
230 */
231 readonly parent: DescMessage;
232 /**
233 * A safe and idiomatic name for the field as a property in ECMAScript.
234 */
235 readonly localName: string;
236 };
237 /**
238 * Describes an extension in a protobuf source file.
239 */
240 export type DescExtension = (Omit<descFieldScalar, "oneof"> & descExtensionCommon) | (Omit<descFieldEnum, "oneof"> & descExtensionCommon) | (Omit<descFieldMessage, "oneof"> & descExtensionCommon) | (descFieldList & descExtensionCommon);
241 type descExtensionCommon = descFieldAndExtensionShared & {
242 readonly kind: "extension";
243 /**
244 * The fully qualified name of the extension.
245 */
246 readonly typeName: string;
247 /**
248 * The file this extension was declared in.
249 */
250 readonly file: DescFile;
251 /**
252 * The parent message, if this extension was declared inside a message declaration.
253 */
254 readonly parent: DescMessage | undefined;
255 /**
256 * The message that this extension extends.
257 */
258 readonly extendee: DescMessage;
259 /**
260 * The `oneof` group this field belongs to, if any.
261 */
262 readonly oneof: undefined;
263 };
264 interface descFieldAndExtensionShared {
265 /**
266 * The field name, as specified in the protobuf source
267 */
268 readonly name: string;
269 /**
270 * The field number, as specified in the protobuf source.
271 */
272 readonly number: number;
273 /**
274 * The field name in JSON.
275 */
276 readonly jsonName: string;
277 /**
278 * Marked as deprecated in the protobuf source.
279 */
280 readonly deprecated: boolean;
281 /**
282 * Presence of the field.
283 * See https://protobuf.dev/programming-guides/field_presence/
284 */
285 readonly presence: SupportedFieldPresence;
286 /**
287 * Whether to reject invalid UTF-8 when reading this field from the binary
288 * wire format. Reflects the resolved `utf8_validation` feature: true for
289 * VERIFY (proto3 and editions 2023+ default), false for NONE (proto2
290 * default).
291 */
292 readonly utf8Validation: boolean;
293 /**
294 * The compiler-generated descriptor.
295 */
296 readonly proto: FieldDescriptorProto;
297 /**
298 * Get the edition features for this protobuf element.
299 */
300 toString(): string;
301 }
302 type descFieldSingularCommon = {
303 /**
304 * The `oneof` group this field belongs to, if any.
305 *
306 * This does not include synthetic oneofs for proto3 optionals.
307 */
308 readonly oneof: DescOneof | undefined;
309 };
310 type descFieldScalar<T extends ScalarType = ScalarType> = T extends T ? {
311 readonly fieldKind: "scalar";
312 /**
313 * Scalar type, if it is a scalar field.
314 */
315 readonly scalar: T;
316 /**
317 * By default, 64-bit integral types (int64, uint64, sint64, fixed64,
318 * sfixed64) are represented with BigInt.
319 *
320 * If the field option `jstype = JS_STRING` is set, this property
321 * is true, and 64-bit integral types are represented with String.
322 */
323 readonly longAsString: boolean;
324 /**
325 * The message type, if it is a message field.
326 */
327 readonly message: undefined;
328 /**
329 * The enum type, if it is an enum field.
330 */
331 readonly enum: undefined;
332 /**
333 * Return the default value specified in the protobuf source.
334 */
335 getDefaultValue(): ScalarValue<T> | undefined;
336 } & descFieldSingularCommon : never;
337 type descFieldMessage = {
338 readonly fieldKind: "message";
339 /**
340 * Scalar type, if it is a scalar field.
341 */
342 readonly scalar: undefined;
343 /**
344 * The message type, if it is a message field.
345 */
346 readonly message: DescMessage;
347 /**
348 * Encode the message delimited (a.k.a. proto2 group encoding), or
349 * length-prefixed?
350 */
351 readonly delimitedEncoding: boolean;
352 /**
353 * The enum type, if it is an enum field.
354 */
355 readonly enum: undefined;
356 /**
357 * Return the default value specified in the protobuf source.
358 */
359 getDefaultValue(): undefined;
360 } & descFieldSingularCommon;
361 type descFieldEnum = {
362 readonly fieldKind: "enum";
363 /**
364 * Scalar type, if it is a scalar field.
365 */
366 readonly scalar: undefined;
367 /**
368 * The message type, if it is a message field.
369 */
370 readonly message: undefined;
371 /**
372 * The enum type, if it is an enum field.
373 */
374 readonly enum: DescEnum;
375 /**
376 * Return the default value specified in the protobuf source.
377 */
378 getDefaultValue(): number | undefined;
379 } & descFieldSingularCommon;
380 type descFieldList = (descFieldListScalar & descFieldListCommon) | (descFieldListEnum & descFieldListCommon) | (descFieldListMessage & descFieldListCommon);
381 type descFieldListCommon = {
382 readonly fieldKind: "list";
383 /**
384 * Pack this repeated field? Only valid for repeated enum fields, and
385 * for repeated scalar fields except BYTES and STRING.
386 */
387 readonly packed: boolean;
388 /**
389 * The `oneof` group this field belongs to, if any.
390 */
391 readonly oneof: undefined;
392 };
393 type descFieldListScalar<T extends ScalarType = ScalarType> = T extends T ? {
394 readonly listKind: "scalar";
395 /**
396 * The enum list element type.
397 */
398 readonly enum: undefined;
399 /**
400 * The message list element type.
401 */
402 readonly message: undefined;
403 /**
404 * Scalar list element type.
405 */
406 readonly scalar: T;
407 /**
408 * By default, 64-bit integral types (int64, uint64, sint64, fixed64,
409 * sfixed64) are represented with BigInt.
410 *
411 * If the field option `jstype = JS_STRING` is set, this property
412 * is true, and 64-bit integral types are represented with String.
413 */
414 readonly longAsString: boolean;
415 } : never;
416 type descFieldListEnum = {
417 readonly listKind: "enum";
418 /**
419 * The enum list element type.
420 */
421 readonly enum: DescEnum;
422 /**
423 * The message list element type.
424 */
425 readonly message: undefined;
426 /**
427 * Scalar list element type.
428 */
429 readonly scalar: undefined;
430 };
431 type descFieldListMessage = {
432 readonly listKind: "message";
433 /**
434 * The enum list element type.
435 */
436 readonly enum: undefined;
437 /**
438 * The message list element type.
439 */
440 readonly message: DescMessage;
441 /**
442 * Scalar list element type.
443 */
444 readonly scalar: undefined;
445 /**
446 * Encode the message delimited (a.k.a. proto2 group encoding), or
447 * length-prefixed?
448 */
449 readonly delimitedEncoding: boolean;
450 };
451 type descFieldMap = (descFieldMapScalar & descFieldMapCommon) | (descFieldMapEnum & descFieldMapCommon) | (descFieldMapMessage & descFieldMapCommon);
452 type descFieldMapCommon<T extends ScalarType = ScalarType> = T extends Exclude<ScalarType, ScalarType.FLOAT | ScalarType.DOUBLE | ScalarType.BYTES> ? {
453 readonly fieldKind: "map";
454 /**
455 * The scalar map key type.
456 */
457 readonly mapKey: T;
458 /**
459 * The `oneof` group this field belongs to, if any.
460 */
461 readonly oneof: undefined;
462 /**
463 * Encode the map entry message delimited (a.k.a. proto2 group encoding),
464 * or length-prefixed? As of Edition 2023, this is always false for map fields,
465 * and also applies to map values, if they are messages.
466 */
467 readonly delimitedEncoding: false;
468 } : never;
469 type descFieldMapScalar<T extends ScalarType = ScalarType> = T extends T ? {
470 readonly mapKind: "scalar";
471 /**
472 * The enum map value type.
473 */
474 readonly enum: undefined;
475 /**
476 * The message map value type.
477 */
478 readonly message: undefined;
479 /**
480 * Scalar map value type.
481 */
482 readonly scalar: T;
483 } : never;
484 type descFieldMapEnum = {
485 readonly mapKind: "enum";
486 /**
487 * The enum map value type.
488 */
489 readonly enum: DescEnum;
490 /**
491 * The message map value type.
492 */
493 readonly message: undefined;
494 /**
495 * Scalar map value type.
496 */
497 readonly scalar: undefined;
498 };
499 type descFieldMapMessage = {
500 readonly mapKind: "message";
501 /**
502 * The enum map value type.
503 */
504 readonly enum: undefined;
505 /**
506 * The message map value type.
507 */
508 readonly message: DescMessage;
509 /**
510 * Scalar map value type.
511 */
512 readonly scalar: undefined;
513 };
514 /**
515 * Describes a oneof group in a protobuf source file.
516 */
517 export interface DescOneof {
518 readonly kind: "oneof";
519 /**
520 * The name of the oneof group, as specified in the protobuf source.
521 */
522 readonly name: string;
523 /**
524 * A safe and idiomatic name for the oneof group as a property in ECMAScript.
525 */
526 readonly localName: string;
527 /**
528 * The message this oneof group was declared in.
529 */
530 readonly parent: DescMessage;
531 /**
532 * The fields declared in this oneof group.
533 */
534 readonly fields: DescField[];
535 /**
536 * Marked as deprecated in the protobuf source.
537 * Note that oneof groups cannot be marked as deprecated, this property
538 * only exists for consistency and will always be false.
539 */
540 readonly deprecated: boolean;
541 /**
542 * The compiler-generated descriptor.
543 */
544 readonly proto: OneofDescriptorProto;
545 toString(): string;
546 }
547 /**
548 * Describes a service declaration in a protobuf source file.
549 */
550 export interface DescService {
551 readonly kind: "service";
552 /**
553 * The fully qualified name of the service. (We omit the leading dot.)
554 */
555 readonly typeName: string;
556 /**
557 * The name of the service, as specified in the protobuf source.
558 */
559 readonly name: string;
560 /**
561 * The file this service was declared in.
562 */
563 readonly file: DescFile;
564 /**
565 * The RPCs this service declares.
566 */
567 readonly methods: DescMethod[];
568 /**
569 * All methods of this service by their "localName".
570 */
571 readonly method: Record<string, DescMethod>;
572 /**
573 * Marked as deprecated in the protobuf source.
574 */
575 readonly deprecated: boolean;
576 /**
577 * The compiler-generated descriptor.
578 */
579 readonly proto: ServiceDescriptorProto;
580 toString(): string;
581 }
582 /**
583 * Describes an RPC declaration in a protobuf source file.
584 */
585 export interface DescMethod {
586 readonly kind: "rpc";
587 /**
588 * The name of the RPC, as specified in the protobuf source.
589 */
590 readonly name: string;
591 /**
592 * A safe and idiomatic name for the RPC as a method in ECMAScript.
593 */
594 readonly localName: string;
595 /**
596 * The parent service.
597 */
598 readonly parent: DescService;
599 /**
600 * One of the four available method types.
601 */
602 readonly methodKind: "unary" | "server_streaming" | "client_streaming" | "bidi_streaming";
603 /**
604 * The message type for requests.
605 */
606 readonly input: DescMessage;
607 /**
608 * The message type for responses.
609 */
610 readonly output: DescMessage;
611 /**
612 * The idempotency level declared in the protobuf source, if any.
613 */
614 readonly idempotency: MethodOptions_IdempotencyLevel;
615 /**
616 * Marked as deprecated in the protobuf source.
617 */
618 readonly deprecated: boolean;
619 /**
620 * The compiler-generated descriptor.
621 */
622 readonly proto: MethodDescriptorProto;
623 toString(): string;
624 }
625 /**
626 * Comments on an element in a protobuf source file.
627 */
628 export interface DescComments {
629 readonly leadingDetached: readonly string[];
630 readonly leading?: string | undefined;
631 readonly trailing?: string | undefined;
632 readonly sourcePath: readonly number[];
633 }
634 export {};