Get fully-qualified path of Protobuf message in JavaScript

Viewed 162

I am trying to get the fully-qualified path of my Protobuf message type in JavaScript. For example, given the following file: status.proto

package my.messages.proto; 

message Status {
   string code = 1;
}

Once compiled with protoc, I can then do something like:

import { Status } from 'gen/my/messages/proto/status_pb.js';

const status = new Status();

But then how can I get the fully-qualified path of this message? I want a string of my.messages.proto.Status, but I can't seem to find any API where this is possible. I basically want the equivalent of the C++ function message.GetDescriptor()->full_name().

If I do console.log(status);, I see something printed out like:

my.messages.proto.Status {wrappers_: null, messageId_: undefined, arrayIndexOffset_: -1, array: Array(1), pivot_: 1.7976931348623157e+308, …}

So, the information is there, but just not sure how I can access it. Is this possible in JavaScript with Protobuf?

0 Answers
Related