protobufjs 8.2.0 → 8.3.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.
- package/README.md +113 -75
- package/dist/light/protobuf.js +119 -55
- package/dist/light/protobuf.js.map +1 -1
- package/dist/light/protobuf.min.js +3 -3
- package/dist/light/protobuf.min.js.map +1 -1
- package/dist/minimal/protobuf.js +61 -18
- package/dist/minimal/protobuf.js.map +1 -1
- package/dist/minimal/protobuf.min.js +3 -3
- package/dist/minimal/protobuf.min.js.map +1 -1
- package/dist/protobuf.js +138 -60
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/ext/descriptor/index.d.ts +2 -1
- package/ext/descriptor.d.ts +11 -234
- package/ext/descriptor.generated.d.ts +409 -0
- package/ext/descriptor.js +96 -66
- package/ext/textformat.d.ts +2 -13
- package/ext/textformat.generated.d.ts +11 -0
- package/ext/textformat.js +28 -42
- package/index.d.ts +304 -275
- package/package.json +4 -7
- package/src/converter.js +3 -3
- package/src/decoder.js +6 -2
- package/src/enum.js +8 -3
- package/src/field.js +2 -0
- package/src/message.js +3 -6
- package/src/method.js +1 -1
- package/src/namespace.js +10 -2
- package/src/object.js +0 -1
- package/src/oneof.js +1 -0
- package/src/parse.js +19 -5
- package/src/root.js +4 -1
- package/src/service.js +6 -1
- package/src/type.js +12 -3
- package/src/typescript.js +19 -0
- package/src/util/minimal.js +8 -1
- package/src/util/utf8.js +39 -13
- package/src/util.js +2 -14
- package/src/writer.js +6 -1
- package/src/writer_buffer.js +6 -1
- package/tsconfig.json +2 -4
- package/src/typescript.jsdoc +0 -15
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// DO NOT EDIT! This is a generated file. Edit the
|
|
1
|
+
// DO NOT EDIT! This is a generated file. Edit the source file instead and regenerate.
|
|
2
2
|
|
|
3
3
|
export as namespace protobuf;
|
|
4
4
|
|
|
@@ -162,28 +162,28 @@ export class Enum extends ReflectionObject {
|
|
|
162
162
|
* @param [comments] The value comments for this enum
|
|
163
163
|
* @param [valuesOptions] The value options for this enum
|
|
164
164
|
*/
|
|
165
|
-
constructor(name: string, values?: { [k: string]: number }, options?: { [k: string]: any }, comment?: string, comments?: { [k: string]: string }, valuesOptions?: ({ [k: string]: { [k: string]: any } }|undefined));
|
|
165
|
+
constructor(name: string, values?: { [k: string]: number }, options?: { [k: string]: any }, comment?: string, comments?: { [k: string]: (string|null) }, valuesOptions?: ({ [k: string]: { [k: string]: any } }|undefined));
|
|
166
166
|
|
|
167
167
|
/** Enum values by id. */
|
|
168
|
-
|
|
168
|
+
valuesById: { [k: number]: string };
|
|
169
169
|
|
|
170
170
|
/** Enum values by name. */
|
|
171
|
-
|
|
171
|
+
values: { [k: string]: number };
|
|
172
172
|
|
|
173
173
|
/** Enum comment text. */
|
|
174
|
-
|
|
174
|
+
comment: (string|null);
|
|
175
175
|
|
|
176
176
|
/** Value comment texts, if any. */
|
|
177
|
-
|
|
177
|
+
comments: { [k: string]: (string|null) };
|
|
178
178
|
|
|
179
179
|
/** Values options, if any */
|
|
180
|
-
|
|
180
|
+
valuesOptions?: { [k: string]: { [k: string]: any } };
|
|
181
181
|
|
|
182
182
|
/** Resolved values features, if any */
|
|
183
|
-
|
|
183
|
+
_valuesFeatures?: { [k: string]: { [k: string]: any } };
|
|
184
184
|
|
|
185
185
|
/** Reserved ranges, if any. */
|
|
186
|
-
|
|
186
|
+
reserved: (number[]|string)[];
|
|
187
187
|
|
|
188
188
|
/**
|
|
189
189
|
* Constructs an enum from an enum descriptor.
|
|
@@ -192,14 +192,14 @@ export class Enum extends ReflectionObject {
|
|
|
192
192
|
* @returns Created enum
|
|
193
193
|
* @throws {TypeError} If arguments are invalid
|
|
194
194
|
*/
|
|
195
|
-
|
|
195
|
+
static fromJSON(name: string, json: IEnum): Enum;
|
|
196
196
|
|
|
197
197
|
/**
|
|
198
198
|
* Converts this enum to an enum descriptor.
|
|
199
199
|
* @param [toJSONOptions] JSON conversion options
|
|
200
200
|
* @returns Enum descriptor
|
|
201
201
|
*/
|
|
202
|
-
|
|
202
|
+
toJSON(toJSONOptions?: IToJSONOptions): IEnum;
|
|
203
203
|
|
|
204
204
|
/**
|
|
205
205
|
* Adds a value to this enum.
|
|
@@ -211,7 +211,7 @@ export class Enum extends ReflectionObject {
|
|
|
211
211
|
* @throws {TypeError} If arguments are invalid
|
|
212
212
|
* @throws {Error} If there is already a value with this name or id
|
|
213
213
|
*/
|
|
214
|
-
|
|
214
|
+
add(name: string, id: number, comment?: string, options?: ({ [k: string]: any }|undefined)): Enum;
|
|
215
215
|
|
|
216
216
|
/**
|
|
217
217
|
* Removes a value from this enum
|
|
@@ -220,31 +220,46 @@ export class Enum extends ReflectionObject {
|
|
|
220
220
|
* @throws {TypeError} If arguments are invalid
|
|
221
221
|
* @throws {Error} If `name` is not a name of this enum
|
|
222
222
|
*/
|
|
223
|
-
|
|
223
|
+
remove(name: string): Enum;
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
226
|
* Tests if the specified id is reserved.
|
|
227
227
|
* @param id Id to test
|
|
228
228
|
* @returns `true` if reserved, otherwise `false`
|
|
229
229
|
*/
|
|
230
|
-
|
|
230
|
+
isReservedId(id: number): boolean;
|
|
231
231
|
|
|
232
232
|
/**
|
|
233
233
|
* Tests if the specified name is reserved.
|
|
234
234
|
* @param name Name to test
|
|
235
235
|
* @returns `true` if reserved, otherwise `false`
|
|
236
236
|
*/
|
|
237
|
-
|
|
237
|
+
isReservedName(name: string): boolean;
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
/** Enum descriptor. */
|
|
241
241
|
export interface IEnum {
|
|
242
242
|
|
|
243
|
+
/** Edition */
|
|
244
|
+
edition?: string;
|
|
245
|
+
|
|
243
246
|
/** Enum values */
|
|
244
247
|
values: { [k: string]: number };
|
|
245
248
|
|
|
246
249
|
/** Enum options */
|
|
247
250
|
options?: { [k: string]: any };
|
|
251
|
+
|
|
252
|
+
/** Enum value options */
|
|
253
|
+
valuesOptions?: { [k: string]: { [k: string]: any } };
|
|
254
|
+
|
|
255
|
+
/** Reserved ranges */
|
|
256
|
+
reserved?: (number[]|string)[];
|
|
257
|
+
|
|
258
|
+
/** Enum comment */
|
|
259
|
+
comment?: (string|null);
|
|
260
|
+
|
|
261
|
+
/** Value comments */
|
|
262
|
+
comments?: { [k: string]: (string|null) };
|
|
248
263
|
}
|
|
249
264
|
|
|
250
265
|
/** Reflected message field. */
|
|
@@ -269,7 +284,7 @@ export class Field extends FieldBase {
|
|
|
269
284
|
* @returns Decorator function
|
|
270
285
|
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
271
286
|
*/
|
|
272
|
-
|
|
287
|
+
static d<T extends Message<T>>(fieldId: number, fieldType: (Constructor<T>|string), fieldRule?: ("optional"|"required"|"repeated")): FieldDecorator;
|
|
273
288
|
|
|
274
289
|
/**
|
|
275
290
|
* Constructs a field from a field descriptor.
|
|
@@ -278,25 +293,25 @@ export class Field extends FieldBase {
|
|
|
278
293
|
* @returns Created field
|
|
279
294
|
* @throws {TypeError} If arguments are invalid
|
|
280
295
|
*/
|
|
281
|
-
|
|
296
|
+
static fromJSON(name: string, json: IField): Field;
|
|
282
297
|
|
|
283
298
|
/** Determines whether this field is required. */
|
|
284
|
-
|
|
299
|
+
readonly required: boolean;
|
|
285
300
|
|
|
286
301
|
/** Determines whether this field is not required. */
|
|
287
|
-
|
|
302
|
+
readonly optional: boolean;
|
|
288
303
|
|
|
289
304
|
/**
|
|
290
305
|
* Determines whether this field uses tag-delimited encoding. In proto2 this
|
|
291
306
|
* corresponded to group syntax.
|
|
292
307
|
*/
|
|
293
|
-
|
|
308
|
+
readonly delimited: boolean;
|
|
294
309
|
|
|
295
310
|
/** Determines whether this field is packed. Only relevant when repeated. */
|
|
296
|
-
|
|
311
|
+
readonly packed: boolean;
|
|
297
312
|
|
|
298
313
|
/** Determines whether this field tracks presence. */
|
|
299
|
-
|
|
314
|
+
readonly hasPresence: boolean;
|
|
300
315
|
|
|
301
316
|
/**
|
|
302
317
|
* Field decorator (TypeScript).
|
|
@@ -307,7 +322,7 @@ export class Field extends FieldBase {
|
|
|
307
322
|
* @returns Decorator function
|
|
308
323
|
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
309
324
|
*/
|
|
310
|
-
|
|
325
|
+
static d<T extends number | number[] | Long | Long[] | string | string[] | boolean | boolean[] | Uint8Array | Uint8Array[] | Buffer | Buffer[]>(fieldId: number, fieldType: ("double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"string"|"bool"|"bytes"|object), fieldRule?: ("optional"|"required"|"repeated"), defaultValue?: T): FieldDecorator;
|
|
311
326
|
}
|
|
312
327
|
|
|
313
328
|
/** Base class of all reflected message fields. This is not an actual class but here for the sake of having consistent type definitions. */
|
|
@@ -326,63 +341,63 @@ export class FieldBase extends ReflectionObject {
|
|
|
326
341
|
constructor(name: string, id: number, type: string, rule?: (string|{ [k: string]: any }), extend?: (string|{ [k: string]: any }), options?: { [k: string]: any }, comment?: string);
|
|
327
342
|
|
|
328
343
|
/** Field type. */
|
|
329
|
-
|
|
344
|
+
type: string;
|
|
330
345
|
|
|
331
346
|
/** Unique field id. */
|
|
332
|
-
|
|
347
|
+
id: number;
|
|
333
348
|
|
|
334
349
|
/** Extended type if different from parent. */
|
|
335
|
-
|
|
350
|
+
extend?: string;
|
|
336
351
|
|
|
337
352
|
/** Whether this field is repeated. */
|
|
338
|
-
|
|
353
|
+
repeated: boolean;
|
|
339
354
|
|
|
340
355
|
/** Whether this field is a map or not. */
|
|
341
|
-
|
|
356
|
+
map: boolean;
|
|
342
357
|
|
|
343
358
|
/** Message this field belongs to. */
|
|
344
|
-
|
|
359
|
+
message: (Type|null);
|
|
345
360
|
|
|
346
361
|
/** OneOf this field belongs to, if any, */
|
|
347
|
-
|
|
362
|
+
partOf: (OneOf|null);
|
|
348
363
|
|
|
349
364
|
/** The field type's default value. */
|
|
350
|
-
|
|
365
|
+
typeDefault: any;
|
|
351
366
|
|
|
352
367
|
/** The field's default value on prototypes. */
|
|
353
|
-
|
|
368
|
+
defaultValue: any;
|
|
354
369
|
|
|
355
370
|
/** Whether this field's value should be treated as a long. */
|
|
356
|
-
|
|
371
|
+
long: boolean;
|
|
357
372
|
|
|
358
373
|
/** Whether this field's value is a buffer. */
|
|
359
|
-
|
|
374
|
+
bytes: boolean;
|
|
360
375
|
|
|
361
376
|
/** Resolved type if not a basic type. */
|
|
362
|
-
|
|
377
|
+
resolvedType: (Type|Enum|null);
|
|
363
378
|
|
|
364
379
|
/** Sister-field within the extended type if a declaring extension field. */
|
|
365
|
-
|
|
380
|
+
extensionField: (Field|null);
|
|
366
381
|
|
|
367
382
|
/** Sister-field within the declaring namespace if an extended field. */
|
|
368
|
-
|
|
383
|
+
declaringField: (Field|null);
|
|
369
384
|
|
|
370
385
|
/** Comment for this field. */
|
|
371
|
-
|
|
386
|
+
comment: (string|null);
|
|
372
387
|
|
|
373
388
|
/**
|
|
374
389
|
* Converts this field to a field descriptor.
|
|
375
390
|
* @param [toJSONOptions] JSON conversion options
|
|
376
391
|
* @returns Field descriptor
|
|
377
392
|
*/
|
|
378
|
-
|
|
393
|
+
toJSON(toJSONOptions?: IToJSONOptions): IField;
|
|
379
394
|
|
|
380
395
|
/**
|
|
381
396
|
* Resolves this field's type references.
|
|
382
397
|
* @returns `this`
|
|
383
398
|
* @throws {Error} If any reference cannot be resolved
|
|
384
399
|
*/
|
|
385
|
-
|
|
400
|
+
resolve(): Field;
|
|
386
401
|
|
|
387
402
|
/**
|
|
388
403
|
* Infers field features from legacy syntax that may have been specified differently.
|
|
@@ -390,12 +405,15 @@ export class FieldBase extends ReflectionObject {
|
|
|
390
405
|
* @param edition The edition this proto is on, or undefined if pre-editions
|
|
391
406
|
* @returns The feature values to override
|
|
392
407
|
*/
|
|
393
|
-
|
|
408
|
+
_inferLegacyProtoFeatures(edition: (string|undefined)): object;
|
|
394
409
|
}
|
|
395
410
|
|
|
396
411
|
/** Field descriptor. */
|
|
397
412
|
export interface IField {
|
|
398
413
|
|
|
414
|
+
/** Edition */
|
|
415
|
+
edition?: string;
|
|
416
|
+
|
|
399
417
|
/** Field rule */
|
|
400
418
|
rule?: string;
|
|
401
419
|
|
|
@@ -407,6 +425,9 @@ export interface IField {
|
|
|
407
425
|
|
|
408
426
|
/** Field options */
|
|
409
427
|
options?: { [k: string]: any };
|
|
428
|
+
|
|
429
|
+
/** Field comment */
|
|
430
|
+
comment?: (string|null);
|
|
410
431
|
}
|
|
411
432
|
|
|
412
433
|
/** Extension field descriptor. */
|
|
@@ -422,14 +443,14 @@ export interface IExtensionField extends IField {
|
|
|
422
443
|
* @param fieldName Field name
|
|
423
444
|
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
424
445
|
*/
|
|
425
|
-
type FieldDecorator = (prototype: object, fieldName: string) => void;
|
|
446
|
+
export type FieldDecorator = (prototype: object, fieldName: string) => void;
|
|
426
447
|
|
|
427
448
|
/**
|
|
428
449
|
* A node-style callback as used by {@link load} and {@link Root#load}.
|
|
429
450
|
* @param error Error, if any, otherwise `null`
|
|
430
451
|
* @param [root] Root, if there hasn't been an error
|
|
431
452
|
*/
|
|
432
|
-
type LoadCallback = (error: (Error|null), root?: Root) => void;
|
|
453
|
+
export type LoadCallback = (error: (Error|null), root?: Root) => void;
|
|
433
454
|
|
|
434
455
|
/**
|
|
435
456
|
* Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback.
|
|
@@ -488,10 +509,10 @@ export class MapField extends FieldBase {
|
|
|
488
509
|
constructor(name: string, id: number, keyType: string, type: string, options?: { [k: string]: any }, comment?: string);
|
|
489
510
|
|
|
490
511
|
/** Key type. */
|
|
491
|
-
|
|
512
|
+
keyType: string;
|
|
492
513
|
|
|
493
514
|
/** Resolved key type if not a basic type. */
|
|
494
|
-
|
|
515
|
+
resolvedKeyType: (ReflectionObject|null);
|
|
495
516
|
|
|
496
517
|
/**
|
|
497
518
|
* Constructs a map field from a map field descriptor.
|
|
@@ -500,14 +521,14 @@ export class MapField extends FieldBase {
|
|
|
500
521
|
* @returns Created map field
|
|
501
522
|
* @throws {TypeError} If arguments are invalid
|
|
502
523
|
*/
|
|
503
|
-
|
|
524
|
+
static fromJSON(name: string, json: IMapField): MapField;
|
|
504
525
|
|
|
505
526
|
/**
|
|
506
527
|
* Converts this map field to a map field descriptor.
|
|
507
528
|
* @param [toJSONOptions] JSON conversion options
|
|
508
529
|
* @returns Map field descriptor
|
|
509
530
|
*/
|
|
510
|
-
|
|
531
|
+
toJSON(toJSONOptions?: IToJSONOptions): IMapField;
|
|
511
532
|
|
|
512
533
|
/**
|
|
513
534
|
* Map field decorator (TypeScript).
|
|
@@ -517,7 +538,7 @@ export class MapField extends FieldBase {
|
|
|
517
538
|
* @returns Decorator function
|
|
518
539
|
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
519
540
|
*/
|
|
520
|
-
|
|
541
|
+
static d<T extends { [key: string]: number | Long | string | boolean | Uint8Array | Buffer | number[] | Message<{}> }>(fieldId: number, fieldKeyType: ("int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"bool"|"string"), fieldValueType: ("double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"bool"|"string"|"bytes"|object|Constructor<{}>)): FieldDecorator;
|
|
521
542
|
}
|
|
522
543
|
|
|
523
544
|
/** Map field descriptor. */
|
|
@@ -544,20 +565,20 @@ export class Message<T extends object = object> {
|
|
|
544
565
|
constructor(properties?: Properties<T>);
|
|
545
566
|
|
|
546
567
|
/** Unknown fields preserved while decoding */
|
|
547
|
-
|
|
568
|
+
$unknowns?: Uint8Array[];
|
|
548
569
|
|
|
549
570
|
/** Reference to the reflected type. */
|
|
550
|
-
|
|
571
|
+
static readonly $type: Type;
|
|
551
572
|
|
|
552
573
|
/** Reference to the reflected type. */
|
|
553
|
-
|
|
574
|
+
readonly $type: Type;
|
|
554
575
|
|
|
555
576
|
/**
|
|
556
577
|
* Creates a new message of this type using the specified properties.
|
|
557
578
|
* @param [properties] Properties to set
|
|
558
579
|
* @returns Message instance
|
|
559
580
|
*/
|
|
560
|
-
|
|
581
|
+
static create<T extends Message<T>>(this: Constructor<T>, properties?: { [k: string]: any }): Message<T>;
|
|
561
582
|
|
|
562
583
|
/**
|
|
563
584
|
* Encodes a message of this type.
|
|
@@ -565,7 +586,7 @@ export class Message<T extends object = object> {
|
|
|
565
586
|
* @param [writer] Writer to use
|
|
566
587
|
* @returns Writer
|
|
567
588
|
*/
|
|
568
|
-
|
|
589
|
+
static encode<T extends Message<T>>(this: Constructor<T>, message: (T|{ [k: string]: any }), writer?: Writer): Writer;
|
|
569
590
|
|
|
570
591
|
/**
|
|
571
592
|
* Encodes a message of this type preceeded by its length as a varint.
|
|
@@ -573,35 +594,35 @@ export class Message<T extends object = object> {
|
|
|
573
594
|
* @param [writer] Writer to use
|
|
574
595
|
* @returns Writer
|
|
575
596
|
*/
|
|
576
|
-
|
|
597
|
+
static encodeDelimited<T extends Message<T>>(this: Constructor<T>, message: (T|{ [k: string]: any }), writer?: Writer): Writer;
|
|
577
598
|
|
|
578
599
|
/**
|
|
579
600
|
* Decodes a message of this type.
|
|
580
601
|
* @param reader Reader or buffer to decode
|
|
581
602
|
* @returns Decoded message
|
|
582
603
|
*/
|
|
583
|
-
|
|
604
|
+
static decode<T extends Message<T>>(this: Constructor<T>, reader: (Reader|Uint8Array)): T;
|
|
584
605
|
|
|
585
606
|
/**
|
|
586
607
|
* Decodes a message of this type preceeded by its length as a varint.
|
|
587
608
|
* @param reader Reader or buffer to decode
|
|
588
609
|
* @returns Decoded message
|
|
589
610
|
*/
|
|
590
|
-
|
|
611
|
+
static decodeDelimited<T extends Message<T>>(this: Constructor<T>, reader: (Reader|Uint8Array)): T;
|
|
591
612
|
|
|
592
613
|
/**
|
|
593
614
|
* Verifies a message of this type.
|
|
594
615
|
* @param message Plain object to verify
|
|
595
616
|
* @returns `null` if valid, otherwise the reason why it is not
|
|
596
617
|
*/
|
|
597
|
-
|
|
618
|
+
static verify(message: { [k: string]: any }): (string|null);
|
|
598
619
|
|
|
599
620
|
/**
|
|
600
621
|
* Creates a new message of this type from a plain object. Also converts values to their respective internal types.
|
|
601
622
|
* @param object Plain object
|
|
602
623
|
* @returns Message instance
|
|
603
624
|
*/
|
|
604
|
-
|
|
625
|
+
static fromObject<T extends Message<T>>(this: Constructor<T>, object: { [k: string]: any }): T;
|
|
605
626
|
|
|
606
627
|
/**
|
|
607
628
|
* Creates a plain object from a message of this type. Also converts values to other types if specified.
|
|
@@ -609,13 +630,13 @@ export class Message<T extends object = object> {
|
|
|
609
630
|
* @param [options] Conversion options
|
|
610
631
|
* @returns Plain object
|
|
611
632
|
*/
|
|
612
|
-
|
|
633
|
+
static toObject<T extends Message<T>>(this: Constructor<T>, message: T, options?: IConversionOptions): { [k: string]: any };
|
|
613
634
|
|
|
614
635
|
/**
|
|
615
636
|
* Converts this message to JSON.
|
|
616
637
|
* @returns JSON object
|
|
617
638
|
*/
|
|
618
|
-
|
|
639
|
+
toJSON(): { [k: string]: any };
|
|
619
640
|
}
|
|
620
641
|
|
|
621
642
|
/** Reflected service method. */
|
|
@@ -636,31 +657,31 @@ export class Method extends ReflectionObject {
|
|
|
636
657
|
constructor(name: string, type: (string|undefined), requestType: string, responseType: string, requestStream?: (boolean|{ [k: string]: any }), responseStream?: (boolean|{ [k: string]: any }), options?: { [k: string]: any }, comment?: string, parsedOptions?: { [k: string]: any }[]);
|
|
637
658
|
|
|
638
659
|
/** Method type. */
|
|
639
|
-
|
|
660
|
+
type: string;
|
|
640
661
|
|
|
641
662
|
/** Request type. */
|
|
642
|
-
|
|
663
|
+
requestType: string;
|
|
643
664
|
|
|
644
665
|
/** Whether requests are streamed or not. */
|
|
645
|
-
|
|
666
|
+
requestStream?: boolean;
|
|
646
667
|
|
|
647
668
|
/** Response type. */
|
|
648
|
-
|
|
669
|
+
responseType: string;
|
|
649
670
|
|
|
650
671
|
/** Whether responses are streamed or not. */
|
|
651
|
-
|
|
672
|
+
responseStream?: boolean;
|
|
652
673
|
|
|
653
674
|
/** Resolved request type. */
|
|
654
|
-
|
|
675
|
+
resolvedRequestType: (Type|null);
|
|
655
676
|
|
|
656
677
|
/** Resolved response type. */
|
|
657
|
-
|
|
678
|
+
resolvedResponseType: (Type|null);
|
|
658
679
|
|
|
659
680
|
/** Comment for this method */
|
|
660
|
-
|
|
681
|
+
comment: (string|null);
|
|
661
682
|
|
|
662
683
|
/** Options properly parsed into objects */
|
|
663
|
-
|
|
684
|
+
parsedOptions?: { [k: string]: any }[];
|
|
664
685
|
|
|
665
686
|
/**
|
|
666
687
|
* Constructs a method from a method descriptor.
|
|
@@ -669,14 +690,14 @@ export class Method extends ReflectionObject {
|
|
|
669
690
|
* @returns Created method
|
|
670
691
|
* @throws {TypeError} If arguments are invalid
|
|
671
692
|
*/
|
|
672
|
-
|
|
693
|
+
static fromJSON(name: string, json: IMethod): Method;
|
|
673
694
|
|
|
674
695
|
/**
|
|
675
696
|
* Converts this method to a method descriptor.
|
|
676
697
|
* @param [toJSONOptions] JSON conversion options
|
|
677
698
|
* @returns Method descriptor
|
|
678
699
|
*/
|
|
679
|
-
|
|
700
|
+
toJSON(toJSONOptions?: IToJSONOptions): IMethod;
|
|
680
701
|
}
|
|
681
702
|
|
|
682
703
|
/** Method descriptor. */
|
|
@@ -700,8 +721,8 @@ export interface IMethod {
|
|
|
700
721
|
/** Method options */
|
|
701
722
|
options?: { [k: string]: any };
|
|
702
723
|
|
|
703
|
-
/** Method
|
|
704
|
-
comment
|
|
724
|
+
/** Method comment */
|
|
725
|
+
comment?: (string|null);
|
|
705
726
|
|
|
706
727
|
/** Method options properly parsed into objects */
|
|
707
728
|
parsedOptions?: { [k: string]: any }[];
|
|
@@ -725,7 +746,7 @@ export class Namespace extends NamespaceBase {
|
|
|
725
746
|
* @returns Created namespace
|
|
726
747
|
* @throws {TypeError} If arguments are invalid
|
|
727
748
|
*/
|
|
728
|
-
|
|
749
|
+
static fromJSON(name: string, json: { [k: string]: any }, depth?: number): Namespace;
|
|
729
750
|
|
|
730
751
|
/**
|
|
731
752
|
* Converts an array of reflection objects to JSON.
|
|
@@ -733,7 +754,7 @@ export class Namespace extends NamespaceBase {
|
|
|
733
754
|
* @param [toJSONOptions] JSON conversion options
|
|
734
755
|
* @returns JSON object or `undefined` when array is empty
|
|
735
756
|
*/
|
|
736
|
-
|
|
757
|
+
static arrayToJSON(array: ReflectionObject[], toJSONOptions?: IToJSONOptions): ({ [k: string]: any }|undefined);
|
|
737
758
|
|
|
738
759
|
/**
|
|
739
760
|
* Tests if the specified id is reserved.
|
|
@@ -741,7 +762,7 @@ export class Namespace extends NamespaceBase {
|
|
|
741
762
|
* @param id Id to test
|
|
742
763
|
* @returns `true` if reserved, otherwise `false`
|
|
743
764
|
*/
|
|
744
|
-
|
|
765
|
+
static isReservedId(reserved: ((number[]|string)[]|undefined), id: number): boolean;
|
|
745
766
|
|
|
746
767
|
/**
|
|
747
768
|
* Tests if the specified name is reserved.
|
|
@@ -749,14 +770,14 @@ export class Namespace extends NamespaceBase {
|
|
|
749
770
|
* @param name Name to test
|
|
750
771
|
* @returns `true` if reserved, otherwise `false`
|
|
751
772
|
*/
|
|
752
|
-
|
|
773
|
+
static isReservedName(reserved: ((number[]|string)[]|undefined), name: string): boolean;
|
|
753
774
|
}
|
|
754
775
|
|
|
755
776
|
/** Base class of all reflection objects containing nested objects. This is not an actual class but here for the sake of having consistent type definitions. */
|
|
756
777
|
export abstract class NamespaceBase extends ReflectionObject {
|
|
757
778
|
|
|
758
779
|
/** Nested objects by name. */
|
|
759
|
-
|
|
780
|
+
nested?: { [k: string]: ReflectionObject };
|
|
760
781
|
|
|
761
782
|
/** Whether or not objects contained in this namespace need feature resolution. */
|
|
762
783
|
protected _needsRecursiveFeatureResolution: boolean;
|
|
@@ -765,14 +786,14 @@ export abstract class NamespaceBase extends ReflectionObject {
|
|
|
765
786
|
protected _needsRecursiveResolve: boolean;
|
|
766
787
|
|
|
767
788
|
/** Nested objects of this namespace as an array for iteration. */
|
|
768
|
-
|
|
789
|
+
readonly nestedArray: ReflectionObject[];
|
|
769
790
|
|
|
770
791
|
/**
|
|
771
792
|
* Converts this namespace to a namespace descriptor.
|
|
772
793
|
* @param [toJSONOptions] JSON conversion options
|
|
773
794
|
* @returns Namespace descriptor
|
|
774
795
|
*/
|
|
775
|
-
|
|
796
|
+
toJSON(toJSONOptions?: IToJSONOptions): INamespace;
|
|
776
797
|
|
|
777
798
|
/**
|
|
778
799
|
* Adds nested objects to this namespace from nested object descriptors.
|
|
@@ -780,14 +801,14 @@ export abstract class NamespaceBase extends ReflectionObject {
|
|
|
780
801
|
* @param [depth] Current nesting depth, defaults to `0`
|
|
781
802
|
* @returns `this`
|
|
782
803
|
*/
|
|
783
|
-
|
|
804
|
+
addJSON(nestedJson: { [k: string]: AnyNestedObject }, depth?: number): Namespace;
|
|
784
805
|
|
|
785
806
|
/**
|
|
786
807
|
* Gets the nested object of the specified name.
|
|
787
808
|
* @param name Nested object name
|
|
788
809
|
* @returns The reflection object or `null` if it doesn't exist
|
|
789
810
|
*/
|
|
790
|
-
|
|
811
|
+
get(name: string): (ReflectionObject|null);
|
|
791
812
|
|
|
792
813
|
/**
|
|
793
814
|
* Gets the values of the nested {@link Enum|enum} of the specified name.
|
|
@@ -796,7 +817,7 @@ export abstract class NamespaceBase extends ReflectionObject {
|
|
|
796
817
|
* @returns Enum values
|
|
797
818
|
* @throws {Error} If there is no such enum
|
|
798
819
|
*/
|
|
799
|
-
|
|
820
|
+
getEnum(name: string): { [k: string]: number };
|
|
800
821
|
|
|
801
822
|
/**
|
|
802
823
|
* Adds a nested object to this namespace.
|
|
@@ -805,7 +826,7 @@ export abstract class NamespaceBase extends ReflectionObject {
|
|
|
805
826
|
* @throws {TypeError} If arguments are invalid
|
|
806
827
|
* @throws {Error} If there is already a nested object with this name
|
|
807
828
|
*/
|
|
808
|
-
|
|
829
|
+
add(object: ReflectionObject): Namespace;
|
|
809
830
|
|
|
810
831
|
/**
|
|
811
832
|
* Removes a nested object from this namespace.
|
|
@@ -814,7 +835,7 @@ export abstract class NamespaceBase extends ReflectionObject {
|
|
|
814
835
|
* @throws {TypeError} If arguments are invalid
|
|
815
836
|
* @throws {Error} If `object` is not a member of this namespace
|
|
816
837
|
*/
|
|
817
|
-
|
|
838
|
+
remove(object: ReflectionObject): Namespace;
|
|
818
839
|
|
|
819
840
|
/**
|
|
820
841
|
* Defines additial namespaces within this one if not yet existing.
|
|
@@ -822,13 +843,13 @@ export abstract class NamespaceBase extends ReflectionObject {
|
|
|
822
843
|
* @param [json] Nested types to create from JSON
|
|
823
844
|
* @returns Pointer to the last namespace created or `this` if path is empty
|
|
824
845
|
*/
|
|
825
|
-
|
|
846
|
+
define(path: (string|string[]), json?: any): Namespace;
|
|
826
847
|
|
|
827
848
|
/**
|
|
828
849
|
* Resolves this namespace's and all its nested objects' type references. Useful to validate a reflection tree, but comes at a cost.
|
|
829
850
|
* @returns `this`
|
|
830
851
|
*/
|
|
831
|
-
|
|
852
|
+
resolveAll(): Namespace;
|
|
832
853
|
|
|
833
854
|
/**
|
|
834
855
|
* Recursively looks up the reflection object matching the specified path in the scope of this namespace.
|
|
@@ -837,7 +858,7 @@ export abstract class NamespaceBase extends ReflectionObject {
|
|
|
837
858
|
* @param [parentAlreadyChecked=false] If known, whether the parent has already been checked
|
|
838
859
|
* @returns Looked up object or `null` if none could be found
|
|
839
860
|
*/
|
|
840
|
-
|
|
861
|
+
lookup(path: (string|string[]), filterTypes: (any|any[]), parentAlreadyChecked?: boolean): (ReflectionObject|null);
|
|
841
862
|
|
|
842
863
|
/**
|
|
843
864
|
* Looks up the reflection object at the specified path, relative to this namespace.
|
|
@@ -845,7 +866,7 @@ export abstract class NamespaceBase extends ReflectionObject {
|
|
|
845
866
|
* @param [parentAlreadyChecked=false] Whether the parent has already been checked
|
|
846
867
|
* @returns Looked up object or `null` if none could be found
|
|
847
868
|
*/
|
|
848
|
-
|
|
869
|
+
lookup(path: (string|string[]), parentAlreadyChecked?: boolean): (ReflectionObject|null);
|
|
849
870
|
|
|
850
871
|
/**
|
|
851
872
|
* Looks up the {@link Type|type} at the specified path, relative to this namespace.
|
|
@@ -854,7 +875,7 @@ export abstract class NamespaceBase extends ReflectionObject {
|
|
|
854
875
|
* @returns Looked up type
|
|
855
876
|
* @throws {Error} If `path` does not point to a type
|
|
856
877
|
*/
|
|
857
|
-
|
|
878
|
+
lookupType(path: (string|string[])): Type;
|
|
858
879
|
|
|
859
880
|
/**
|
|
860
881
|
* Looks up the values of the {@link Enum|enum} at the specified path, relative to this namespace.
|
|
@@ -863,7 +884,7 @@ export abstract class NamespaceBase extends ReflectionObject {
|
|
|
863
884
|
* @returns Looked up enum
|
|
864
885
|
* @throws {Error} If `path` does not point to an enum
|
|
865
886
|
*/
|
|
866
|
-
|
|
887
|
+
lookupEnum(path: (string|string[])): Enum;
|
|
867
888
|
|
|
868
889
|
/**
|
|
869
890
|
* Looks up the {@link Type|type} or {@link Enum|enum} at the specified path, relative to this namespace.
|
|
@@ -872,7 +893,7 @@ export abstract class NamespaceBase extends ReflectionObject {
|
|
|
872
893
|
* @returns Looked up type or enum
|
|
873
894
|
* @throws {Error} If `path` does not point to a type or enum
|
|
874
895
|
*/
|
|
875
|
-
|
|
896
|
+
lookupTypeOrEnum(path: (string|string[])): Type;
|
|
876
897
|
|
|
877
898
|
/**
|
|
878
899
|
* Looks up the {@link Service|service} at the specified path, relative to this namespace.
|
|
@@ -881,7 +902,7 @@ export abstract class NamespaceBase extends ReflectionObject {
|
|
|
881
902
|
* @returns Looked up service
|
|
882
903
|
* @throws {Error} If `path` does not point to a service
|
|
883
904
|
*/
|
|
884
|
-
|
|
905
|
+
lookupService(path: (string|string[])): Service;
|
|
885
906
|
}
|
|
886
907
|
|
|
887
908
|
/** Namespace descriptor. */
|
|
@@ -895,77 +916,77 @@ export interface INamespace {
|
|
|
895
916
|
}
|
|
896
917
|
|
|
897
918
|
/** Any extension field descriptor. */
|
|
898
|
-
type AnyExtensionField = (IExtensionField|IExtensionMapField);
|
|
919
|
+
export type AnyExtensionField = (IExtensionField|IExtensionMapField);
|
|
899
920
|
|
|
900
921
|
/** Any nested object descriptor. */
|
|
901
|
-
type AnyNestedObject = (IEnum|IType|IService|AnyExtensionField|INamespace|IOneOf);
|
|
922
|
+
export type AnyNestedObject = (IEnum|IType|IService|AnyExtensionField|INamespace|IOneOf);
|
|
902
923
|
|
|
903
924
|
/** Base class of all reflection objects. */
|
|
904
925
|
export abstract class ReflectionObject {
|
|
905
926
|
|
|
906
927
|
/** Options. */
|
|
907
|
-
|
|
928
|
+
options?: { [k: string]: any };
|
|
908
929
|
|
|
909
930
|
/** Parsed Options. */
|
|
910
|
-
|
|
931
|
+
parsedOptions?: { [k: string]: any }[];
|
|
911
932
|
|
|
912
933
|
/** Unique name within its namespace. */
|
|
913
|
-
|
|
934
|
+
name: string;
|
|
914
935
|
|
|
915
936
|
/** Parent namespace. */
|
|
916
|
-
|
|
937
|
+
parent: (Namespace|null);
|
|
917
938
|
|
|
918
939
|
/** Whether already resolved or not. */
|
|
919
|
-
|
|
940
|
+
resolved: boolean;
|
|
920
941
|
|
|
921
942
|
/** Comment text, if any. */
|
|
922
|
-
|
|
943
|
+
comment: (string|null);
|
|
923
944
|
|
|
924
945
|
/** Defining file name. */
|
|
925
|
-
|
|
946
|
+
filename: (string|null);
|
|
926
947
|
|
|
927
948
|
/** Reference to the root namespace. */
|
|
928
|
-
|
|
949
|
+
readonly root: Root;
|
|
929
950
|
|
|
930
951
|
/** Full name including leading dot. */
|
|
931
|
-
|
|
952
|
+
readonly fullName: string;
|
|
932
953
|
|
|
933
954
|
/**
|
|
934
955
|
* Converts this reflection object to its descriptor representation.
|
|
935
956
|
* @returns Descriptor
|
|
936
957
|
*/
|
|
937
|
-
|
|
958
|
+
toJSON(): { [k: string]: any };
|
|
938
959
|
|
|
939
960
|
/**
|
|
940
961
|
* Called when this object is added to a parent.
|
|
941
962
|
* @param parent Parent added to
|
|
942
963
|
*/
|
|
943
|
-
|
|
964
|
+
onAdd(parent: ReflectionObject): void;
|
|
944
965
|
|
|
945
966
|
/**
|
|
946
967
|
* Called when this object is removed from a parent.
|
|
947
968
|
* @param parent Parent removed from
|
|
948
969
|
*/
|
|
949
|
-
|
|
970
|
+
onRemove(parent: ReflectionObject): void;
|
|
950
971
|
|
|
951
972
|
/**
|
|
952
973
|
* Resolves this objects type references.
|
|
953
974
|
* @returns `this`
|
|
954
975
|
*/
|
|
955
|
-
|
|
976
|
+
resolve(): ReflectionObject;
|
|
956
977
|
|
|
957
978
|
/**
|
|
958
979
|
* Resolves this objects editions features.
|
|
959
980
|
* @param edition The edition we're currently resolving for.
|
|
960
981
|
* @returns `this`
|
|
961
982
|
*/
|
|
962
|
-
|
|
983
|
+
_resolveFeaturesRecursive(edition: string): ReflectionObject;
|
|
963
984
|
|
|
964
985
|
/**
|
|
965
986
|
* Resolves child features from parent features
|
|
966
987
|
* @param edition The edition we're currently resolving for.
|
|
967
988
|
*/
|
|
968
|
-
|
|
989
|
+
_resolveFeatures(edition: string): void;
|
|
969
990
|
|
|
970
991
|
/**
|
|
971
992
|
* Infers features from legacy syntax that may have been specified differently.
|
|
@@ -973,14 +994,14 @@ export abstract class ReflectionObject {
|
|
|
973
994
|
* @param edition The edition this proto is on, or undefined if pre-editions
|
|
974
995
|
* @returns The feature values to override
|
|
975
996
|
*/
|
|
976
|
-
|
|
997
|
+
_inferLegacyProtoFeatures(edition: (string|undefined)): object;
|
|
977
998
|
|
|
978
999
|
/**
|
|
979
1000
|
* Gets an option value.
|
|
980
1001
|
* @param name Option name
|
|
981
1002
|
* @returns Option value or `undefined` if not set
|
|
982
1003
|
*/
|
|
983
|
-
|
|
1004
|
+
getOption(name: string): any;
|
|
984
1005
|
|
|
985
1006
|
/**
|
|
986
1007
|
* Sets an option.
|
|
@@ -989,7 +1010,7 @@ export abstract class ReflectionObject {
|
|
|
989
1010
|
* @param [ifNotSet] Sets the option only if it isn't currently set
|
|
990
1011
|
* @returns `this`
|
|
991
1012
|
*/
|
|
992
|
-
|
|
1013
|
+
setOption(name: string, value: any, ifNotSet?: (boolean|undefined)): ReflectionObject;
|
|
993
1014
|
|
|
994
1015
|
/**
|
|
995
1016
|
* Sets a parsed option.
|
|
@@ -998,7 +1019,7 @@ export abstract class ReflectionObject {
|
|
|
998
1019
|
* @param propName dot '.' delimited full path of property within the option to set. if undefined\empty, will add a new option with that value
|
|
999
1020
|
* @returns `this`
|
|
1000
1021
|
*/
|
|
1001
|
-
|
|
1022
|
+
setParsedOption(name: string, value: any, propName: string): ReflectionObject;
|
|
1002
1023
|
|
|
1003
1024
|
/**
|
|
1004
1025
|
* Sets multiple options.
|
|
@@ -1006,19 +1027,19 @@ export abstract class ReflectionObject {
|
|
|
1006
1027
|
* @param [ifNotSet] Sets an option only if it isn't currently set
|
|
1007
1028
|
* @returns `this`
|
|
1008
1029
|
*/
|
|
1009
|
-
|
|
1030
|
+
setOptions(options: { [k: string]: any }, ifNotSet?: boolean): ReflectionObject;
|
|
1010
1031
|
|
|
1011
1032
|
/**
|
|
1012
1033
|
* Converts this instance to its string representation.
|
|
1013
1034
|
* @returns Class name[, space, full name]
|
|
1014
1035
|
*/
|
|
1015
|
-
|
|
1036
|
+
toString(): string;
|
|
1016
1037
|
|
|
1017
1038
|
/**
|
|
1018
1039
|
* Converts the edition this object is pinned to for JSON format.
|
|
1019
1040
|
* @returns The edition string for JSON representation
|
|
1020
1041
|
*/
|
|
1021
|
-
|
|
1042
|
+
_editionToJSON(): (string|undefined);
|
|
1022
1043
|
}
|
|
1023
1044
|
|
|
1024
1045
|
/** Reflected oneof. */
|
|
@@ -1034,13 +1055,13 @@ export class OneOf extends ReflectionObject {
|
|
|
1034
1055
|
constructor(name: string, fieldNames?: (string[]|{ [k: string]: any }), options?: { [k: string]: any }, comment?: string);
|
|
1035
1056
|
|
|
1036
1057
|
/** Field names that belong to this oneof. */
|
|
1037
|
-
|
|
1058
|
+
oneof: string[];
|
|
1038
1059
|
|
|
1039
1060
|
/** Fields that belong to this oneof as an array for iteration. */
|
|
1040
|
-
|
|
1061
|
+
readonly fieldsArray: Field[];
|
|
1041
1062
|
|
|
1042
1063
|
/** Comment for this field. */
|
|
1043
|
-
|
|
1064
|
+
comment: (string|null);
|
|
1044
1065
|
|
|
1045
1066
|
/**
|
|
1046
1067
|
* Constructs a oneof from a oneof descriptor.
|
|
@@ -1049,35 +1070,35 @@ export class OneOf extends ReflectionObject {
|
|
|
1049
1070
|
* @returns Created oneof
|
|
1050
1071
|
* @throws {TypeError} If arguments are invalid
|
|
1051
1072
|
*/
|
|
1052
|
-
|
|
1073
|
+
static fromJSON(name: string, json: IOneOf): OneOf;
|
|
1053
1074
|
|
|
1054
1075
|
/**
|
|
1055
1076
|
* Converts this oneof to a oneof descriptor.
|
|
1056
1077
|
* @param [toJSONOptions] JSON conversion options
|
|
1057
1078
|
* @returns Oneof descriptor
|
|
1058
1079
|
*/
|
|
1059
|
-
|
|
1080
|
+
toJSON(toJSONOptions?: IToJSONOptions): IOneOf;
|
|
1060
1081
|
|
|
1061
1082
|
/**
|
|
1062
1083
|
* Adds a field to this oneof and removes it from its current parent, if any.
|
|
1063
1084
|
* @param field Field to add
|
|
1064
1085
|
* @returns `this`
|
|
1065
1086
|
*/
|
|
1066
|
-
|
|
1087
|
+
add(field: Field): OneOf;
|
|
1067
1088
|
|
|
1068
1089
|
/**
|
|
1069
1090
|
* Removes a field from this oneof and puts it back to the oneof's parent.
|
|
1070
1091
|
* @param field Field to remove
|
|
1071
1092
|
* @returns `this`
|
|
1072
1093
|
*/
|
|
1073
|
-
|
|
1094
|
+
remove(field: Field): OneOf;
|
|
1074
1095
|
|
|
1075
1096
|
/**
|
|
1076
1097
|
* Determines whether this field corresponds to a synthetic oneof created for
|
|
1077
1098
|
* a proto3 optional field. No behavioral logic should depend on this, but it
|
|
1078
1099
|
* can be relevant for reflection.
|
|
1079
1100
|
*/
|
|
1080
|
-
|
|
1101
|
+
readonly isProto3Optional: boolean;
|
|
1081
1102
|
|
|
1082
1103
|
/**
|
|
1083
1104
|
* OneOf decorator (TypeScript).
|
|
@@ -1085,7 +1106,7 @@ export class OneOf extends ReflectionObject {
|
|
|
1085
1106
|
* @returns Decorator function
|
|
1086
1107
|
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
1087
1108
|
*/
|
|
1088
|
-
|
|
1109
|
+
static d<T extends string>(...fieldNames: string[]): OneOfDecorator;
|
|
1089
1110
|
}
|
|
1090
1111
|
|
|
1091
1112
|
/** Oneof descriptor. */
|
|
@@ -1096,6 +1117,9 @@ export interface IOneOf {
|
|
|
1096
1117
|
|
|
1097
1118
|
/** Oneof options */
|
|
1098
1119
|
options?: { [k: string]: any };
|
|
1120
|
+
|
|
1121
|
+
/** Oneof comment */
|
|
1122
|
+
comment?: (string|null);
|
|
1099
1123
|
}
|
|
1100
1124
|
|
|
1101
1125
|
/**
|
|
@@ -1104,7 +1128,7 @@ export interface IOneOf {
|
|
|
1104
1128
|
* @param oneofName OneOf name
|
|
1105
1129
|
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
1106
1130
|
*/
|
|
1107
|
-
type OneOfDecorator = (prototype: object, oneofName: string) => void;
|
|
1131
|
+
export type OneOfDecorator = (prototype: object, oneofName: string) => void;
|
|
1108
1132
|
|
|
1109
1133
|
/**
|
|
1110
1134
|
* Parses the given .proto source and returns an object with the parsed contents.
|
|
@@ -1169,13 +1193,13 @@ export class Reader {
|
|
|
1169
1193
|
constructor(buffer: Uint8Array);
|
|
1170
1194
|
|
|
1171
1195
|
/** Read buffer. */
|
|
1172
|
-
|
|
1196
|
+
buf: Uint8Array;
|
|
1173
1197
|
|
|
1174
1198
|
/** Read buffer position. */
|
|
1175
|
-
|
|
1199
|
+
pos: number;
|
|
1176
1200
|
|
|
1177
1201
|
/** Read buffer length. */
|
|
1178
|
-
|
|
1202
|
+
len: number;
|
|
1179
1203
|
|
|
1180
1204
|
/**
|
|
1181
1205
|
* Creates a new reader using the specified buffer.
|
|
@@ -1183,7 +1207,7 @@ export class Reader {
|
|
|
1183
1207
|
* @returns A {@link BufferReader} if `buffer` is a Buffer, otherwise a {@link Reader}
|
|
1184
1208
|
* @throws {Error} If `buffer` is not a valid buffer
|
|
1185
1209
|
*/
|
|
1186
|
-
|
|
1210
|
+
static create(buffer: (Uint8Array|Buffer)): (Reader|BufferReader);
|
|
1187
1211
|
|
|
1188
1212
|
/**
|
|
1189
1213
|
* Returns raw bytes from the backing buffer without advancing the reader.
|
|
@@ -1191,113 +1215,113 @@ export class Reader {
|
|
|
1191
1215
|
* @param end End offset
|
|
1192
1216
|
* @returns Raw bytes
|
|
1193
1217
|
*/
|
|
1194
|
-
|
|
1218
|
+
raw(start: number, end: number): Uint8Array;
|
|
1195
1219
|
|
|
1196
1220
|
/**
|
|
1197
1221
|
* Reads a varint as an unsigned 32 bit value.
|
|
1198
1222
|
* @returns Value read
|
|
1199
1223
|
*/
|
|
1200
|
-
|
|
1224
|
+
uint32(): number;
|
|
1201
1225
|
|
|
1202
1226
|
/**
|
|
1203
1227
|
* Reads a field tag.
|
|
1204
1228
|
* @returns Tag read
|
|
1205
1229
|
*/
|
|
1206
|
-
|
|
1230
|
+
tag(): number;
|
|
1207
1231
|
|
|
1208
1232
|
/**
|
|
1209
1233
|
* Reads a varint as a signed 32 bit value.
|
|
1210
1234
|
* @returns Value read
|
|
1211
1235
|
*/
|
|
1212
|
-
|
|
1236
|
+
int32(): number;
|
|
1213
1237
|
|
|
1214
1238
|
/**
|
|
1215
1239
|
* Reads a zig-zag encoded varint as a signed 32 bit value.
|
|
1216
1240
|
* @returns Value read
|
|
1217
1241
|
*/
|
|
1218
|
-
|
|
1242
|
+
sint32(): number;
|
|
1219
1243
|
|
|
1220
1244
|
/**
|
|
1221
1245
|
* Reads a varint as a signed 64 bit value.
|
|
1222
1246
|
* @returns Value read
|
|
1223
1247
|
*/
|
|
1224
|
-
|
|
1248
|
+
int64(): Long;
|
|
1225
1249
|
|
|
1226
1250
|
/**
|
|
1227
1251
|
* Reads a varint as an unsigned 64 bit value.
|
|
1228
1252
|
* @returns Value read
|
|
1229
1253
|
*/
|
|
1230
|
-
|
|
1254
|
+
uint64(): Long;
|
|
1231
1255
|
|
|
1232
1256
|
/**
|
|
1233
1257
|
* Reads a zig-zag encoded varint as a signed 64 bit value.
|
|
1234
1258
|
* @returns Value read
|
|
1235
1259
|
*/
|
|
1236
|
-
|
|
1260
|
+
sint64(): Long;
|
|
1237
1261
|
|
|
1238
1262
|
/**
|
|
1239
1263
|
* Reads a varint as a boolean.
|
|
1240
1264
|
* @returns Value read
|
|
1241
1265
|
*/
|
|
1242
|
-
|
|
1266
|
+
bool(): boolean;
|
|
1243
1267
|
|
|
1244
1268
|
/**
|
|
1245
1269
|
* Reads fixed 32 bits as an unsigned 32 bit integer.
|
|
1246
1270
|
* @returns Value read
|
|
1247
1271
|
*/
|
|
1248
|
-
|
|
1272
|
+
fixed32(): number;
|
|
1249
1273
|
|
|
1250
1274
|
/**
|
|
1251
1275
|
* Reads fixed 32 bits as a signed 32 bit integer.
|
|
1252
1276
|
* @returns Value read
|
|
1253
1277
|
*/
|
|
1254
|
-
|
|
1278
|
+
sfixed32(): number;
|
|
1255
1279
|
|
|
1256
1280
|
/**
|
|
1257
1281
|
* Reads fixed 64 bits.
|
|
1258
1282
|
* @returns Value read
|
|
1259
1283
|
*/
|
|
1260
|
-
|
|
1284
|
+
fixed64(): Long;
|
|
1261
1285
|
|
|
1262
1286
|
/**
|
|
1263
1287
|
* Reads zig-zag encoded fixed 64 bits.
|
|
1264
1288
|
* @returns Value read
|
|
1265
1289
|
*/
|
|
1266
|
-
|
|
1290
|
+
sfixed64(): Long;
|
|
1267
1291
|
|
|
1268
1292
|
/**
|
|
1269
1293
|
* Reads a float (32 bit) as a number.
|
|
1270
1294
|
* @returns Value read
|
|
1271
1295
|
*/
|
|
1272
|
-
|
|
1296
|
+
float(): number;
|
|
1273
1297
|
|
|
1274
1298
|
/**
|
|
1275
1299
|
* Reads a double (64 bit float) as a number.
|
|
1276
1300
|
* @returns Value read
|
|
1277
1301
|
*/
|
|
1278
|
-
|
|
1302
|
+
double(): number;
|
|
1279
1303
|
|
|
1280
1304
|
/**
|
|
1281
1305
|
* Reads a sequence of bytes preceeded by its length as a varint.
|
|
1282
1306
|
* @returns Value read
|
|
1283
1307
|
*/
|
|
1284
|
-
|
|
1308
|
+
bytes(): Uint8Array;
|
|
1285
1309
|
|
|
1286
1310
|
/**
|
|
1287
1311
|
* Reads a string preceeded by its byte length as a varint.
|
|
1288
1312
|
* @returns Value read
|
|
1289
1313
|
*/
|
|
1290
|
-
|
|
1314
|
+
string(): string;
|
|
1291
1315
|
|
|
1292
1316
|
/**
|
|
1293
1317
|
* Skips the specified number of bytes if specified, otherwise skips a varint.
|
|
1294
1318
|
* @param [length] Length if known, otherwise a varint is assumed
|
|
1295
1319
|
* @returns `this`
|
|
1296
1320
|
*/
|
|
1297
|
-
|
|
1321
|
+
skip(length?: number): Reader;
|
|
1298
1322
|
|
|
1299
1323
|
/** Recursion limit. */
|
|
1300
|
-
|
|
1324
|
+
static recursionLimit: number;
|
|
1301
1325
|
|
|
1302
1326
|
/**
|
|
1303
1327
|
* Skips the next element of the specified wire type.
|
|
@@ -1306,7 +1330,7 @@ export class Reader {
|
|
|
1306
1330
|
* @param [fieldNumber] Field number for validating group end tags
|
|
1307
1331
|
* @returns `this`
|
|
1308
1332
|
*/
|
|
1309
|
-
|
|
1333
|
+
skipType(wireType: number, depth?: number, fieldNumber?: number): Reader;
|
|
1310
1334
|
}
|
|
1311
1335
|
|
|
1312
1336
|
/** Wire format reader using node buffers. */
|
|
@@ -1324,13 +1348,13 @@ export class BufferReader extends Reader {
|
|
|
1324
1348
|
* @param end End offset
|
|
1325
1349
|
* @returns Raw bytes
|
|
1326
1350
|
*/
|
|
1327
|
-
|
|
1351
|
+
raw(start: number, end: number): Buffer;
|
|
1328
1352
|
|
|
1329
1353
|
/**
|
|
1330
1354
|
* Reads a sequence of bytes preceeded by its length as a varint.
|
|
1331
1355
|
* @returns Value read
|
|
1332
1356
|
*/
|
|
1333
|
-
|
|
1357
|
+
bytes(): Buffer;
|
|
1334
1358
|
}
|
|
1335
1359
|
|
|
1336
1360
|
/** Root namespace wrapping all types, enums, services, sub-namespaces etc. that belong together. */
|
|
@@ -1343,10 +1367,10 @@ export class Root extends NamespaceBase {
|
|
|
1343
1367
|
constructor(options?: { [k: string]: any });
|
|
1344
1368
|
|
|
1345
1369
|
/** Deferred extension fields. */
|
|
1346
|
-
|
|
1370
|
+
deferred: Field[];
|
|
1347
1371
|
|
|
1348
1372
|
/** Resolved file names of loaded files. */
|
|
1349
|
-
|
|
1373
|
+
files: string[];
|
|
1350
1374
|
|
|
1351
1375
|
/**
|
|
1352
1376
|
* Loads a namespace descriptor into a root namespace.
|
|
@@ -1355,7 +1379,7 @@ export class Root extends NamespaceBase {
|
|
|
1355
1379
|
* @param [depth] Current nesting depth, defaults to `0`
|
|
1356
1380
|
* @returns Root namespace
|
|
1357
1381
|
*/
|
|
1358
|
-
|
|
1382
|
+
static fromJSON(json: INamespace, root?: Root, depth?: number): Root;
|
|
1359
1383
|
|
|
1360
1384
|
/**
|
|
1361
1385
|
* Resolves the path of an imported file, relative to the importing origin.
|
|
@@ -1364,7 +1388,7 @@ export class Root extends NamespaceBase {
|
|
|
1364
1388
|
* @param target The file name being imported
|
|
1365
1389
|
* @returns Resolved path to `target` or `null` to skip the file
|
|
1366
1390
|
*/
|
|
1367
|
-
|
|
1391
|
+
resolvePath(origin: string, target: string): (string|null);
|
|
1368
1392
|
|
|
1369
1393
|
/**
|
|
1370
1394
|
* Fetch content from file path or url
|
|
@@ -1372,7 +1396,7 @@ export class Root extends NamespaceBase {
|
|
|
1372
1396
|
* @param path File path or url
|
|
1373
1397
|
* @param callback Callback function
|
|
1374
1398
|
*/
|
|
1375
|
-
|
|
1399
|
+
fetch(path: string, callback: FetchCallback): void;
|
|
1376
1400
|
|
|
1377
1401
|
/**
|
|
1378
1402
|
* Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.
|
|
@@ -1380,14 +1404,14 @@ export class Root extends NamespaceBase {
|
|
|
1380
1404
|
* @param options Parse options
|
|
1381
1405
|
* @param callback Callback function
|
|
1382
1406
|
*/
|
|
1383
|
-
|
|
1407
|
+
load(filename: (string|string[]), options: IParseOptions, callback: LoadCallback): void;
|
|
1384
1408
|
|
|
1385
1409
|
/**
|
|
1386
1410
|
* Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.
|
|
1387
1411
|
* @param filename Names of one or multiple files to load
|
|
1388
1412
|
* @param callback Callback function
|
|
1389
1413
|
*/
|
|
1390
|
-
|
|
1414
|
+
load(filename: (string|string[]), callback: LoadCallback): void;
|
|
1391
1415
|
|
|
1392
1416
|
/**
|
|
1393
1417
|
* Loads one or multiple .proto or preprocessed .json files into this root namespace and returns a promise.
|
|
@@ -1395,7 +1419,7 @@ export class Root extends NamespaceBase {
|
|
|
1395
1419
|
* @param [options] Parse options. Defaults to {@link parse.defaults} when omitted.
|
|
1396
1420
|
* @returns Promise
|
|
1397
1421
|
*/
|
|
1398
|
-
|
|
1422
|
+
load(filename: (string|string[]), options?: IParseOptions): Promise<Root>;
|
|
1399
1423
|
|
|
1400
1424
|
/**
|
|
1401
1425
|
* Synchronously loads one or multiple .proto or preprocessed .json files into this root namespace (node only).
|
|
@@ -1404,7 +1428,7 @@ export class Root extends NamespaceBase {
|
|
|
1404
1428
|
* @returns Root namespace
|
|
1405
1429
|
* @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid
|
|
1406
1430
|
*/
|
|
1407
|
-
|
|
1431
|
+
loadSync(filename: (string|string[]), options?: IParseOptions): Root;
|
|
1408
1432
|
}
|
|
1409
1433
|
|
|
1410
1434
|
/**
|
|
@@ -1446,13 +1470,13 @@ export namespace rpc {
|
|
|
1446
1470
|
constructor(rpcImpl: RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean);
|
|
1447
1471
|
|
|
1448
1472
|
/** RPC implementation. Becomes `null` once the service is ended. */
|
|
1449
|
-
|
|
1473
|
+
rpcImpl: (RPCImpl|null);
|
|
1450
1474
|
|
|
1451
1475
|
/** Whether requests are length-delimited. */
|
|
1452
|
-
|
|
1476
|
+
requestDelimited: boolean;
|
|
1453
1477
|
|
|
1454
1478
|
/** Whether responses are length-delimited. */
|
|
1455
|
-
|
|
1479
|
+
responseDelimited: boolean;
|
|
1456
1480
|
|
|
1457
1481
|
/**
|
|
1458
1482
|
* Calls a service method through {@link rpc.Service#rpcImpl|rpcImpl}.
|
|
@@ -1462,14 +1486,14 @@ export namespace rpc {
|
|
|
1462
1486
|
* @param request Request message or plain object
|
|
1463
1487
|
* @param callback Service callback
|
|
1464
1488
|
*/
|
|
1465
|
-
|
|
1489
|
+
rpcCall<TReq extends Message<TReq>, TRes extends Message<TRes>>(method: (Method|rpc.ServiceMethod<TReq, TRes>), requestCtor: Constructor<TReq>, responseCtor: Constructor<TRes>, request: (TReq|Properties<TReq>), callback: rpc.ServiceMethodCallback<TRes>): void;
|
|
1466
1490
|
|
|
1467
1491
|
/**
|
|
1468
1492
|
* Ends this service and emits the `end` event.
|
|
1469
1493
|
* @param [endedByRPC=false] Whether the service has been ended by the RPC implementation.
|
|
1470
1494
|
* @returns `this`
|
|
1471
1495
|
*/
|
|
1472
|
-
|
|
1496
|
+
end(endedByRPC?: boolean): rpc.Service;
|
|
1473
1497
|
}
|
|
1474
1498
|
}
|
|
1475
1499
|
|
|
@@ -1479,14 +1503,14 @@ export namespace rpc {
|
|
|
1479
1503
|
* @param requestData Request data
|
|
1480
1504
|
* @param callback Callback function
|
|
1481
1505
|
*/
|
|
1482
|
-
type RPCImpl = (method: (Method|rpc.ServiceMethod<Message<{}>, Message<{}>>), requestData: Uint8Array, callback: RPCImplCallback) => void;
|
|
1506
|
+
export type RPCImpl = (method: (Method|rpc.ServiceMethod<Message<{}>, Message<{}>>), requestData: Uint8Array, callback: RPCImplCallback) => void;
|
|
1483
1507
|
|
|
1484
1508
|
/**
|
|
1485
1509
|
* Node-style callback as used by {@link RPCImpl}.
|
|
1486
1510
|
* @param error Error, if any, otherwise `null`
|
|
1487
1511
|
* @param [response] Response data or `null` to signal end of stream, if there hasn't been an error
|
|
1488
1512
|
*/
|
|
1489
|
-
type RPCImplCallback = (error: (Error|null), response?: (Uint8Array|null)) => void;
|
|
1513
|
+
export type RPCImplCallback = (error: (Error|null), response?: (Uint8Array|null)) => void;
|
|
1490
1514
|
|
|
1491
1515
|
/** Reflected service. */
|
|
1492
1516
|
export class Service extends NamespaceBase {
|
|
@@ -1500,7 +1524,7 @@ export class Service extends NamespaceBase {
|
|
|
1500
1524
|
constructor(name: string, options?: { [k: string]: any });
|
|
1501
1525
|
|
|
1502
1526
|
/** Service methods. */
|
|
1503
|
-
|
|
1527
|
+
methods: { [k: string]: Method };
|
|
1504
1528
|
|
|
1505
1529
|
/**
|
|
1506
1530
|
* Constructs a service from a service descriptor.
|
|
@@ -1510,17 +1534,17 @@ export class Service extends NamespaceBase {
|
|
|
1510
1534
|
* @returns Created service
|
|
1511
1535
|
* @throws {TypeError} If arguments are invalid
|
|
1512
1536
|
*/
|
|
1513
|
-
|
|
1537
|
+
static fromJSON(name: string, json: IService, depth?: number): Service;
|
|
1514
1538
|
|
|
1515
1539
|
/**
|
|
1516
1540
|
* Converts this service to a service descriptor.
|
|
1517
1541
|
* @param [toJSONOptions] JSON conversion options
|
|
1518
1542
|
* @returns Service descriptor
|
|
1519
1543
|
*/
|
|
1520
|
-
|
|
1544
|
+
toJSON(toJSONOptions?: IToJSONOptions): IService;
|
|
1521
1545
|
|
|
1522
1546
|
/** Methods of this service as an array for iteration. */
|
|
1523
|
-
|
|
1547
|
+
readonly methodsArray: Method[];
|
|
1524
1548
|
|
|
1525
1549
|
/**
|
|
1526
1550
|
* Creates a runtime service using the specified rpc implementation.
|
|
@@ -1529,33 +1553,39 @@ export class Service extends NamespaceBase {
|
|
|
1529
1553
|
* @param [responseDelimited=false] Whether responses are length-delimited
|
|
1530
1554
|
* @returns RPC service. Useful where requests and/or responses are streamed.
|
|
1531
1555
|
*/
|
|
1532
|
-
|
|
1556
|
+
create(rpcImpl: RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): rpc.Service;
|
|
1533
1557
|
}
|
|
1534
1558
|
|
|
1535
1559
|
/** Service descriptor. */
|
|
1536
1560
|
export interface IService extends INamespace {
|
|
1537
1561
|
|
|
1562
|
+
/** Edition */
|
|
1563
|
+
edition?: string;
|
|
1564
|
+
|
|
1538
1565
|
/** Method descriptors */
|
|
1539
1566
|
methods: { [k: string]: IMethod };
|
|
1567
|
+
|
|
1568
|
+
/** Service comment */
|
|
1569
|
+
comment?: (string|null);
|
|
1540
1570
|
}
|
|
1541
1571
|
|
|
1542
1572
|
/**
|
|
1543
1573
|
* Gets the next token and advances.
|
|
1544
1574
|
* @returns Next token or `null` on eof
|
|
1545
1575
|
*/
|
|
1546
|
-
type TokenizerHandleNext = () => (string|null);
|
|
1576
|
+
export type TokenizerHandleNext = () => (string|null);
|
|
1547
1577
|
|
|
1548
1578
|
/**
|
|
1549
1579
|
* Peeks for the next token.
|
|
1550
1580
|
* @returns Next token or `null` on eof
|
|
1551
1581
|
*/
|
|
1552
|
-
type TokenizerHandlePeek = () => (string|null);
|
|
1582
|
+
export type TokenizerHandlePeek = () => (string|null);
|
|
1553
1583
|
|
|
1554
1584
|
/**
|
|
1555
1585
|
* Pushes a token back to the stack.
|
|
1556
1586
|
* @param token Token
|
|
1557
1587
|
*/
|
|
1558
|
-
type TokenizerHandlePush = (token: string) => void;
|
|
1588
|
+
export type TokenizerHandlePush = (token: string) => void;
|
|
1559
1589
|
|
|
1560
1590
|
/**
|
|
1561
1591
|
* Skips the next token.
|
|
@@ -1564,14 +1594,14 @@ type TokenizerHandlePush = (token: string) => void;
|
|
|
1564
1594
|
* @returns Whether the token matched
|
|
1565
1595
|
* @throws {Error} If the token didn't match and is not optional
|
|
1566
1596
|
*/
|
|
1567
|
-
type TokenizerHandleSkip = (expected: string, optional?: boolean) => boolean;
|
|
1597
|
+
export type TokenizerHandleSkip = (expected: string, optional?: boolean) => boolean;
|
|
1568
1598
|
|
|
1569
1599
|
/**
|
|
1570
1600
|
* Gets the comment on the previous line or, alternatively, the line comment on the specified line.
|
|
1571
1601
|
* @param [line] Line number
|
|
1572
1602
|
* @returns Comment text or `null` if none
|
|
1573
1603
|
*/
|
|
1574
|
-
type TokenizerHandleCmnt = (line?: number) => (string|null);
|
|
1604
|
+
export type TokenizerHandleCmnt = (line?: number) => (string|null);
|
|
1575
1605
|
|
|
1576
1606
|
/** Handle object returned from {@link tokenize}. */
|
|
1577
1607
|
export interface ITokenizerHandle {
|
|
@@ -1624,38 +1654,38 @@ export class Type extends NamespaceBase {
|
|
|
1624
1654
|
constructor(name: string, options?: { [k: string]: any });
|
|
1625
1655
|
|
|
1626
1656
|
/** Message fields. */
|
|
1627
|
-
|
|
1657
|
+
fields: { [k: string]: Field };
|
|
1628
1658
|
|
|
1629
1659
|
/** Oneofs declared within this namespace, if any. */
|
|
1630
|
-
|
|
1660
|
+
oneofs: { [k: string]: OneOf };
|
|
1631
1661
|
|
|
1632
1662
|
/** Extension ranges, if any. */
|
|
1633
|
-
|
|
1663
|
+
extensions: number[][];
|
|
1634
1664
|
|
|
1635
1665
|
/** Reserved ranges, if any. */
|
|
1636
|
-
|
|
1666
|
+
reserved: (number[]|string)[];
|
|
1637
1667
|
|
|
1638
1668
|
/** Message fields by id. */
|
|
1639
|
-
|
|
1669
|
+
readonly fieldsById: { [k: number]: Field };
|
|
1640
1670
|
|
|
1641
1671
|
/** Fields of this message as an array for iteration. */
|
|
1642
|
-
|
|
1672
|
+
readonly fieldsArray: Field[];
|
|
1643
1673
|
|
|
1644
1674
|
/** Oneofs of this message as an array for iteration. */
|
|
1645
|
-
|
|
1675
|
+
readonly oneofsArray: OneOf[];
|
|
1646
1676
|
|
|
1647
1677
|
/**
|
|
1648
1678
|
* The registered constructor, if any registered, otherwise a generic constructor.
|
|
1649
1679
|
* Assigning a function replaces the internal constructor. If the function does not extend {@link Message} yet, its prototype will be setup accordingly and static methods will be populated. If it already extends {@link Message}, it will just replace the internal constructor.
|
|
1650
1680
|
*/
|
|
1651
|
-
|
|
1681
|
+
ctor: Constructor<{}>;
|
|
1652
1682
|
|
|
1653
1683
|
/**
|
|
1654
1684
|
* Generates a constructor function for the specified type.
|
|
1655
1685
|
* @param mtype Message type
|
|
1656
1686
|
* @returns Codegen instance
|
|
1657
1687
|
*/
|
|
1658
|
-
|
|
1688
|
+
static generateConstructor(mtype: Type): Codegen;
|
|
1659
1689
|
|
|
1660
1690
|
/**
|
|
1661
1691
|
* Creates a message type from a message type descriptor.
|
|
@@ -1664,14 +1694,14 @@ export class Type extends NamespaceBase {
|
|
|
1664
1694
|
* @param [depth] Current nesting depth, defaults to `0`
|
|
1665
1695
|
* @returns Created message type
|
|
1666
1696
|
*/
|
|
1667
|
-
|
|
1697
|
+
static fromJSON(name: string, json: IType, depth?: number): Type;
|
|
1668
1698
|
|
|
1669
1699
|
/**
|
|
1670
1700
|
* Converts this message type to a message type descriptor.
|
|
1671
1701
|
* @param [toJSONOptions] JSON conversion options
|
|
1672
1702
|
* @returns Message type descriptor
|
|
1673
1703
|
*/
|
|
1674
|
-
|
|
1704
|
+
toJSON(toJSONOptions?: IToJSONOptions): IType;
|
|
1675
1705
|
|
|
1676
1706
|
/**
|
|
1677
1707
|
* Adds a nested object to this type.
|
|
@@ -1680,7 +1710,7 @@ export class Type extends NamespaceBase {
|
|
|
1680
1710
|
* @throws {TypeError} If arguments are invalid
|
|
1681
1711
|
* @throws {Error} If there is already a nested object with this name or, if a field, when there is already a field with this id
|
|
1682
1712
|
*/
|
|
1683
|
-
|
|
1713
|
+
add(object: ReflectionObject): Type;
|
|
1684
1714
|
|
|
1685
1715
|
/**
|
|
1686
1716
|
* Removes a nested object from this type.
|
|
@@ -1689,34 +1719,34 @@ export class Type extends NamespaceBase {
|
|
|
1689
1719
|
* @throws {TypeError} If arguments are invalid
|
|
1690
1720
|
* @throws {Error} If `object` is not a member of this type
|
|
1691
1721
|
*/
|
|
1692
|
-
|
|
1722
|
+
remove(object: ReflectionObject): Type;
|
|
1693
1723
|
|
|
1694
1724
|
/**
|
|
1695
1725
|
* Tests if the specified id is reserved.
|
|
1696
1726
|
* @param id Id to test
|
|
1697
1727
|
* @returns `true` if reserved, otherwise `false`
|
|
1698
1728
|
*/
|
|
1699
|
-
|
|
1729
|
+
isReservedId(id: number): boolean;
|
|
1700
1730
|
|
|
1701
1731
|
/**
|
|
1702
1732
|
* Tests if the specified name is reserved.
|
|
1703
1733
|
* @param name Name to test
|
|
1704
1734
|
* @returns `true` if reserved, otherwise `false`
|
|
1705
1735
|
*/
|
|
1706
|
-
|
|
1736
|
+
isReservedName(name: string): boolean;
|
|
1707
1737
|
|
|
1708
1738
|
/**
|
|
1709
1739
|
* Creates a new message of this type using the specified properties.
|
|
1710
1740
|
* @param [properties] Properties to set
|
|
1711
1741
|
* @returns Message instance
|
|
1712
1742
|
*/
|
|
1713
|
-
|
|
1743
|
+
create(properties?: { [k: string]: any }): Message<{}>;
|
|
1714
1744
|
|
|
1715
1745
|
/**
|
|
1716
1746
|
* Sets up {@link Type#encode|encode}, {@link Type#decode|decode} and {@link Type#verify|verify}.
|
|
1717
1747
|
* @returns `this`
|
|
1718
1748
|
*/
|
|
1719
|
-
|
|
1749
|
+
setup(): Type;
|
|
1720
1750
|
|
|
1721
1751
|
/**
|
|
1722
1752
|
* Encodes a message of this type. Does not implicitly {@link Type#verify|verify} messages.
|
|
@@ -1724,7 +1754,7 @@ export class Type extends NamespaceBase {
|
|
|
1724
1754
|
* @param [writer] Writer to encode to
|
|
1725
1755
|
* @returns writer
|
|
1726
1756
|
*/
|
|
1727
|
-
|
|
1757
|
+
encode(message: (Message<{}>|{ [k: string]: any }), writer?: Writer): Writer;
|
|
1728
1758
|
|
|
1729
1759
|
/**
|
|
1730
1760
|
* Encodes a message of this type preceeded by its byte length as a varint. Does not implicitly {@link Type#verify|verify} messages.
|
|
@@ -1732,7 +1762,7 @@ export class Type extends NamespaceBase {
|
|
|
1732
1762
|
* @param [writer] Writer to encode to
|
|
1733
1763
|
* @returns writer
|
|
1734
1764
|
*/
|
|
1735
|
-
|
|
1765
|
+
encodeDelimited(message: (Message<{}>|{ [k: string]: any }), writer?: Writer): Writer;
|
|
1736
1766
|
|
|
1737
1767
|
/**
|
|
1738
1768
|
* Decodes a message of this type.
|
|
@@ -1742,7 +1772,7 @@ export class Type extends NamespaceBase {
|
|
|
1742
1772
|
* @throws {Error} If the payload is not a reader or valid buffer
|
|
1743
1773
|
* @throws {util.ProtocolError<{}>} If required fields are missing
|
|
1744
1774
|
*/
|
|
1745
|
-
|
|
1775
|
+
decode(reader: (Reader|Uint8Array), length?: number): Message<{}>;
|
|
1746
1776
|
|
|
1747
1777
|
/**
|
|
1748
1778
|
* Decodes a message of this type preceeded by its byte length as a varint.
|
|
@@ -1751,21 +1781,21 @@ export class Type extends NamespaceBase {
|
|
|
1751
1781
|
* @throws {Error} If the payload is not a reader or valid buffer
|
|
1752
1782
|
* @throws {util.ProtocolError} If required fields are missing
|
|
1753
1783
|
*/
|
|
1754
|
-
|
|
1784
|
+
decodeDelimited(reader: (Reader|Uint8Array)): Message<{}>;
|
|
1755
1785
|
|
|
1756
1786
|
/**
|
|
1757
1787
|
* Verifies that field values are valid and that required fields are present.
|
|
1758
1788
|
* @param message Plain object to verify
|
|
1759
1789
|
* @returns `null` if valid, otherwise the reason why it is not
|
|
1760
1790
|
*/
|
|
1761
|
-
|
|
1791
|
+
verify(message: { [k: string]: any }): (null|string);
|
|
1762
1792
|
|
|
1763
1793
|
/**
|
|
1764
1794
|
* Creates a new message of this type from a plain object. Also converts values to their respective internal types.
|
|
1765
1795
|
* @param object Plain object to convert
|
|
1766
1796
|
* @returns Message instance
|
|
1767
1797
|
*/
|
|
1768
|
-
|
|
1798
|
+
fromObject(object: { [k: string]: any }): Message<{}>;
|
|
1769
1799
|
|
|
1770
1800
|
/**
|
|
1771
1801
|
* Creates a plain object from a message of this type. Also converts values to other types if specified.
|
|
@@ -1773,14 +1803,14 @@ export class Type extends NamespaceBase {
|
|
|
1773
1803
|
* @param [options] Conversion options
|
|
1774
1804
|
* @returns Plain object
|
|
1775
1805
|
*/
|
|
1776
|
-
|
|
1806
|
+
toObject(message: Message<{}>, options?: IConversionOptions): { [k: string]: any };
|
|
1777
1807
|
|
|
1778
1808
|
/**
|
|
1779
1809
|
* Gets the type url for this type.
|
|
1780
1810
|
* @param [prefix] Custom type url prefix, defaults to `"type.googleapis.com"`
|
|
1781
1811
|
* @returns The type url
|
|
1782
1812
|
*/
|
|
1783
|
-
|
|
1813
|
+
getTypeUrl(prefix?: string): string;
|
|
1784
1814
|
|
|
1785
1815
|
/**
|
|
1786
1816
|
* Type decorator (TypeScript).
|
|
@@ -1788,12 +1818,15 @@ export class Type extends NamespaceBase {
|
|
|
1788
1818
|
* @returns Decorator function
|
|
1789
1819
|
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
1790
1820
|
*/
|
|
1791
|
-
|
|
1821
|
+
static d<T extends Message<T>>(typeName?: string): TypeDecorator<T>;
|
|
1792
1822
|
}
|
|
1793
1823
|
|
|
1794
1824
|
/** Message type descriptor. */
|
|
1795
1825
|
export interface IType extends INamespace {
|
|
1796
1826
|
|
|
1827
|
+
/** Edition */
|
|
1828
|
+
edition?: string;
|
|
1829
|
+
|
|
1797
1830
|
/** Oneof descriptors */
|
|
1798
1831
|
oneofs?: { [k: string]: IOneOf };
|
|
1799
1832
|
|
|
@@ -1808,6 +1841,9 @@ export interface IType extends INamespace {
|
|
|
1808
1841
|
|
|
1809
1842
|
/** Whether a legacy group or not */
|
|
1810
1843
|
group?: boolean;
|
|
1844
|
+
|
|
1845
|
+
/** Message type comment */
|
|
1846
|
+
comment?: (string|null);
|
|
1811
1847
|
}
|
|
1812
1848
|
|
|
1813
1849
|
/** Conversion options as used by {@link Type#toObject} and {@link Message.toObject}. */
|
|
@@ -1855,7 +1891,7 @@ export interface IConversionOptions {
|
|
|
1855
1891
|
* @param target Target constructor
|
|
1856
1892
|
* @deprecated Legacy TypeScript decorator support. Will be removed in a future release.
|
|
1857
1893
|
*/
|
|
1858
|
-
type TypeDecorator<T extends Message<T>> = (target: Constructor<T>) => void;
|
|
1894
|
+
export type TypeDecorator<T extends Message<T>> = (target: Constructor<T>) => void;
|
|
1859
1895
|
|
|
1860
1896
|
/** Common type constants. */
|
|
1861
1897
|
export namespace types {
|
|
@@ -1943,19 +1979,17 @@ export namespace types {
|
|
|
1943
1979
|
}
|
|
1944
1980
|
|
|
1945
1981
|
/** Constructor type. */
|
|
1946
|
-
export
|
|
1947
|
-
new(...params: any[]): T; prototype: T;
|
|
1948
|
-
}
|
|
1982
|
+
export type Constructor<T> = Function & { new(...params: any[]): T; prototype: T };
|
|
1949
1983
|
|
|
1950
1984
|
/** Properties type. */
|
|
1951
|
-
type Properties<T> = { [P in keyof T]?: T[P] };
|
|
1985
|
+
export type Properties<T> = { [P in keyof T]?: T[P] };
|
|
1952
1986
|
|
|
1953
1987
|
/**
|
|
1954
1988
|
* Callback as used by {@link util.asPromise}.
|
|
1955
1989
|
* @param error Error, if any
|
|
1956
1990
|
* @param params Additional arguments
|
|
1957
1991
|
*/
|
|
1958
|
-
type asPromiseCallback = (error: (Error|null), ...params: any[]) => void;
|
|
1992
|
+
export type asPromiseCallback = (error: (Error|null), ...params: any[]) => void;
|
|
1959
1993
|
|
|
1960
1994
|
/**
|
|
1961
1995
|
* Appends code to the function's body or finishes generation.
|
|
@@ -1964,20 +1998,20 @@ type asPromiseCallback = (error: (Error|null), ...params: any[]) => void;
|
|
|
1964
1998
|
* @returns Itself or the generated function if finished
|
|
1965
1999
|
* @throws {Error} If format parameter counts do not match
|
|
1966
2000
|
*/
|
|
1967
|
-
type Codegen = (formatStringOrScope?: (string|{ [k: string]: any }), ...formatParams: any[]) => (Codegen|Function);
|
|
2001
|
+
export type Codegen = (formatStringOrScope?: (string|{ [k: string]: any }), ...formatParams: any[]) => (Codegen|Function);
|
|
1968
2002
|
|
|
1969
2003
|
/**
|
|
1970
2004
|
* Event listener as used by {@link util.EventEmitter}.
|
|
1971
2005
|
* @param args Arguments
|
|
1972
2006
|
*/
|
|
1973
|
-
type EventEmitterListener = (...args: any[]) => void;
|
|
2007
|
+
export type EventEmitterListener = (...args: any[]) => void;
|
|
1974
2008
|
|
|
1975
2009
|
/**
|
|
1976
2010
|
* Node-style callback as used by {@link util.fetch}.
|
|
1977
2011
|
* @param error Error, if any, otherwise `null`
|
|
1978
2012
|
* @param [contents] File contents, if there hasn't been an error
|
|
1979
2013
|
*/
|
|
1980
|
-
type FetchCallback = (error: Error, contents?: string) => void;
|
|
2014
|
+
export type FetchCallback = (error: Error, contents?: string) => void;
|
|
1981
2015
|
|
|
1982
2016
|
/** Options as used by {@link util.fetch}. */
|
|
1983
2017
|
export interface IFetchOptions {
|
|
@@ -2016,20 +2050,20 @@ export interface Long {
|
|
|
2016
2050
|
* A OneOf getter as returned by {@link util.oneOfGetter}.
|
|
2017
2051
|
* @returns Set field name, if any
|
|
2018
2052
|
*/
|
|
2019
|
-
type OneOfGetter = () => (string|undefined);
|
|
2053
|
+
export type OneOfGetter = () => (string|undefined);
|
|
2020
2054
|
|
|
2021
2055
|
/**
|
|
2022
2056
|
* A OneOf setter as returned by {@link util.oneOfSetter}.
|
|
2023
2057
|
* @param value Field name
|
|
2024
2058
|
*/
|
|
2025
|
-
type OneOfSetter = (value: (string|undefined)) => void;
|
|
2059
|
+
export type OneOfSetter = (value: (string|undefined)) => void;
|
|
2026
2060
|
|
|
2027
2061
|
/**
|
|
2028
2062
|
* An allocator as used by {@link util.pool}.
|
|
2029
2063
|
* @param size Buffer size
|
|
2030
2064
|
* @returns Buffer
|
|
2031
2065
|
*/
|
|
2032
|
-
type PoolAllocator = (size: number) => Uint8Array;
|
|
2066
|
+
export type PoolAllocator = (size: number) => Uint8Array;
|
|
2033
2067
|
|
|
2034
2068
|
/**
|
|
2035
2069
|
* A slicer as used by {@link util.pool}.
|
|
@@ -2037,7 +2071,7 @@ type PoolAllocator = (size: number) => Uint8Array;
|
|
|
2037
2071
|
* @param end End offset
|
|
2038
2072
|
* @returns Buffer slice
|
|
2039
2073
|
*/
|
|
2040
|
-
type PoolSlicer = (this: Uint8Array, start: number, end: number) => Uint8Array;
|
|
2074
|
+
export type PoolSlicer = (this: Uint8Array, start: number, end: number) => Uint8Array;
|
|
2041
2075
|
|
|
2042
2076
|
/** Various utility functions. */
|
|
2043
2077
|
export namespace util {
|
|
@@ -2122,7 +2156,7 @@ export namespace util {
|
|
|
2122
2156
|
* @param [ctx] Listener context
|
|
2123
2157
|
* @returns `this`
|
|
2124
2158
|
*/
|
|
2125
|
-
|
|
2159
|
+
on(evt: string, fn: EventEmitterListener, ctx?: any): this;
|
|
2126
2160
|
|
|
2127
2161
|
/**
|
|
2128
2162
|
* Removes an event listener or any matching listeners if arguments are omitted.
|
|
@@ -2130,7 +2164,7 @@ export namespace util {
|
|
|
2130
2164
|
* @param [fn] Listener to remove. Removes all listeners of `evt` if omitted.
|
|
2131
2165
|
* @returns `this`
|
|
2132
2166
|
*/
|
|
2133
|
-
|
|
2167
|
+
off(evt?: string, fn?: EventEmitterListener): this;
|
|
2134
2168
|
|
|
2135
2169
|
/**
|
|
2136
2170
|
* Emits an event by calling its listeners with the specified arguments.
|
|
@@ -2138,7 +2172,7 @@ export namespace util {
|
|
|
2138
2172
|
* @param args Arguments
|
|
2139
2173
|
* @returns `this`
|
|
2140
2174
|
*/
|
|
2141
|
-
|
|
2175
|
+
emit(evt: string, ...args: any[]): this;
|
|
2142
2176
|
}
|
|
2143
2177
|
|
|
2144
2178
|
/**
|
|
@@ -2251,75 +2285,75 @@ export namespace util {
|
|
|
2251
2285
|
constructor(lo: number, hi: number);
|
|
2252
2286
|
|
|
2253
2287
|
/** Low bits. */
|
|
2254
|
-
|
|
2288
|
+
lo: number;
|
|
2255
2289
|
|
|
2256
2290
|
/** High bits. */
|
|
2257
|
-
|
|
2291
|
+
hi: number;
|
|
2258
2292
|
|
|
2259
2293
|
/** Zero bits. */
|
|
2260
|
-
|
|
2294
|
+
static zero: util.LongBits;
|
|
2261
2295
|
|
|
2262
2296
|
/** Zero hash. */
|
|
2263
|
-
|
|
2297
|
+
static zeroHash: string;
|
|
2264
2298
|
|
|
2265
2299
|
/**
|
|
2266
2300
|
* Constructs new long bits from the specified number.
|
|
2267
2301
|
* @param value Value
|
|
2268
2302
|
* @returns Instance
|
|
2269
2303
|
*/
|
|
2270
|
-
|
|
2304
|
+
static fromNumber(value: number): util.LongBits;
|
|
2271
2305
|
|
|
2272
2306
|
/**
|
|
2273
2307
|
* Constructs new long bits from a number, long or string.
|
|
2274
2308
|
* @param value Value
|
|
2275
2309
|
* @returns Instance
|
|
2276
2310
|
*/
|
|
2277
|
-
|
|
2311
|
+
static from(value: (Long|number|string)): util.LongBits;
|
|
2278
2312
|
|
|
2279
2313
|
/**
|
|
2280
2314
|
* Converts this long bits to a possibly unsafe JavaScript number.
|
|
2281
2315
|
* @param [unsigned=false] Whether unsigned or not
|
|
2282
2316
|
* @returns Possibly unsafe number
|
|
2283
2317
|
*/
|
|
2284
|
-
|
|
2318
|
+
toNumber(unsigned?: boolean): number;
|
|
2285
2319
|
|
|
2286
2320
|
/**
|
|
2287
2321
|
* Converts this long bits to a long.
|
|
2288
2322
|
* @param [unsigned=false] Whether unsigned or not
|
|
2289
2323
|
* @returns Long
|
|
2290
2324
|
*/
|
|
2291
|
-
|
|
2325
|
+
toLong(unsigned?: boolean): Long;
|
|
2292
2326
|
|
|
2293
2327
|
/**
|
|
2294
2328
|
* Constructs new long bits from the specified 8 characters long hash.
|
|
2295
2329
|
* @param hash Hash
|
|
2296
2330
|
* @returns Bits
|
|
2297
2331
|
*/
|
|
2298
|
-
|
|
2332
|
+
static fromHash(hash: string): util.LongBits;
|
|
2299
2333
|
|
|
2300
2334
|
/**
|
|
2301
2335
|
* Converts this long bits to a 8 characters long hash.
|
|
2302
2336
|
* @returns Hash
|
|
2303
2337
|
*/
|
|
2304
|
-
|
|
2338
|
+
toHash(): string;
|
|
2305
2339
|
|
|
2306
2340
|
/**
|
|
2307
2341
|
* Zig-zag encodes this long bits.
|
|
2308
2342
|
* @returns `this`
|
|
2309
2343
|
*/
|
|
2310
|
-
|
|
2344
|
+
zzEncode(): util.LongBits;
|
|
2311
2345
|
|
|
2312
2346
|
/**
|
|
2313
2347
|
* Zig-zag decodes this long bits.
|
|
2314
2348
|
* @returns `this`
|
|
2315
2349
|
*/
|
|
2316
|
-
|
|
2350
|
+
zzDecode(): util.LongBits;
|
|
2317
2351
|
|
|
2318
2352
|
/**
|
|
2319
2353
|
* Calculates the length of this longbits when encoded as a varint.
|
|
2320
2354
|
* @returns Length
|
|
2321
2355
|
*/
|
|
2322
|
-
|
|
2356
|
+
length(): number;
|
|
2323
2357
|
}
|
|
2324
2358
|
|
|
2325
2359
|
/** Whether running within node or not. */
|
|
@@ -2436,6 +2470,9 @@ export namespace util {
|
|
|
2436
2470
|
*/
|
|
2437
2471
|
function merge(dst: { [k: string]: any }, src: { [k: string]: any }, ifNotSet?: boolean): { [k: string]: any };
|
|
2438
2472
|
|
|
2473
|
+
/** Schema declaration nesting limit. */
|
|
2474
|
+
let nestingLimit: number;
|
|
2475
|
+
|
|
2439
2476
|
/** Recursion limit. */
|
|
2440
2477
|
let recursionLimit: number;
|
|
2441
2478
|
|
|
@@ -2472,7 +2509,7 @@ export namespace util {
|
|
|
2472
2509
|
constructor(message: string, properties?: { [k: string]: any });
|
|
2473
2510
|
|
|
2474
2511
|
/** So far decoded message instance. */
|
|
2475
|
-
|
|
2512
|
+
instance: Message<T>;
|
|
2476
2513
|
}
|
|
2477
2514
|
|
|
2478
2515
|
/**
|
|
@@ -2574,14 +2611,6 @@ export namespace util {
|
|
|
2574
2611
|
/** Node's fs module if available. */
|
|
2575
2612
|
let fs: { [k: string]: any };
|
|
2576
2613
|
|
|
2577
|
-
/**
|
|
2578
|
-
* Checks a recursion depth.
|
|
2579
|
-
* @param depth Depth of recursion
|
|
2580
|
-
* @returns Depth of recursion
|
|
2581
|
-
* @throws {Error} If depth exceeds util.recursionLimit
|
|
2582
|
-
*/
|
|
2583
|
-
function checkDepth(depth: (number|undefined)): number;
|
|
2584
|
-
|
|
2585
2614
|
/**
|
|
2586
2615
|
* Converts an object's values to an array.
|
|
2587
2616
|
* @param object Object to convert
|
|
@@ -2681,7 +2710,7 @@ export const wrappers: { [k: string]: IWrapper };
|
|
|
2681
2710
|
* @param object Plain object
|
|
2682
2711
|
* @returns Message instance
|
|
2683
2712
|
*/
|
|
2684
|
-
type WrapperFromObjectConverter = (this: Type, object: { [k: string]: any }) => Message<{}>;
|
|
2713
|
+
export type WrapperFromObjectConverter = (this: Type, object: { [k: string]: any }) => Message<{}>;
|
|
2685
2714
|
|
|
2686
2715
|
/**
|
|
2687
2716
|
* To object converter part of an {@link IWrapper}.
|
|
@@ -2689,7 +2718,7 @@ type WrapperFromObjectConverter = (this: Type, object: { [k: string]: any }) =>
|
|
|
2689
2718
|
* @param [options] Conversion options
|
|
2690
2719
|
* @returns Plain object
|
|
2691
2720
|
*/
|
|
2692
|
-
type WrapperToObjectConverter = (this: Type, message: Message<{}>, options?: IConversionOptions) => { [k: string]: any };
|
|
2721
|
+
export type WrapperToObjectConverter = (this: Type, message: Message<{}>, options?: IConversionOptions) => { [k: string]: any };
|
|
2693
2722
|
|
|
2694
2723
|
/** Common type wrapper part of {@link wrappers}. */
|
|
2695
2724
|
export interface IWrapper {
|
|
@@ -2708,50 +2737,50 @@ export class Writer {
|
|
|
2708
2737
|
constructor();
|
|
2709
2738
|
|
|
2710
2739
|
/** Current length. */
|
|
2711
|
-
|
|
2740
|
+
len: number;
|
|
2712
2741
|
|
|
2713
2742
|
/** Operations head. */
|
|
2714
|
-
|
|
2743
|
+
head: object;
|
|
2715
2744
|
|
|
2716
2745
|
/** Operations tail */
|
|
2717
|
-
|
|
2746
|
+
tail: object;
|
|
2718
2747
|
|
|
2719
2748
|
/** Linked forked states. */
|
|
2720
|
-
|
|
2749
|
+
states: (object|null);
|
|
2721
2750
|
|
|
2722
2751
|
/**
|
|
2723
2752
|
* Creates a new writer.
|
|
2724
2753
|
* @returns A {@link BufferWriter} when Buffers are supported, otherwise a {@link Writer}
|
|
2725
2754
|
*/
|
|
2726
|
-
|
|
2755
|
+
static create(): (BufferWriter|Writer);
|
|
2727
2756
|
|
|
2728
2757
|
/**
|
|
2729
2758
|
* Allocates a buffer of the specified size.
|
|
2730
2759
|
* @param size Buffer size
|
|
2731
2760
|
* @returns Buffer
|
|
2732
2761
|
*/
|
|
2733
|
-
|
|
2762
|
+
static alloc(size: number): Uint8Array;
|
|
2734
2763
|
|
|
2735
2764
|
/**
|
|
2736
2765
|
* Writes an unsigned 32 bit value as a varint.
|
|
2737
2766
|
* @param value Value to write
|
|
2738
2767
|
* @returns `this`
|
|
2739
2768
|
*/
|
|
2740
|
-
|
|
2769
|
+
uint32(value: number): Writer;
|
|
2741
2770
|
|
|
2742
2771
|
/**
|
|
2743
2772
|
* Writes a signed 32 bit value as a varint.
|
|
2744
2773
|
* @param value Value to write
|
|
2745
2774
|
* @returns `this`
|
|
2746
2775
|
*/
|
|
2747
|
-
|
|
2776
|
+
int32(value: number): Writer;
|
|
2748
2777
|
|
|
2749
2778
|
/**
|
|
2750
2779
|
* Writes a 32 bit value as a varint, zig-zag encoded.
|
|
2751
2780
|
* @param value Value to write
|
|
2752
2781
|
* @returns `this`
|
|
2753
2782
|
*/
|
|
2754
|
-
|
|
2783
|
+
sint32(value: number): Writer;
|
|
2755
2784
|
|
|
2756
2785
|
/**
|
|
2757
2786
|
* Writes an unsigned 64 bit value as a varint.
|
|
@@ -2759,7 +2788,7 @@ export class Writer {
|
|
|
2759
2788
|
* @returns `this`
|
|
2760
2789
|
* @throws {TypeError} If `value` is a string and no long library is present.
|
|
2761
2790
|
*/
|
|
2762
|
-
|
|
2791
|
+
uint64(value: (Long|number|string)): Writer;
|
|
2763
2792
|
|
|
2764
2793
|
/**
|
|
2765
2794
|
* Writes a signed 64 bit value as a varint.
|
|
@@ -2767,7 +2796,7 @@ export class Writer {
|
|
|
2767
2796
|
* @returns `this`
|
|
2768
2797
|
* @throws {TypeError} If `value` is a string and no long library is present.
|
|
2769
2798
|
*/
|
|
2770
|
-
|
|
2799
|
+
int64(value: (Long|number|string)): Writer;
|
|
2771
2800
|
|
|
2772
2801
|
/**
|
|
2773
2802
|
* Writes a signed 64 bit value as a varint, zig-zag encoded.
|
|
@@ -2775,28 +2804,28 @@ export class Writer {
|
|
|
2775
2804
|
* @returns `this`
|
|
2776
2805
|
* @throws {TypeError} If `value` is a string and no long library is present.
|
|
2777
2806
|
*/
|
|
2778
|
-
|
|
2807
|
+
sint64(value: (Long|number|string)): Writer;
|
|
2779
2808
|
|
|
2780
2809
|
/**
|
|
2781
2810
|
* Writes a boolish value as a varint.
|
|
2782
2811
|
* @param value Value to write
|
|
2783
2812
|
* @returns `this`
|
|
2784
2813
|
*/
|
|
2785
|
-
|
|
2814
|
+
bool(value: boolean): Writer;
|
|
2786
2815
|
|
|
2787
2816
|
/**
|
|
2788
2817
|
* Writes an unsigned 32 bit value as fixed 32 bits.
|
|
2789
2818
|
* @param value Value to write
|
|
2790
2819
|
* @returns `this`
|
|
2791
2820
|
*/
|
|
2792
|
-
|
|
2821
|
+
fixed32(value: number): Writer;
|
|
2793
2822
|
|
|
2794
2823
|
/**
|
|
2795
2824
|
* Writes a signed 32 bit value as fixed 32 bits.
|
|
2796
2825
|
* @param value Value to write
|
|
2797
2826
|
* @returns `this`
|
|
2798
2827
|
*/
|
|
2799
|
-
|
|
2828
|
+
sfixed32(value: number): Writer;
|
|
2800
2829
|
|
|
2801
2830
|
/**
|
|
2802
2831
|
* Writes an unsigned 64 bit value as fixed 64 bits.
|
|
@@ -2804,7 +2833,7 @@ export class Writer {
|
|
|
2804
2833
|
* @returns `this`
|
|
2805
2834
|
* @throws {TypeError} If `value` is a string and no long library is present.
|
|
2806
2835
|
*/
|
|
2807
|
-
|
|
2836
|
+
fixed64(value: (Long|number|string)): Writer;
|
|
2808
2837
|
|
|
2809
2838
|
/**
|
|
2810
2839
|
* Writes a signed 64 bit value as fixed 64 bits.
|
|
@@ -2812,67 +2841,67 @@ export class Writer {
|
|
|
2812
2841
|
* @returns `this`
|
|
2813
2842
|
* @throws {TypeError} If `value` is a string and no long library is present.
|
|
2814
2843
|
*/
|
|
2815
|
-
|
|
2844
|
+
sfixed64(value: (Long|number|string)): Writer;
|
|
2816
2845
|
|
|
2817
2846
|
/**
|
|
2818
2847
|
* Writes a float (32 bit).
|
|
2819
2848
|
* @param value Value to write
|
|
2820
2849
|
* @returns `this`
|
|
2821
2850
|
*/
|
|
2822
|
-
|
|
2851
|
+
float(value: number): Writer;
|
|
2823
2852
|
|
|
2824
2853
|
/**
|
|
2825
2854
|
* Writes a double (64 bit float).
|
|
2826
2855
|
* @param value Value to write
|
|
2827
2856
|
* @returns `this`
|
|
2828
2857
|
*/
|
|
2829
|
-
|
|
2858
|
+
double(value: number): Writer;
|
|
2830
2859
|
|
|
2831
2860
|
/**
|
|
2832
2861
|
* Writes a sequence of bytes.
|
|
2833
2862
|
* @param value Buffer or base64 encoded string to write
|
|
2834
2863
|
* @returns `this`
|
|
2835
2864
|
*/
|
|
2836
|
-
|
|
2865
|
+
bytes(value: (Uint8Array|string)): Writer;
|
|
2837
2866
|
|
|
2838
2867
|
/**
|
|
2839
2868
|
* Writes raw bytes without a tag or length prefix.
|
|
2840
2869
|
* @param value Raw bytes
|
|
2841
2870
|
* @returns `this`
|
|
2842
2871
|
*/
|
|
2843
|
-
|
|
2872
|
+
raw(value: Uint8Array): Writer;
|
|
2844
2873
|
|
|
2845
2874
|
/**
|
|
2846
2875
|
* Writes a string.
|
|
2847
2876
|
* @param value Value to write
|
|
2848
2877
|
* @returns `this`
|
|
2849
2878
|
*/
|
|
2850
|
-
|
|
2879
|
+
string(value: string): Writer;
|
|
2851
2880
|
|
|
2852
2881
|
/**
|
|
2853
2882
|
* Forks this writer's state by pushing it to a stack.
|
|
2854
2883
|
* Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state.
|
|
2855
2884
|
* @returns `this`
|
|
2856
2885
|
*/
|
|
2857
|
-
|
|
2886
|
+
fork(): Writer;
|
|
2858
2887
|
|
|
2859
2888
|
/**
|
|
2860
2889
|
* Resets this instance to the last state.
|
|
2861
2890
|
* @returns `this`
|
|
2862
2891
|
*/
|
|
2863
|
-
|
|
2892
|
+
reset(): Writer;
|
|
2864
2893
|
|
|
2865
2894
|
/**
|
|
2866
2895
|
* Resets to the last state and appends the fork state's current write length as a varint followed by its operations.
|
|
2867
2896
|
* @returns `this`
|
|
2868
2897
|
*/
|
|
2869
|
-
|
|
2898
|
+
ldelim(): Writer;
|
|
2870
2899
|
|
|
2871
2900
|
/**
|
|
2872
2901
|
* Finishes the write operation.
|
|
2873
2902
|
* @returns Finished buffer
|
|
2874
2903
|
*/
|
|
2875
|
-
|
|
2904
|
+
finish(): Uint8Array;
|
|
2876
2905
|
|
|
2877
2906
|
/**
|
|
2878
2907
|
* Finishes the write operation, writing into the provided buffer.
|
|
@@ -2882,7 +2911,7 @@ export class Writer {
|
|
|
2882
2911
|
* @param [offset=0] Offset to start writing at
|
|
2883
2912
|
* @returns The provided buffer
|
|
2884
2913
|
*/
|
|
2885
|
-
|
|
2914
|
+
finishInto<T extends Uint8Array>(buf: T, offset?: number): T;
|
|
2886
2915
|
}
|
|
2887
2916
|
|
|
2888
2917
|
/** Wire format writer using node buffers. */
|
|
@@ -2896,18 +2925,18 @@ export class BufferWriter extends Writer {
|
|
|
2896
2925
|
* @param size Buffer size
|
|
2897
2926
|
* @returns Buffer
|
|
2898
2927
|
*/
|
|
2899
|
-
|
|
2928
|
+
static alloc(size: number): Buffer;
|
|
2900
2929
|
|
|
2901
2930
|
/**
|
|
2902
2931
|
* Writes raw bytes without a tag or length prefix.
|
|
2903
2932
|
* @param value Raw bytes
|
|
2904
2933
|
* @returns `this`
|
|
2905
2934
|
*/
|
|
2906
|
-
|
|
2935
|
+
raw(value: Uint8Array): BufferWriter;
|
|
2907
2936
|
|
|
2908
2937
|
/**
|
|
2909
2938
|
* Finishes the write operation.
|
|
2910
2939
|
* @returns Finished buffer
|
|
2911
2940
|
*/
|
|
2912
|
-
|
|
2941
|
+
finish(): Buffer;
|
|
2913
2942
|
}
|