Questions tagged [protobuf.js]

`protobuf-js' is a Protocol Buffers encoder/decoder for Javascript.

108 questions
2
votes
2 answers

protobuf.js pbts: Generating typescript types from .proto without null | undefined

I'm using pbts to generate typescript declaration files for a large protobuf library. The problem is that the pbts output makes every property undefined or null, e.g. interface IMyThing { myProp?: string | null; } and what I want is: interface…
Marc Gelfo
  • 81
  • 8
2
votes
0 answers

Converting protobuf.js Types to custom formats

In my protobuf schema, I have a type that contains binary data (already defined in an existing schema, I can't change this): // message BinaryKey { bytes data = 1; } let BinaryKey = new Type('BinaryKey') BinaryKey.add(new Field('data', 1,…
zakum1
  • 895
  • 6
  • 20
2
votes
1 answer

How to decode protobuf base64 string to js object

I'm try to decode protobuf message from server side (base64 string) to javascript object. Use for decode protobuf.js. As doc suggest : var builder = ProtoBuf.newBuilder({ convertFieldsToCamelCase: true }); var YourMessage =…
D.Cobby
  • 23
  • 1
  • 5
1
vote
0 answers

How do I create an object that is compatible with the Timestamp type in protobuf.js in TypeScript?

When I try to assign to a Timestamp field of a protocol buffer built with protobuf.js, I get a TypeScript error. My protocol buffer has the following definition: syntax = "proto3"; import "google/protobuf/timestamp.proto"; message MyMessage { …
Aaron Stanek
  • 408
  • 2
  • 9
1
vote
0 answers

HTTP POST x-protobuf data using axios

Previously I used request lib to send my requests, but since it is deprecated I'm moving to axios. It looked like this: const request = { url: url, method: 'POST', encoding: null, headers: { 'content-type':…
user122222
  • 2,179
  • 4
  • 35
  • 78
1
vote
0 answers

Sending gRPC request in node without .proto file

I have a NextJS with Typescript application. I want to connect to a running gRPC server and send gRPC requests to the server. I do not have access to the .proto file, but I know the server address, service name, messages names and fields. I can't…
1
vote
2 answers

ProtoBuf - Can a field support two possible datatypes?

is it possible for one field in protobuf to support/accept a string or an array of string. This is my message: message MessageA { string fieldId =1; string method = 2; google.protobuf.Any value =3; } The reason for it being dynamic is because…
1
vote
0 answers

Cannot run my react native app on my emulator

so recently, I created my first project in react native, but when I want to run it on my android emulator, it returns me this error : FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'Wood'. >…
1
vote
0 answers

protobufjs fixed64 mismatch

protobuf.js version: 7.1.2 I have a proto message with a single field fixed64. For certain numbers, there is a missmatch between the encoded and decoded objects. I've created this repo as a reference. To execute it, run: $ npm i $ node index.js It…
luckslovez
  • 21
  • 3
1
vote
0 answers

How to generate constant typescript enums from protobuf?

I have this protobuf code enum Language { en = 0; jp = 1; ar = 2; } When it's generated to typescript the values become Lanuage.en = 0, Language.jp = 1 ... What I want is Language.en = "ENGLISH", Language.ar = "ARABIC" How to achieve this?
rksh1997
  • 1,103
  • 7
  • 17
1
vote
1 answer

TS-1068 and TS-1442

I have a class which has a member public offerTags: [ 'Array' ].; The above line is throwing error Unexpected token. A constructor, method, accessor, or property was expected.ts(1068) and Expected '=' for property initializer.ts(1442) . This…
cutiecatie
  • 61
  • 6
1
vote
1 answer

Protobuf: Serialize/DeSerialize C++ to Js

I'm using protobuf to send/receive binary data from Cpp to Js and vice-versa and I'm using QWebChannel to communicate with the HTML client. Question: How to deserialize binary data in cpp which is serialized and sent from Js? Following I…
1
vote
1 answer

How can we convert .proto file and JSON descriptors?

I'd like to convert from .proto file to JSON descriptors. .proto file is like as this: https://github.com/protobufjs/protobuf.js/blob/master/google/protobuf/type.proto JSON descriptors is like as…
Robocco
  • 121
  • 1
  • 6
1
vote
1 answer

How to write a series of Messages into a file and read them back using protobuf (protobuf.js with proto3)?

I tried the example and was able to get one Message to work: // awesome.proto package awesomepackage; syntax = "proto3"; message AwesomeMessage { string awesome_field = 1; // becomes awesomeField } A complete solution is in my answer in this…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
1
vote
1 answer

Prefix protobuf message with signed 4 byte int

I am working with a Websocket API which I send protobuf objects to. The documentation says: Server uses Big Endian format for binary data. Messages sent back and forth require a signed 4 byte int of the message size, prefixed to the message So the…
Coder1
  • 13,139
  • 15
  • 59
  • 89