@bufbuild/protobuf 0.0.6 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +34 -4
  2. package/dist/cjs/binary-encoding.js +2 -2
  3. package/dist/cjs/codegen-info.js +60 -0
  4. package/dist/cjs/create-descriptor-set.js +952 -0
  5. package/dist/cjs/create-registry-from-desc.js +376 -0
  6. package/dist/cjs/create-registry.js +75 -0
  7. package/dist/cjs/descriptor-set.js +0 -458
  8. package/dist/cjs/google/protobuf/any_pb.js +4 -2
  9. package/dist/cjs/google/protobuf/duration_pb.js +1 -1
  10. package/dist/cjs/google/protobuf/struct_pb.js +2 -2
  11. package/dist/cjs/google/protobuf/type_pb.js +1 -1
  12. package/dist/cjs/index.js +17 -7
  13. package/dist/cjs/{descriptor-registry.js → legacy-descriptor-registry.js} +35 -69
  14. package/dist/cjs/legacy-descriptor-set.js +453 -0
  15. package/dist/cjs/legacy-type-registry.js +104 -0
  16. package/dist/cjs/message.js +2 -1
  17. package/dist/cjs/private/binary-format-common.js +4 -3
  18. package/dist/cjs/private/binary-format-proto2.js +3 -6
  19. package/dist/cjs/private/binary-format-proto3.js +2 -5
  20. package/dist/cjs/private/enum.js +22 -31
  21. package/dist/cjs/private/field-wrapper.js +30 -1
  22. package/dist/cjs/private/field.js +1 -1
  23. package/dist/cjs/private/json-format-common.js +6 -5
  24. package/dist/cjs/private/message-type.js +2 -1
  25. package/dist/cjs/private/names.js +168 -29
  26. package/dist/cjs/proto-int64.js +1 -1
  27. package/dist/cjs/proto2.js +7 -9
  28. package/dist/cjs/proto3.js +10 -13
  29. package/dist/cjs/type-registry.js +0 -87
  30. package/dist/esm/binary-encoding.js +2 -2
  31. package/dist/esm/codegen-info.js +57 -0
  32. package/dist/esm/create-descriptor-set.js +947 -0
  33. package/dist/esm/create-registry-from-desc.js +371 -0
  34. package/dist/esm/create-registry.js +71 -0
  35. package/dist/esm/descriptor-set.js +1 -456
  36. package/dist/esm/google/protobuf/any_pb.js +4 -2
  37. package/dist/esm/google/protobuf/duration_pb.js +1 -1
  38. package/dist/esm/google/protobuf/struct_pb.js +2 -2
  39. package/dist/esm/google/protobuf/type_pb.js +1 -1
  40. package/dist/esm/index.js +9 -3
  41. package/dist/esm/{descriptor-registry.js → legacy-descriptor-registry.js} +33 -67
  42. package/dist/esm/legacy-descriptor-set.js +449 -0
  43. package/dist/esm/legacy-type-registry.js +100 -0
  44. package/dist/esm/message.js +2 -1
  45. package/dist/esm/private/binary-format-common.js +4 -3
  46. package/dist/esm/private/binary-format-proto2.js +3 -6
  47. package/dist/esm/private/binary-format-proto3.js +2 -5
  48. package/dist/esm/private/enum.js +22 -31
  49. package/dist/esm/private/field-wrapper.js +28 -0
  50. package/dist/esm/private/field.js +2 -2
  51. package/dist/esm/private/json-format-common.js +6 -5
  52. package/dist/esm/private/message-type.js +2 -1
  53. package/dist/esm/private/names.js +163 -24
  54. package/dist/esm/proto-int64.js +1 -1
  55. package/dist/esm/proto2.js +8 -10
  56. package/dist/esm/proto3.js +11 -14
  57. package/dist/esm/type-registry.js +1 -85
  58. package/dist/types/codegen-info.d.ts +19 -0
  59. package/dist/types/create-descriptor-set.d.ts +16 -0
  60. package/dist/types/create-registry-from-desc.d.ts +49 -0
  61. package/dist/types/create-registry.d.ts +8 -0
  62. package/dist/types/descriptor-set.d.ts +554 -108
  63. package/dist/types/enum.d.ts +9 -5
  64. package/dist/types/index.d.ts +9 -3
  65. package/dist/types/{descriptor-registry.d.ts → legacy-descriptor-registry.d.ts} +8 -6
  66. package/dist/types/legacy-descriptor-set.d.ts +152 -0
  67. package/dist/types/legacy-type-registry.d.ts +44 -0
  68. package/dist/types/private/enum.d.ts +4 -8
  69. package/dist/types/private/field-wrapper.d.ts +7 -0
  70. package/dist/types/private/message-type.d.ts +1 -4
  71. package/dist/types/private/names.d.ts +26 -8
  72. package/dist/types/private/proto-runtime.d.ts +2 -2
  73. package/dist/types/private/util.d.ts +1 -6
  74. package/dist/types/type-registry.d.ts +0 -38
  75. package/package.json +4 -3
