TheThingsArchive / node-app-sdk

The Things Network Application SDK for Node.JS
https://www.thethingsnetwork.org/docs/node-js/
MIT License
41 stars 28 forks source link

Wrap Manager gRPC API #54

Closed FokkeZB closed 7 years ago

FokkeZB commented 7 years ago

WIP in https://github.com/TheThingsNetwork/node-app-sdk/tree/feature/manager-grpc

/cc @htdvisser

htdvisser commented 7 years ago

Definitely better to generate code.

FokkeZB commented 7 years ago

Don't really like the way you construct a request with the generated code.

johanstokking commented 7 years ago

You mean the setters for properties? I think it's not that bad, especially because it's protobufs which only know fields. This makes it forward-compatible, not if you need a specific constructor or field order.

FokkeZB commented 7 years ago

What I mean is that you need to use the Request objects where the dynamic version lets you use plain objects.

I'll play with the generated variant

FokkeZB commented 7 years ago

@johanstokking @htdvisser I try to generate them but again, the Q is.. how to get the dependencies?

$ protoc --js_out=import_style=commonjs,binary:../node/static_codegen/ --grpc_out=../node/static_codegen --plugin=protoc-gen-grpc=grpc_node_plugin handler.proto 
google/api/annotations.proto: File not found.
ttn/api/api.proto: File not found.
ttn/api/broker/broker.proto: File not found.
ttn/api/protocol/protocol.proto: File not found.
ttn/api/protocol/lorawan/device.proto: File not found.
handler.proto: Import "google/api/annotations.proto" was not found or had errors.
handler.proto: Import "ttn/api/api.proto" was not found or had errors.
handler.proto: Import "ttn/api/broker/broker.proto" was not found or had errors.
handler.proto: Import "ttn/api/protocol/protocol.proto" was not found or had errors.
handler.proto: Import "ttn/api/protocol/lorawan/device.proto" was not found or had errors.
handler.proto:19:3: "protocol.Message" is not defined.
handler.proto:20:3: "broker.DownlinkOption" is not defined.
handler.proto:21:3: "protocol.ActivationMetadata" is not defined.
handler.proto:35:3: "api.SystemStats" is not defined.
handler.proto:36:3: "api.ComponentStats" is not defined.
handler.proto:38:3: "api.Rates" is not defined.
handler.proto:39:3: "api.Rates" is not defined.
handler.proto:40:3: "api.Rates" is not defined.
handler.proto:80:5: "lorawan.Device" is not defined.
handler.proto:26:27: "broker.ActivationChallengeRequest" is not defined.
handler.proto:26:71: "broker.ActivationChallengeResponse" is not defined.
handler.proto:27:16: "broker.DeduplicatedDeviceActivationRequest" is not defined.

I guess the repo needs a Makefile. Should it then clone the ttn repo, pull in dependencies (go vendor?), generate the .js files, copy them to this repo and delete the clone?

romeovs commented 7 years ago

Done by #64