@bufbuild/protobuf 0.0.10 → 0.1.0

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 (38) hide show
  1. package/dist/cjs/create-registry-from-desc.js +2 -112
  2. package/dist/cjs/create-registry.js +1 -1
  3. package/dist/cjs/google/protobuf/descriptor_pb.js +2 -2
  4. package/dist/cjs/google/protobuf/empty_pb.js +0 -1
  5. package/dist/cjs/google/protobuf/struct_pb.js +1 -1
  6. package/dist/cjs/google/protobuf/type_pb.js +1 -1
  7. package/dist/cjs/google/varint.js +85 -37
  8. package/dist/cjs/index.js +1 -7
  9. package/dist/cjs/private/json-format-common.js +6 -6
  10. package/dist/cjs/proto-int64.js +23 -40
  11. package/dist/esm/create-registry-from-desc.js +1 -110
  12. package/dist/esm/create-registry.js +1 -1
  13. package/dist/esm/google/protobuf/descriptor_pb.js +2 -2
  14. package/dist/esm/google/protobuf/empty_pb.js +0 -1
  15. package/dist/esm/google/protobuf/struct_pb.js +1 -1
  16. package/dist/esm/google/protobuf/type_pb.js +1 -1
  17. package/dist/esm/google/varint.js +81 -34
  18. package/dist/esm/index.js +0 -3
  19. package/dist/esm/private/json-format-common.js +6 -6
  20. package/dist/esm/proto-int64.js +24 -41
  21. package/dist/types/create-registry-from-desc.d.ts +0 -34
  22. package/dist/types/create-registry.d.ts +1 -1
  23. package/dist/types/google/protobuf/descriptor_pb.d.ts +6 -6
  24. package/dist/types/google/protobuf/empty_pb.d.ts +0 -1
  25. package/dist/types/google/varint.d.ts +21 -9
  26. package/dist/types/index.d.ts +0 -3
  27. package/dist/types/message.d.ts +3 -1
  28. package/dist/types/proto-int64.d.ts +14 -13
  29. package/package.json +5 -9
  30. package/dist/cjs/legacy-descriptor-registry.js +0 -468
  31. package/dist/cjs/legacy-descriptor-set.js +0 -453
  32. package/dist/cjs/legacy-type-registry.js +0 -104
  33. package/dist/esm/legacy-descriptor-registry.js +0 -464
  34. package/dist/esm/legacy-descriptor-set.js +0 -449
  35. package/dist/esm/legacy-type-registry.js +0 -100
  36. package/dist/types/legacy-descriptor-registry.d.ts +0 -45
  37. package/dist/types/legacy-descriptor-set.d.ts +0 -152
  38. package/dist/types/legacy-type-registry.d.ts +0 -44
