How to use the google-protobuf/google/protobuf/any_pb.js.Any function in google-protobuf

To help you get started, we’ve selected a few google-protobuf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pulumi / pulumi / sdk / nodejs / cmd / dynamic-provider / index.ts View on Github external
function grpcResponseFromError(e: {id: string, properties: any, message: string, reasons?: string[]}): any {
    // Create response object.
    const resp = new statusproto.Status();
    resp.setCode(grpc.status.UNKNOWN);
    resp.setMessage(e.message);

    const metadata = new grpc.Metadata();
    if (e.id) {
        // Object created successfully, but failed to initialize. Pack initialization failure into
        // details.
        const detail = new provproto.ErrorResourceInitFailed();
        detail.setId(e.id);
        detail.setProperties(structproto.Struct.fromJavaScript(e.properties || {}));
        detail.setReasonsList(e.reasons || []);

        const details = new anyproto.Any();
        details.pack(detail.serializeBinary(), "pulumirpc.ErrorResourceInitFailed");

        // Add details to metadata.
        resp.addDetails(details);
        // NOTE: `grpc-status-details-bin` is a magic field that allows us to send structured
        // protobuf data as an error back through gRPC. This notion of details is a first-class in
        // the Go gRPC implementation, and the nodejs implementation has not quite caught up to it,
        // which is why it's cumbersome here.
        metadata.add("grpc-status-details-bin", Buffer.from(resp.serializeBinary()));
    }

    return {
        code: grpc.status.UNKNOWN,
        message: e.message,
        metadata: metadata,
    };
github googlefonts / fontbakery-dashboard / containers / base / javascript / node / util / ProtobufAnyHandler.js View on Github external
_p.pack = function(message) {
    var any = new Any()
      , typeName = this.getTypeNameForMessage(message) // e.g. 'fontbakery.dashboard.Files'
      ;
    any.pack(message.serializeBinary(), typeName);
    return any;
};
github ArcBlock / forge-js / forge / forge-proto / lib / create_asset_tx_pb.js View on Github external
proto.forge_abi.CreateAssetTx.deserializeBinaryFromReader = function(msg, reader) {
  while (reader.nextField()) {
    if (reader.isEndGroup()) {
      break;
    }
    var field = reader.getFieldNumber();
    switch (field) {
    case 1:
      var value = /** @type {string} */ (reader.readString());
      msg.setMoniker(value);
      break;
    case 2:
      var value = new google_protobuf_any_pb.Any;
      reader.readMessage(value,google_protobuf_any_pb.Any.deserializeBinaryFromReader);
      msg.setData(value);
      break;
    case 3:
      var value = /** @type {boolean} */ (reader.readBool());
      msg.setReadonly(value);
      break;
    case 4:
      var value = /** @type {boolean} */ (reader.readBool());
      msg.setTransferrable(value);
      break;
    case 5:
      var value = /** @type {number} */ (reader.readUint32());
      msg.setTtl(value);
      break;
    case 6:
github improbable-eng / ts-protoc-gen / examples / generated / proto / examplecom / well_known_message_pb.js View on Github external
proto.examplecom.WellKnownMessage.deserializeBinaryFromReader = function(msg, reader) {
  while (reader.nextField()) {
    if (reader.isEndGroup()) {
      break;
    }
    var field = reader.getFieldNumber();
    switch (field) {
    case 1:
      var value = new google_protobuf_compiler_plugin_pb.CodeGeneratorRequest;
      reader.readMessage(value,google_protobuf_compiler_plugin_pb.CodeGeneratorRequest.deserializeBinaryFromReader);
      msg.setMyCodeGeneratorRequest(value);
      break;
    case 2:
      var value = new google_protobuf_any_pb.Any;
      reader.readMessage(value,google_protobuf_any_pb.Any.deserializeBinaryFromReader);
      msg.setMyAny(value);
      break;
    case 3:
      var value = new google_protobuf_api_pb.Method;
      reader.readMessage(value,google_protobuf_api_pb.Method.deserializeBinaryFromReader);
      msg.setMyMethod(value);
      break;
    case 4:
      var value = new google_protobuf_descriptor_pb.GeneratedCodeInfo;
      reader.readMessage(value,google_protobuf_descriptor_pb.GeneratedCodeInfo.deserializeBinaryFromReader);
      msg.setMyGeneratedCodeInfo(value);
      break;
    case 5:
      var value = new google_protobuf_duration_pb.Duration;
      reader.readMessage(value,google_protobuf_duration_pb.Duration.deserializeBinaryFromReader);
github Opteo / google-ads-node / src / protos / google / longrunning / operations_pb.js View on Github external
case 2:
      var value = new google_protobuf_any_pb.Any;
      reader.readMessage(value,google_protobuf_any_pb.Any.deserializeBinaryFromReader);
      msg.setMetadata(value);
      break;
    case 3:
      var value = /** @type {boolean} */ (reader.readBool());
      msg.setDone(value);
      break;
    case 4:
      var value = new google_rpc_status_pb.Status;
      reader.readMessage(value,google_rpc_status_pb.Status.deserializeBinaryFromReader);
      msg.setError(value);
      break;
    case 5:
      var value = new google_protobuf_any_pb.Any;
      reader.readMessage(value,google_protobuf_any_pb.Any.deserializeBinaryFromReader);
      msg.setResponse(value);
      break;
    default:
      reader.skipField();
      break;
    }
  }
  return msg;
};
github ArcBlock / forge-js / forge / forge-proto / lib / transfer_tx_pb.js View on Github external
switch (field) {
    case 1:
      var value = /** @type {string} */ (reader.readString());
      msg.setTo(value);
      break;
    case 2:
      var value = new type_pb.BigUint;
      reader.readMessage(value,type_pb.BigUint.deserializeBinaryFromReader);
      msg.setValue(value);
      break;
    case 3:
      var value = /** @type {string} */ (reader.readString());
      msg.addAssets(value);
      break;
    case 15:
      var value = new google_protobuf_any_pb.Any;
      reader.readMessage(value,google_protobuf_any_pb.Any.deserializeBinaryFromReader);
      msg.setData(value);
      break;
    default:
      reader.skipField();
      break;
    }
  }
  return msg;
};
github ArcBlock / forge-js / forge / forge-proto / lib / setup_swap_tx_pb.js View on Github external
msg.addAssets(value);
      break;
    case 3:
      var value = /** @type {string} */ (reader.readString());
      msg.setReceiver(value);
      break;
    case 4:
      var value = /** @type {!Uint8Array} */ (reader.readBytes());
      msg.setHashlock(value);
      break;
    case 5:
      var value = /** @type {number} */ (reader.readUint32());
      msg.setLocktime(value);
      break;
    case 15:
      var value = new google_protobuf_any_pb.Any;
      reader.readMessage(value,google_protobuf_any_pb.Any.deserializeBinaryFromReader);
      msg.setData(value);
      break;
    default:
      reader.skipField();
      break;
    }
  }
  return msg;
};
github ArcBlock / forge-js / forge / forge-proto / lib / deploy_protocol_tx_pb.js View on Github external
break;
    case 9:
      var value = /** @type {string} */ (reader.readString());
      msg.addSources(value);
      break;
    case 10:
      var value = new proto.forge_abi.CodeInfo;
      reader.readMessage(value,proto.forge_abi.CodeInfo.deserializeBinaryFromReader);
      msg.addCode(value);
      break;
    case 11:
      var value = /** @type {string} */ (reader.readString());
      msg.addTags(value);
      break;
    case 15:
      var value = new google_protobuf_any_pb.Any;
      reader.readMessage(value,google_protobuf_any_pb.Any.deserializeBinaryFromReader);
      msg.setData(value);
      break;
    default:
      reader.skipField();
      break;
    }
  }
  return msg;
};
github Opteo / google-ads-node / src / protos / google / longrunning / operations_pb.js View on Github external
proto.google.longrunning.Operation.deserializeBinaryFromReader = function(msg, reader) {
  while (reader.nextField()) {
    if (reader.isEndGroup()) {
      break;
    }
    var field = reader.getFieldNumber();
    switch (field) {
    case 1:
      var value = /** @type {string} */ (reader.readString());
      msg.setName(value);
      break;
    case 2:
      var value = new google_protobuf_any_pb.Any;
      reader.readMessage(value,google_protobuf_any_pb.Any.deserializeBinaryFromReader);
      msg.setMetadata(value);
      break;
    case 3:
      var value = /** @type {boolean} */ (reader.readBool());
      msg.setDone(value);
      break;
    case 4:
      var value = new google_rpc_status_pb.Status;
      reader.readMessage(value,google_rpc_status_pb.Status.deserializeBinaryFromReader);
      msg.setError(value);
      break;
    case 5:
      var value = new google_protobuf_any_pb.Any;
      reader.readMessage(value,google_protobuf_any_pb.Any.deserializeBinaryFromReader);
      msg.setResponse(value);

google-protobuf

Protocol Buffers for JavaScript

BSD-3-Clause
Latest version published 2 months ago

Package Health Score

89 / 100
Full package analysis