@@ -1,150 +1,596 @@
1
- import type { DescriptorProto, EnumDescriptorProto, EnumValueDescriptorProto, FieldDescriptorProto, OneofDescriptorProto } from "./google/protobuf/descriptor_pb.js";
2
- import { FieldDescriptorProto_Type, FileDescriptorProto, MethodDescriptorProto, ServiceDescriptorProto } from "./google/protobuf/descriptor_pb.js";
3
- import { ScalarType } from "./field.js";
4
- import { MethodIdempotency, MethodKind } from "./service-type.js";
1
+ import type { DescriptorProto, EnumDescriptorProto, EnumValueDescriptorProto, FieldDescriptorProto, FileDescriptorProto, MethodDescriptorProto, OneofDescriptorProto, ServiceDescriptorProto } from "./google/protobuf/descriptor_pb.js";
2
+ import type { ScalarType } from "./field.js";
3
+ import type { MethodIdempotency, MethodKind } from "./service-type.js";
5
4
  /**
6
- * DescriptorSet wraps a set of google.protobuf.FileDescriptorProto,
7
- * asserting basic expectations and providing hierarchical information.
5
+ * DescriptorSet provides a convenient interface for working with a set
6
+ * of google.protobuf.FileDescriptorProto.
8
7
  *
9
- * Note that all types are kept by their fully qualified type name
10
- * with a leading dot.
8
+ * When protobuf sources are compiled, each file is parsed into a
9
+ * google.protobuf.FileDescriptorProto. Those messages describe all parts
10
+ * of the source file that are required to generate code for them.
11
11
  */