@@ -1,449 +0,0 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- import { FieldDescriptorProto_Label, FieldDescriptorProto_Type, MethodOptions_IdempotencyLevel, } from "./google/protobuf/descriptor_pb.js";
15
- import { assert } from "./private/assert.js";
16
- import { ScalarType } from "./field.js";
17
- import { MethodIdempotency, MethodKind } from "./service-type.js";
18
- /**
19
- * LegacyDescriptorSet wraps a set of google.protobuf.FileDescriptorProto,
20
- * asserting basic expectations and providing hierarchical information.
21
- *
22
- * Note that all types are kept by their fully qualified type name
23
- * with a leading dot.
24
- *
25
- * @deprecated
26
- */
27
- export class LegacyDescriptorSet {
28
- constructor() {
29
- this.enums = {};
30
- this.messages = {};
31
- this.services = {};
32
- }
33
- /**
34
- * May raise an error on invalid descriptors.
35
- */
36
- add(...files) {
37
- for (const file of files) {
38
- newFile(file, this);
39
- }
40
- }
41
- listEnums() {
42
- return Object.values(this.enums).filter(isDefined);
43
- }
44
- listMessages() {
45
- return Object.values(this.messages).filter(isDefined);
46
- }
47
- listServices() {
48
- return Object.values(this.services).filter(isDefined);
49
- }
50
- }
51
- function isDefined(v) {
52
- return v !== undefined;
53
- }
54
- const fieldTypeToScalarType = {
55
- [FieldDescriptorProto_Type.DOUBLE]: ScalarType.DOUBLE,
56
- [FieldDescriptorProto_Type.FLOAT]: ScalarType.FLOAT,
57
- [FieldDescriptorProto_Type.INT64]: ScalarType.INT64,
58
- [FieldDescriptorProto_Type.UINT64]: ScalarType.UINT64,
59
- [FieldDescriptorProto_Type.INT32]: ScalarType.INT32,
60
- [FieldDescriptorProto_Type.FIXED64]: ScalarType.FIXED64,
61
- [FieldDescriptorProto_Type.FIXED32]: ScalarType.FIXED32,
62
- [FieldDescriptorProto_Type.BOOL]: ScalarType.BOOL,
63
- [FieldDescriptorProto_Type.STRING]: ScalarType.STRING,
64
- [FieldDescriptorProto_Type.GROUP]: undefined,
65
- [FieldDescriptorProto_Type.MESSAGE]: undefined,
66
- [FieldDescriptorProto_Type.BYTES]: ScalarType.BYTES,
67
- [FieldDescriptorProto_Type.UINT32]: ScalarType.UINT32,
68
- [FieldDescriptorProto_Type.ENUM]: undefined,
69
- [FieldDescriptorProto_Type.SFIXED32]: ScalarType.SFIXED32,
70
- [FieldDescriptorProto_Type.SFIXED64]: ScalarType.SFIXED64,
71
- [FieldDescriptorProto_Type.SINT32]: ScalarType.SINT32,
72
- [FieldDescriptorProto_Type.SINT64]: ScalarType.SINT64,
73
- };
74
- function newFile(proto, ds) {
75
- assert(proto.name, `missing file descriptor name`);
76
- if (proto.syntax !== undefined && proto.syntax !== "proto3") {
77
- throw new Error(`invalid descriptor: unsupported syntax: ${proto.syntax}`);
78
- }
79
- const file = {
80
- proto,
81
- syntax: proto.syntax === "proto3" ? "proto3" : "proto2",
82
- name: proto.name.endsWith(".proto")
83
- ? proto.name.substring(-".proto".length)
84
- : proto.name,
85
- toString() {
86
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- we asserted above
87
- return `file ${this.proto.name}`;
88
- },
89
- };
90
- for (const messageType of proto.messageType) {
91
- newMessage(messageType, undefined, file, ds);
92
- }
93
- for (const enumType of proto.enumType) {
94
- newEnum(enumType, undefined, file, ds);
95
- }
96
- for (const extension of proto.extension) {
97
- newExtension(extension, undefined, file, ds);
98
- }
99
- for (const service of proto.service) {
100
- newService(service, file, ds);
101
- }
102
- return file;
103
- }
104
- function newEnum(proto, parent, file, us) {
105
- assert(proto.name, `invalid descriptor: missing enum descriptor name`);
106
- let protoTypeName;
107
- if (parent) {
108
- protoTypeName = `${parent.protoTypeName}.${proto.name}`;
109
- }
110
- else if (file.proto.package !== undefined) {
111
- protoTypeName = `.${file.proto.package}.${proto.name}`;
112
- }
113
- else {
114
- protoTypeName = `.${proto.name}`;
115
- }
116
- const values = [];
117
- const enumT = {
118
- proto,
119
- file,
120
- parent,
121
- name: proto.name,
122
- protoTypeName,
123
- typeName: protoTypeName.startsWith(".")
124
- ? protoTypeName.substring(1)
125
- : protoTypeName,
126
- values,
127
- toString() {
128
- return `enum ${this.typeName}`;
129
- },
130
- };
131
- us.enums[enumT.protoTypeName] = enumT;
132
- for (const value of proto.value) {
133
- values.push(newEnumValue(value, enumT));
134
- }
135
- return enumT;
136
- }
137
- function newEnumValue(proto, parent) {
138
- assert(proto.name, `invalid descriptor: missing enum value descriptor name`);
139
- assert(proto.number !== undefined, `invalid descriptor: missing enum value descriptor number`);
140
- return {
141
- proto,
142
- name: proto.name,
143
- number: proto.number,
144
- parent,
145
- toString() {
146
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- we asserted above
147
- return `enum value ${this.parent.typeName}.${this.proto.name}`;
148
- },
149
- };
150
- }
151
- function newMessage(proto, parent, file, us) {
152
- var _a;
153
- assert(proto.name, `invalid descriptor: missing name`);
154
- const nestedMessages = [];
155
- const fields = [];
156
- const oneofs = [];
157
- const nestedEnums = [];
158
- const nestedExtensions = [];
159
- let protoTypeName;
160
- if (parent) {
161
- protoTypeName = `${parent.protoTypeName}.${proto.name}`;
162
- }
163
- else if (file.proto.package !== undefined) {
164
- protoTypeName = `.${file.proto.package}.${proto.name}`;
165
- }
166
- else {
167
- protoTypeName = `.${proto.name}`;
168
- }
169
- const message = {
170
- proto,
171
- file,
172
- parent,
173
- name: proto.name,
174
- typeName: protoTypeName.startsWith(".")
175
- ? protoTypeName.substring(1)
176
- : protoTypeName,
177
- protoTypeName,
178
- fields,
179
- oneofs,
180
- nestedEnums,
181
- nestedMessages,
182
- nestedExtensions,
183
- toString() {
184
- return `message ${this.typeName}`;
185
- },
186
- };
187
- us.messages[message.protoTypeName] = message;
188
- for (const nestedType of proto.nestedType) {
189
- nestedMessages.push(newMessage(nestedType, message, file, us));
190
- }
191
- for (const oneofDecl of proto.oneofDecl) {
192
- oneofs.push(newOneof(oneofDecl, message, file));
193
- }
194
- for (const field of proto.field) {
195
- let oneof = undefined;
196
- if (field.oneofIndex !== undefined) {
197
- oneof = oneofs[field.oneofIndex];
198
- assert(oneof, `invalid descriptor: oneof declaration index ${field.oneofIndex} specified by field #${(_a = field.number) !== null && _a !== void 0 ? _a : -1} not found`);
199
- }
200
- fields.push(newField(field, message, oneof));
201
- }
202
- for (const enumType of proto.enumType) {
203
- nestedEnums.push(newEnum(enumType, message, file, us));
204
- }
205
- for (const extension of proto.extension) {
206
- nestedExtensions.push(newExtension(extension, message, file, us));
207
- }
208
- return message;
209
- }
210
- function newField(proto, parent, oneof) {
211
- var _a;
212
- assert(proto.name, `invalid descriptor: missing name`);
213
- assert(proto.number, `invalid descriptor: missing number`);
214
- assert(proto.type, `invalid descriptor: missing type`);
215
- let optional = false;
216
- let packed = ((_a = proto.options) === null || _a === void 0 ? void 0 : _a.packed) === true;
217
- switch (parent.file.syntax) {
218
- case "proto2":
219
- optional =
220
- oneof === undefined &&
221
- proto.label === FieldDescriptorProto_Label.OPTIONAL;
222
- break;
223
- case "proto3":
224
- optional = proto.proto3Optional === true;
225
- switch (proto.type) {
226
- case FieldDescriptorProto_Type.DOUBLE:
227
- case FieldDescriptorProto_Type.FLOAT:
228
- case FieldDescriptorProto_Type.INT64:
229
- case FieldDescriptorProto_Type.UINT64:
230
- case FieldDescriptorProto_Type.INT32:
231
- case FieldDescriptorProto_Type.FIXED64:
232
- case FieldDescriptorProto_Type.FIXED32:
233
- case FieldDescriptorProto_Type.UINT32:
234
- case FieldDescriptorProto_Type.SFIXED32:
235
- case FieldDescriptorProto_Type.SFIXED64:
236
- case FieldDescriptorProto_Type.SINT32:
237
- case FieldDescriptorProto_Type.SINT64:
238
- case FieldDescriptorProto_Type.BOOL:
239
- case FieldDescriptorProto_Type.ENUM:
240
- // From the proto3 language guide:
241
- // > In proto3, repeated fields of scalar numeric types are packed by default.
242
- // This information is incomplete - according to the conformance tests, BOOL
243
- // and ENUM are packed by default as well. This means only STRING and BYTES
244
- // are not packed by default, which makes sense because they are length-delimited.
245
- packed = true;
246
- break;
247
- case FieldDescriptorProto_Type.STRING:
248
- case FieldDescriptorProto_Type.GROUP:
249
- case FieldDescriptorProto_Type.MESSAGE:
250
- case FieldDescriptorProto_Type.BYTES:
251
- assert(!packed, `invalid descriptor: ${FieldDescriptorProto_Type[proto.type]} cannot be packed`);
252
- break;
253
- }
254
- break;
255
- }
256
- const field = {
257
- proto,
258
- name: proto.name,
259
- number: proto.number,
260
- type: proto.type,
261
- parent,
262
- oneof: proto.proto3Optional === true ? undefined : oneof,
263
- optional,
264
- packed,
265
- toString() {
266
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- we asserted above
267
- return `field ${parent.typeName}.${proto.name}`;
268
- },
269
- resolve(us) {
270
- return resolveField(this, us);
271
- },
272
- };
273
- if (oneof) {
274
- oneof.fields.push(field);
275
- }
276
- return field;
277
- }
278
- function resolveField(u, us) {
279
- var _a;
280
- const repeated = u.proto.label === FieldDescriptorProto_Label.REPEATED;
281
- switch (u.type) {
282
- case FieldDescriptorProto_Type.MESSAGE:
283
- case FieldDescriptorProto_Type.GROUP: {
284
- assert(u.proto.typeName, `invalid descriptor: ${u.toString()} has type ${FieldDescriptorProto_Type[u.type]}, but type_name is unset`);
285
- const refMessage = us.messages[u.proto.typeName];
286
- assert(refMessage, `invalid descriptor: cannot find type_name "${u.proto.typeName}" specified by ${u.toString()}`);
287
- if (((_a = refMessage.proto.options) === null || _a === void 0 ? void 0 : _a.mapEntry) !== undefined) {
288
- return Object.assign(Object.assign({}, u), { repeated: false, scalarType: undefined, message: undefined, enum: undefined, map: resolveMap(refMessage, us) });
289
- }
290
- return Object.assign(Object.assign({}, u), { repeated, scalarType: undefined, message: refMessage, enum: undefined, map: undefined });
291
- }
292
- case FieldDescriptorProto_Type.ENUM: {
293
- assert(u.proto.typeName, `invalid descriptor: ${u.toString()} has type ${FieldDescriptorProto_Type[u.type]}, but type_name is unset`);
294
- const refEnum = us.enums[u.proto.typeName];
295
- assert(refEnum, `invalid descriptor: cannot find type_name "${u.proto.typeName}" specified by ${u.toString()}`);
296
- return Object.assign(Object.assign({}, u), { repeated, scalarType: undefined, message: undefined, enum: refEnum, map: undefined });
297
- }
298
- default: {
299
- const scalarType = fieldTypeToScalarType[u.type];
300
- assert(scalarType, `invalid descriptor: unable to convert google.protobuf.FieldDescriptorProto.Type ${FieldDescriptorProto_Type[u.type]} to ScalarType`);
301
- return Object.assign(Object.assign({}, u), { repeated,
302
- scalarType, message: undefined, enum: undefined, map: undefined });
303
- }
304
- }
305
- }
306
- function resolveMap(mapEntry, us) {
307
- var _a;
308
- assert((_a = mapEntry.proto.options) === null || _a === void 0 ? void 0 : _a.mapEntry, `invalid descriptor: expected ${mapEntry.toString()} to be a map entry`);
309
- assert(mapEntry.fields.length === 2, `invalid descriptor: map entry ${mapEntry.toString()} has ${mapEntry.fields.length} fields`);
310
- const uKeyField = mapEntry.fields.find((f) => f.proto.number === 1);
311
- assert(uKeyField, `invalid descriptor: map entry ${mapEntry.toString()} is missing key field`);
312
- const keyField = resolveField(uKeyField, us);
313
- assert(keyField.scalarType !== undefined &&
314
- keyField.scalarType !== ScalarType.BYTES &&
315
- keyField.scalarType !== ScalarType.FLOAT &&
316
- keyField.scalarType !== ScalarType.DOUBLE, `invalid descriptor: map entry ${mapEntry.toString()} has unexpected key type ${FieldDescriptorProto_Type[keyField.type]}`);
317
- const uValueField = mapEntry.fields.find((f) => f.proto.number === 2);
318
- assert(uValueField, `invalid descriptor: map entry ${mapEntry.toString()} is missing value field`);
319
- const valueField = resolveField(uValueField, us);
320
- if (valueField.scalarType !== undefined) {
321
- return {
322
- key: keyField.scalarType,
323
- value: {
324
- scalarType: valueField.scalarType,
325
- enum: undefined,
326
- message: undefined,
327
- },
328
- };
329
- }
330
- if (valueField.enum !== undefined) {
331
- return {
332
- key: keyField.scalarType,
333
- value: { scalar: undefined, enum: valueField.enum, message: undefined },
334
- };
335
- }
336
- if (valueField.message !== undefined) {
337
- return {
338
- key: keyField.scalarType,
339
- value: {
340
- scalar: undefined,
341
- enum: undefined,
342
- message: valueField.message,
343
- },
344
- };
345
- }
346
- throw new Error(`invalid descriptor: map entry ${mapEntry.toString()} has unexpected value type ${FieldDescriptorProto_Type[keyField.type]}`);
347
- }
348
- function newOneof(proto, parent, file) {
349
- assert(proto.name, `invalid descriptor: missing oneof descriptor name`);
350
- return {
351
- proto,
352
- parent,
353
- file,
354
- fields: [],
355
- name: proto.name,
356
- toString() {
357
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- we asserted above
358
- return `oneof ${parent.typeName}.${proto.name}`;
359
- },
360
- };
361
- }
362
- function newExtension(proto, parent, file, us // eslint-disable-line @typescript-eslint/no-unused-vars
363
- ) {
364
- assert(proto.name, `invalid descriptor: missing field descriptor name`);
365
- return {
366
- proto,
367
- file,
368
- parent,
369
- };
370
- }
371
- function newService(proto, file, us) {
372
- assert(proto.name, `invalid descriptor: missing service descriptor name`);
373
- let protoTypeName;
374
- if (file.proto.package !== undefined) {
375
- protoTypeName = `.${file.proto.package}.${proto.name}`;
376
- }
377
- else {
378
- protoTypeName = `.${proto.name}`;
379
- }
380
- const methods = [];
381
- const service = {
382
- proto,
383
- file,
384
- typeName: protoTypeName.startsWith(".")
385
- ? protoTypeName.substring(1)
386
- : protoTypeName,
387
- protoTypeName,
388
- methods,
389
- toString() {
390
- return `service ${this.typeName}`;
391
- },
392
- };
393
- for (const method of proto.method) {
394
- methods.push(newMethod(method, service));
395
- }
396
- us.services[service.protoTypeName] = service;
397
- return service;
398
- }
399
- function newMethod(proto, parent) {
400
- var _a;
401
- assert(proto.name, `invalid descriptor: missing method descriptor name`);
402
- assert(proto.inputType, `invalid descriptor: missing method input type`);
403
- assert(proto.outputType, `invalid descriptor: missing method output type`);
404
- let kind;
405
- if (proto.clientStreaming === true && proto.serverStreaming === true) {
406
- kind = MethodKind.BiDiStreaming;
407
- }
408
- else if (proto.clientStreaming === true) {
409
- kind = MethodKind.ClientStreaming;
410
- }
411
- else if (proto.serverStreaming === true) {
412
- kind = MethodKind.ServerStreaming;
413
- }
414
- else {
415
- kind = MethodKind.Unary;
416
- }
417
- let idempotency;
418
- switch ((_a = proto.options) === null || _a === void 0 ? void 0 : _a.idempotencyLevel) {
419
- case MethodOptions_IdempotencyLevel.IDEMPOTENT:
420
- idempotency = MethodIdempotency.Idempotent;
421
- break;
422
- case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS:
423
- idempotency = MethodIdempotency.NoSideEffects;
424
- break;
425
- case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN:
426
- case undefined:
427
- idempotency = undefined;
428
- break;
429
- }
430
- const inputTypeName = proto.inputType.startsWith(".")
431
- ? proto.inputType.substring(1)
432
- : proto.inputType;
433
- const outputTypeName = proto.outputType.startsWith(".")
434
- ? proto.outputType.substring(1)
435
- : proto.outputType;
436
- return {
437
- proto,
438
- parent,
439
- name: proto.name,
440
- kind,
441
- idempotency,
442
- inputTypeName,
443
- outputTypeName,
444
- toString() {
445
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- we asserted above
446
- return `rpc ${this.parent.typeName}.${proto.name}`;
447
- },
448
- };
449
- }
@@ -1,100 +0,0 @@
1
- // Copyright 2021-2022 Buf Technologies, Inc.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- /**
15
- * @deprecated use createRegistry() instead
16
- *
17
- * TypeRegistry is a simple registry for all message, enum, or service types.
18
- */
19
- export class TypeRegistry {
20
- constructor() {
21
- this.messages = {};
22
- this.enums = {};
23
- this.services = {};
24
- }
25
- /**
26
- * Find a message type by its protobuf type name.
27
- */
28
- findMessage(typeName) {
29
- return this.messages[typeName];
30
- }
31
- /**
32
- * Find an enum type by its protobuf type name.
33
- */
34
- findEnum(typeName) {
35
- return this.enums[typeName];
36
- }
37
- /**
38
- * Find a service type by its protobuf type name.
39
- */
40
- findService(typeName) {
41
- return this.services[typeName];
42
- }
43
- /**
44
- * Create a new TypeRegistry from the given types.
45
- */
46
- static from(...types) {
47
- const registry = new TypeRegistry();
48
- for (const type of types) {
49
- registry.add(type);
50
- }
51
- return registry;
52
- }
53
- /**
54
- * @deprecated use TypeRegistry.from()
55
- */
56
- static fromIterable(types) {
57
- return TypeRegistry.from(...types);
58
- }
59
- /**
60
- * @deprecated use TypeRegistry.from()
61
- */
62
- static fromTypes(...types) {
63
- return TypeRegistry.from(...types);
64
- }
65
- /**
66
- * Add a type to the registry. For messages, the types used in message
67
- * fields are added recursively. For services, the message types used
68
- * for requests and responses are added recursively.
69
- */
70
- add(type) {
71
- if ("fields" in type) {
72
- if (!this.findMessage(type.typeName)) {
73
- this.messages[type.typeName] = type;
74
- for (const field of type.fields.list()) {
75
- if (field.kind == "message") {
76
- this.add(field.T);
77
- }
78
- else if (field.kind == "map" && field.V.kind == "message") {
79
- this.add(field.V.T);
80
- }
81
- else if (field.kind == "enum") {
82
- this.add(field.T);
83
- }
84
- }
85
- }
86
- }
87
- else if ("methods" in type) {
88
- if (!this.findService(type.typeName)) {
89
- this.services[type.typeName] = type;
90
- for (const method of Object.values(type.methods)) {
91
- this.add(method.I);
92
- this.add(method.O);
93
- }
94
- }
95
- }
96
- else {
97
- this.enums[type.typeName] = type;
98
- }
99
- }
100
- }
@@ -1,45 +0,0 @@
1
- import type { FileDescriptorProto } from "./google/protobuf/descriptor_pb.js";
2
- import { FileDescriptorSet } from "./google/protobuf/descriptor_pb.js";
3
- import type { MessageType } from "./message-type.js";
4
- import type { EnumType } from "./enum.js";
5
- import { LegacyDescriptorSet } from "./legacy-descriptor-set.js";
6
- import type { IEnumTypeRegistry, IMessageTypeRegistry, IServiceTypeRegistry } from "./type-registry.js";
7
- import type { ServiceType } from "./service-type.js";
8
- import type { PartialMessage } from "./message.js";
9
- /**
10
- * LegacyDescriptorRegistry is a type registry that dynamically creates types
11
- * from a set of google.protobuf.FileDescriptorProto.
12
- *
13
- * By default, all well-known types with a specialized JSON representation
14
- * are replaced with their generated counterpart in this package.
15
- *
16
- * @deprecated
17
- */
18
- export declare class LegacyDescriptorRegistry implements IMessageTypeRegistry, IEnumTypeRegistry, IServiceTypeRegistry {
19
- private readonly ds;
20
- private readonly enums;
21
- private readonly messages;
22
- private readonly services;
23
- constructor(descriptorSet?: LegacyDescriptorSet, replaceWkt?: boolean);
24
- /**
25
- * Conveniently create a DescriptorRegistry from a FileDescriptorSet
26
- * instance or a FileDescriptorSet in binary format.
27
- */
28
- static fromFileDescriptorSet(bytesOrSet: Uint8Array | FileDescriptorSet | PartialMessage<FileDescriptorSet>): LegacyDescriptorRegistry;
29
- /**
30
- * May raise an error on invalid descriptors.
31
- */
32
- add(...files: FileDescriptorProto[]): void;
33
- /**
34
- * May raise an error on invalid descriptors.
35
- */
36
- findEnum(typeName: string): EnumType | undefined;
37
- /**
38
- * May raise an error on invalid descriptors.
39
- */
40
- findMessage(typeName: string): MessageType | undefined;
41
- /**
42
- * May raise an error on invalid descriptors.
43
- */
44
- findService(typeName: string): ServiceType | undefined;
45
- }