12
- export declare class DescriptorSet implements UnresolvedSet {
13
- readonly enums: Record<string, UnresolvedEnum | undefined>;
14
- readonly messages: Record<string, UnresolvedMessage | undefined>;
15
- readonly services: Record<string, UnresolvedService | undefined>;
12
+ export interface DescriptorSet {
16
13
  /**
17
- * May raise an error on invalid descriptors.
14
+ * All files, in the order they were added to the set.
18
15
  */
19
- add(...files: FileDescriptorProto[]): void;
20
- listEnums(): UnresolvedEnum[];
21
- listMessages(): UnresolvedMessage[];
22
- listServices(): UnresolvedService[];
23
- }
24
- interface UnresolvedSet {
25
- readonly enums: Record<string, UnresolvedEnum | undefined>;
26
- readonly messages: Record<string, UnresolvedMessage | undefined>;
27
- readonly services: Record<string, UnresolvedService | undefined>;
16
+ readonly files: DescFile[];
17
+ /**
18
+ * All enumerations, indexed by their fully qualified type name.
19
+ * (We omit the leading dot.)
20
+ */
21
+ readonly enums: ReadonlyMap<string, DescEnum>;
22
+ /**
23
+ * All messages, indexed by their fully qualified type name.
24
+ * (We omit the leading dot.)
25
+ */
26
+ readonly messages: ReadonlyMap<string, DescMessage>;
27
+ /**
28
+ * All services, indexed by their fully qualified type name.
29
+ * (We omit the leading dot.)
30
+ */
31
+ readonly services: ReadonlyMap<string, DescService>;
32
+ /**
33
+ * All extensions, indexed by their fully qualified type name.
34
+ */
35
+ readonly extensions: ReadonlyMap<string, DescExtension>;
28
36
  }
29
- interface File {
30
- readonly proto: FileDescriptorProto;
37
+ /**
38
+ * Describes a protobuf source file.
39
+ */
40
+ export interface DescFile {
41
+ kind: "file";
42
+ /**
43
+ * The syntax specified in the protobuf source.
44
+ */
31
45
  readonly syntax: "proto3" | "proto2";
46
+ /**
47
+ * The name of the file, excluding the .proto suffix.
48
+ * For a protobuf file `foo/bar.proto`, this is `foo/bar`.
49
+ */
32
50
  readonly name: string;
51
+ /**
52
+ * Top-level enumerations declared in this file.
53
+ * Note that more enumerations might be declared within message declarations.
54
+ */
55
+ readonly enums: DescEnum[];
56
+ /**
57
+ * Top-level messages declared in this file.
58
+ * Note that more messages might be declared within message declarations.
59
+ */
60
+ readonly messages: DescMessage[];
61
+ /**
62
+ * Top-level extensions declared in this file.
63
+ * Note that more extensions might be declared within message declarations.
64
+ */
65
+ readonly extensions: DescExtension[];
66
+ /**
67
+ * Services declared in this file.
68
+ */
69
+ readonly services: DescService[];
70
+ /**
71
+ * Marked as deprecated in the protobuf source.
72
+ */
73
+ readonly deprecated: boolean;
74
+ /**
75
+ * The compiler-generated descriptor.
76
+ */
77
+ readonly proto: FileDescriptorProto;
78
+ /**
79
+ * Get comments on the syntax element in the protobuf source.
80
+ */
81
+ getSyntaxComments(): DescComments;
82
+ /**
83
+ * Get comments on the package element in the protobuf source.
84
+ */
85
+ getPackageComments(): DescComments;
33
86
  toString(): string;
34
87
  }
35
- interface UnresolvedEnum {
36
- readonly proto: EnumDescriptorProto;
37
- readonly file: File;
38
- readonly parent: UnresolvedMessage | undefined;
39
- readonly name: string;
88
+ /**
89
+ * Describes an enumeration in a protobuf source file.
90
+ */
91
+ export interface DescEnum {
92
+ kind: "enum";
93
+ /**
94
+ * The fully qualified name of the enumeration. (We omit the leading dot.)
95
+ */
40
96
  readonly typeName: string;
41
- readonly protoTypeName: string;
42
- readonly values: UnresolvedEnumValue[];
97
+ /**
98
+ * The name of the enumeration, as declared in the protobuf source.
99
+ */
100
+ readonly name: string;
101
+ /**
102
+ * The file this enumeration was declared in.
103
+ */
104
+ readonly file: DescFile;
105
+ /**
106
+ * The parent message, if this enumeration was declared inside a message declaration.
107
+ */
108
+ readonly parent: DescMessage | undefined;
109
+ /**
110
+ * Values declared for this enumeration.
111
+ */
112
+ readonly values: 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;
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
+ /**
127
+ * Get comments on the element in the protobuf source.
128
+ */
129
+ getComments(): DescComments;
43
130
  toString(): string;
44
131
  }
45
- interface UnresolvedEnumValue {
46
- readonly proto: EnumValueDescriptorProto;
47
- readonly parent: UnresolvedEnum;
132
+ /**
133
+ * Describes an individual value of an enumeration in a protobuf source file.
134
+ */
135
+ export interface DescEnumValue {
136
+ kind: "enum_value";
137
+ /**
138
+ * The name of the enumeration value, as specified in the protobuf source.
139
+ */
48
140
  readonly name: 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
+ */
49
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
+ /**
158
+ * Return a string that (closely) matches the definition of the enumeration
159
+ * value in the protobuf source.
160
+ */
161
+ declarationString(): string;
162
+ /**
163
+ * Get comments on the element in the protobuf source.
164
+ */
165
+ getComments(): DescComments;
50
166
  toString(): string;
51
167
  }
52
- interface UnresolvedMessage {
53
- readonly proto: DescriptorProto;
54
- readonly file: File;
55
- readonly parent: UnresolvedMessage | undefined;
56
- readonly name: string;
168
+ /**
169
+ * Describes a message declaration in a protobuf source file.
170
+ */
171
+ export interface DescMessage {
172
+ kind: "message";
173
+ /**
174
+ * The fully qualified name of the message. (We omit the leading dot.)
175
+ */
57
176
  readonly typeName: string;
58
- readonly protoTypeName: string;
59
- readonly fields: UnresolvedField[];
60
- readonly oneofs: UnresolvedOneof[];
61
- readonly nestedEnums: UnresolvedEnum[];
62
- readonly nestedMessages: UnresolvedMessage[];
63
- readonly nestedExtensions: UnresolvedExtension[];
177
+ /**
178
+ * The name of the message, as specified in the protobuf source.
179
+ */
180
+ readonly name: string;
181
+ /**
182
+ * The file this message was declared in.
183
+ */
184
+ readonly file: DescFile;
185
+ /**
186
+ * The parent message, if this message was declared inside a message declaration.
187
+ */
188
+ readonly parent: DescMessage | undefined;
189
+ /**
190
+ * Fields declared for this message, including fields declared in a oneof
191
+ * group.
192
+ */
193
+ readonly fields: DescField[];
194
+ /**
195
+ * Oneof groups declared for this message.
196
+ * This does not include synthetic oneofs for proto3 optionals.
197
+ */
198
+ readonly oneofs: DescOneof[];
199
+ /**
200
+ * Fields and oneof groups for this message, ordered by their appearance in the
201
+ * protobuf source.
202
+ */
203
+ readonly members: (DescField | DescOneof)[];
204
+ /**
205
+ * Enumerations declared within the message, if any.
206
+ */
207
+ readonly nestedEnums: DescEnum[];
208
+ /**
209
+ * Messages declared within the message, if any.
210
+ * This does not include synthetic messages like map entries.
211
+ */
212
+ readonly nestedMessages: DescMessage[];
213
+ /**
214
+ * Extensions declared within the message, if any.
215
+ */
216
+ readonly nestedExtensions: DescExtension[];
217
+ /**
218
+ * Marked as deprecated in the protobuf source.
219
+ */
220
+ readonly deprecated: boolean;
221
+ /**
222
+ * The compiler-generated descriptor.
223
+ */
224
+ readonly proto: DescriptorProto;
225
+ /**
226
+ * Get comments on the element in the protobuf source.
227
+ */
228
+ getComments(): DescComments;
64
229
  toString(): string;
65
230
  }
66
- interface UnresolvedField {
67
- readonly proto: FieldDescriptorProto;
68
- readonly number: number;
231
+ /**
232
+ * Describes a field declaration in a protobuf source file.
233
+ */
234
+ export declare type DescField = DescFieldCommon & (DescFieldScalar | DescFieldMessage | DescFieldEnum | DescFieldMap) & {
235
+ /**
236
+ * The message this field is declared on.
237
+ */
238
+ readonly parent: DescMessage;
239
+ };
240
+ /**
241
+ * Describes an extension in a protobuf source file.
242
+ */
243
+ export declare type DescExtension = DescFieldCommon & (DescFieldScalar | DescFieldMessage | DescFieldEnum | DescFieldMap) & {
244
+ /**
245
+ * The fully qualified name of the extension.
246
+ */
247
+ readonly typeName: string;
248
+ /**
249
+ * The file this extension was declared in.
250
+ */
251
+ readonly file: DescFile;
252
+ /**
253
+ * The parent message, if this extension was declared inside a message declaration.
254
+ */
255
+ readonly parent: DescMessage | undefined;
256
+ /**
257
+ * The message that this extension extends.
258
+ */
259
+ readonly extendee: DescMessage;
260
+ };
261
+ interface DescFieldCommon {
262
+ /**
263
+ * The field name, as specified in the protobuf source
264
+ */
69
265
  readonly name: string;
70
- readonly type: FieldDescriptorProto_Type;
71
- readonly parent: UnresolvedMessage;
72
- readonly oneof: UnresolvedOneof | undefined;
266
+ /**
267
+ * The field number, as specified in the protobuf source.
268
+ */
269
+ readonly number: number;
270
+ /**
271
+ * The `oneof` group this field belongs to, if any.
272
+ */
273
+ readonly oneof: DescOneof | undefined;
274
+ /**
275
+ * Whether this field was declared with `optional` in the protobuf source.
276
+ */
73
277
  readonly optional: boolean;
278
+ /**
279
+ * Pack this repeated field?
280
+ */
74
281
  readonly packed: boolean;
282
+ /**
283
+ * Is this field packed by default? Only valid for enum fields, and for
284
+ * scalar fields except BYTES and STRING.
285
+ * In proto3 syntax, fields are packed by default. In proto2 syntax, fields
286
+ * are unpacked by default.
287
+ */
288
+ readonly packedByDefault: boolean;
289
+ /**
290
+ * A user-defined name for the JSON format, set with the field option
291
+ * [json_name="foo"].
292
+ */
293
+ readonly jsonName: string | undefined;
294
+ /**
295
+ * Marked as deprecated in the protobuf source.
296
+ */
297
+ readonly deprecated: boolean;
298
+ /**
299
+ * The compiler-generated descriptor.
300
+ */
301
+ readonly proto: FieldDescriptorProto;
302
+ /**
303
+ * Get comments on the element in the protobuf source.
304
+ */
305
+ getComments(): DescComments;
306
+ /**
307
+ * Return a string that (closely) matches the definition of the field in the
308
+ * protobuf source.
309
+ */
310
+ declarationString(): string;
75
311
  toString(): string;
76
- resolve(us: UnresolvedSet): ResolvedField;
77
312
  }
78
- declare type ResolvedField = (UnresolvedField & {
79
- repeated: boolean;
80
- readonly scalarType: ScalarType;
313
+ interface DescFieldScalar {
314
+ readonly kind: "scalar_field";
315
+ /**
316
+ * Is the field repeated?
317
+ */
318
+ readonly repeated: boolean;
319
+ /**
320
+ * Scalar type, if it is a scalar field.
321
+ */
322
+ readonly scalar: ScalarType;
323
+ /**
324
+ * The message type, if it is a message field.
325
+ */
81
326
  readonly message: undefined;
327
+ /**
328
+ * The enum type, if it is an enum field.
329
+ */
82
330
  readonly enum: undefined;
83
- readonly map: undefined;
84
- }) | (UnresolvedField & {
85
- repeated: boolean;
86
- readonly scalarType: undefined;
87
- readonly message: UnresolvedMessage;
331
+ /**
332
+ * The map key type, if this is a map field.
333
+ */
334
+ readonly mapKey: undefined;
335
+ /**
336
+ * The map value type, if this is a map field.
337
+ */
338
+ readonly mapValue: undefined;
339
+ /**
340
+ * Return the default value specified in the protobuf source.
341
+ * Only valid for proto2 syntax.
342
+ */
343
+ getDefaultValue(): number | boolean | string | bigint | Uint8Array | undefined;
344
+ }
345
+ interface DescFieldMessage {
346
+ readonly kind: "message_field";
347
+ /**
348
+ * Is the field repeated?
349
+ */
350
+ readonly repeated: boolean;
351
+ /**
352
+ * Scalar type, if it is a scalar field.
353
+ */
354
+ readonly scalar: undefined;
355
+ /**
356
+ * The message type, if it is a message field.
357
+ */
358
+ readonly message: DescMessage;
359
+ /**
360
+ * The enum type, if it is an enum field.
361
+ */
88
362
  readonly enum: undefined;
89
- readonly map: undefined;
90
- }) | (UnresolvedField & {
91
- repeated: boolean;
92
- readonly scalarType: undefined;
363
+ /**
364
+ * The map key type, if this is a map field.
365
+ */
366
+ readonly mapKey: undefined;
367
+ /**
368
+ * The map value type, if this is a map field.
369
+ */
370
+ readonly mapValue: undefined;
371
+ }
372
+ interface DescFieldEnum {
373
+ readonly kind: "enum_field";
374
+ /**
375
+ * Is the field repeated?
376
+ */
377
+ readonly repeated: boolean;
378
+ /**
379
+ * Scalar type, if it is a scalar field.
380
+ */
381
+ readonly scalar: undefined;
382
+ /**
383
+ * The message type, if it is a message field.
384
+ */
93
385
  readonly message: undefined;
94
- readonly enum: UnresolvedEnum;
95
- readonly map: undefined;
96
- }) | (UnresolvedField & {
97
- repeated: false;
98
- readonly scalarType: undefined;
386
+ /**
387
+ * The enum type, if it is an enum field.
388
+ */
389
+ readonly enum: DescEnum;
390
+ /**
391
+ * The map key type, if this is a map field.
392
+ */
393
+ readonly mapKey: undefined;
394
+ /**
395
+ * The map value type, if this is a map field.
396
+ */
397
+ readonly mapValue: undefined;
398
+ /**
399
+ * Return the default value specified in the protobuf source.
400
+ * Only valid for proto2 syntax.
401
+ */
402
+ getDefaultValue(): number | boolean | string | bigint | Uint8Array | undefined;
403
+ }
404
+ interface DescFieldMap {
405
+ readonly kind: "map_field";
406
+ /**
407
+ * Is the field repeated?
408
+ */
409
+ readonly repeated: false;
410
+ /**
411
+ * Scalar type, if it is a scalar field.
412
+ */
413
+ readonly scalar: undefined;
414
+ /**
415
+ * The message type, if it is a message field.
416
+ */
99
417
  readonly message: undefined;
418
+ /**
419
+ * The enum type, if it is an enum field.
420
+ */
100
421
  readonly enum: undefined;
101
- readonly map: Map;
102
- });
103
- declare type Map = {
104
- key: Exclude<ScalarType, ScalarType.FLOAT | ScalarType.DOUBLE | ScalarType.BYTES>;
105
- value: {
106
- enum: UnresolvedEnum;
107
- message: undefined;
108
- scalar: undefined;
109
- } | {
110
- enum: undefined;
111
- message: UnresolvedMessage;
112
- scalar: undefined;
113
- } | {
114
- enum: undefined;
115
- message: undefined;
116
- scalarType: ScalarType;
117
- };
118
- };
119
- interface UnresolvedOneof {
120
- readonly proto: OneofDescriptorProto;
422
+ /**
423
+ * The map key type, if this is a map field.
424
+ */
425
+ readonly mapKey: Exclude<ScalarType, ScalarType.FLOAT | ScalarType.DOUBLE | ScalarType.BYTES>;
426
+ /**
427
+ * The map value type, if this is a map field.
428
+ */
429
+ readonly mapValue: DescFieldMapValueEnum | DescFieldMapValueMessage | DescFieldMapValueScalar;
430
+ }
431
+ interface DescFieldMapValueEnum {
432
+ readonly kind: "enum";
433
+ /**
434
+ * The enum type, if this is a map field with enum values.
435
+ */
436
+ readonly enum: DescEnum;
437
+ /**
438
+ * The message this message field uses.
439
+ */
440
+ readonly message: undefined;
441
+ /**
442
+ * Scalar type, if this is a map field with scalar values.
443
+ */
444
+ readonly scalar: undefined;
445
+ }
446
+ interface DescFieldMapValueMessage {
447
+ readonly kind: "message";
448
+ /**
449
+ * The enum type, if this is a map field with enum values.
450
+ */
451
+ readonly enum: undefined;
452
+ /**
453
+ * The message type, if this is a map field with message values.
454
+ */
455
+ readonly message: DescMessage;
456
+ /**
457
+ * Scalar type, if this is a map field with scalar values.
458
+ */
459
+ readonly scalar: undefined;
460
+ }
461
+ interface DescFieldMapValueScalar {
462
+ readonly kind: "scalar";
463
+ /**
464
+ * The enum type, if this is a map field with enum values.
465
+ */
466
+ readonly enum: undefined;
467
+ /**
468
+ * The message type, if this is a map field with message values.
469
+ */
470
+ readonly message: undefined;
471
+ /**
472
+ * Scalar type, if this is a map field with scalar values.
473
+ */
474
+ readonly scalar: ScalarType;
475
+ }
476
+ /**
477
+ * Describes a oneof group in a protobuf source file.
478
+ */
479
+ export interface DescOneof {
480
+ kind: "oneof";
481
+ /**
482
+ * The name of the oneof group, as specified in the protobuf source.
483
+ */
121
484
  readonly name: string;
122
- readonly parent: UnresolvedMessage;
123
- readonly file: File;
124
- readonly fields: UnresolvedField[];
485
+ /**
486
+ * The message this oneof group was declared in.
487
+ */
488
+ readonly parent: DescMessage;
489
+ /**
490
+ * The fields declared in this oneof group.
491
+ */
492
+ readonly fields: DescField[];
493
+ /**
494
+ * Marked as deprecated in the protobuf source.
495
+ * Note that oneof groups cannot be marked as deprecated, this property
496
+ * only exists for consistency and will always be false.
497
+ */
498
+ readonly deprecated: boolean;
499
+ /**
500
+ * The compiler-generated descriptor.
501
+ */
502
+ readonly proto: OneofDescriptorProto;
503
+ /**
504
+ * Get comments on the element in the protobuf source.
505
+ */
506
+ getComments(): DescComments;
125
507
  toString(): string;
126
508
  }
127
- interface UnresolvedExtension {
128
- readonly proto: FieldDescriptorProto;
129
- readonly parent: UnresolvedMessage | undefined;
130
- readonly file: File;
131
- }
132
- interface UnresolvedService {
133
- readonly proto: ServiceDescriptorProto;
134
- readonly file: File;
135
- readonly methods: UnresolvedMethod[];
509
+ /**
510
+ * Describes a service declaration in a protobuf source file.
511
+ */
512
+ export interface DescService {
513
+ kind: "service";
514
+ /**
515
+ * The fully qualified name of the service. (We omit the leading dot.)
516
+ */
136
517
  readonly typeName: string;
137
- readonly protoTypeName: string;
518
+ /**
519
+ * The name of the service, as specified in the protobuf source.
520
+ */
521
+ readonly name: string;
522
+ /**
523
+ * The file this service was declared in.
524
+ */
525
+ readonly file: DescFile;
526
+ /**
527
+ * The RPCs this service declares.
528
+ */
529
+ readonly methods: DescMethod[];
530
+ /**
531
+ * Marked as deprecated in the protobuf source.
532
+ */
533
+ readonly deprecated: boolean;
534
+ /**
535
+ * The compiler-generated descriptor.
536
+ */
537
+ readonly proto: ServiceDescriptorProto;
538
+ /**
539
+ * Get comments on the element in the protobuf source.
540
+ */
541
+ getComments(): DescComments;
138
542
  toString(): string;
139
543
  }
140
- interface UnresolvedMethod {
141
- readonly proto: MethodDescriptorProto;
142
- readonly parent: UnresolvedService;
544
+ /**
545
+ * Describes an RPC declaration in a protobuf source file.
546
+ */
547
+ export interface DescMethod {
548
+ kind: "rpc";
549
+ /**
550
+ * The name of the RPC, as specified in the protobuf source.
551
+ */
143
552
  readonly name: string;
144
- readonly kind: MethodKind;
145
- readonly inputTypeName: string;
146
- readonly outputTypeName: string;
553
+ /**
554
+ * The parent service.
555
+ */
556
+ readonly parent: DescService;
557
+ /**
558
+ * One of the four available method types.
559
+ */
560
+ readonly methodKind: MethodKind;
561
+ /**
562
+ * The message type for requests.
563
+ */
564
+ readonly input: DescMessage;
565
+ /**
566
+ * The message type for responses.
567
+ */
568
+ readonly output: DescMessage;
569
+ /**
570
+ * The idempotency level declared in the protobuf source, if any.
571
+ */
147
572
  readonly idempotency?: MethodIdempotency;
573
+ /**
574
+ * Marked as deprecated in the protobuf source.
575
+ */
576
+ readonly deprecated: boolean;
577
+ /**
578
+ * The compiler-generated descriptor.
579
+ */
580
+ readonly proto: MethodDescriptorProto;
581
+ /**
582
+ * Get comments on the element in the protobuf source.
583
+ */
584
+ getComments(): DescComments;
148
585
  toString(): string;
149
586
  }
587
+ /**
588
+ * Comments on an element in a protobuf source file.
589
+ */
590
+ export interface DescComments {
591
+ readonly leadingDetached: readonly string[];
592
+ readonly leading?: string;
593
+ readonly trailing?: string;
594
+ readonly sourcePath: readonly number[];
595
+ }
150
596
  export {};