-
Notifications
You must be signed in to change notification settings - Fork 1
Introduce deviceOSProtobuf.getDefinition(name) to device-os-protobuf #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… also: - Adds `lodash` to dependencies - Drops `mkdirp` from dependencies
This is dynamically using pbjs generated JSON to get the request ID rather than an additional static mapping outside of *.proto files
…NumberRequest") instead of "SERIAL_NUMBER" Intent behind "SERIAL_NUMBER" was ambiguous, it could be the request message OR the reply message. Instead of introducing some kind of clever mapping we'll build the API this way
Uses similar approach to particle-usb (documentation module) We ignore protobufjs generated documentation for now because it is HUGE and potentially not useful
We use a typedef to describe the object that getDefinition returns
This commit introduces lots of other test coverage against real world Device OS messages
While critically reviewing this PR myself, I decided to read the entire README of the protobufjs to understand if we are using this module correctly. One aspect of our technical approach is odd. We use both I'm not proposing we pursue that now because I think this PR is a good step forward. But wanted to raise the option in case others wanted to chime in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good at a glance. I haven't run the library directly.
I'd say run both variants of the |
Also, sets contributors in package.json
Cool. Thanks for the feedback @monkbroc , I've pushed commits that address all of your comments/questions. @sergeuz I'm looking forward to your feedback as well. One thing I forgot to mention earlier was this snippet of code inside
|
3b423cc
to
0a47605
Compare
"scripts": { | ||
"build": "mkdirp dist && pbjs control/*.proto -t static-module -o dist/index.js --no-delimited --no-convert --no-verify", | ||
"docs": "jsdoc -X dist/index.js > dist/index-docs.json", | ||
"build": "npm run build:pbjs:module && npm run build:pbjs:json && npm run build:docs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great now!
…reate, encode, decode methods It used to only support a string; this simplifies upstream usage in particle-usb
Overview
Introduces main public API methods for this module:
encode(protobufMessageName, {data: "foo"})
decode(protobufMessageName, buffer)
getDefinition(protobufMessageName)
getDefinitions()
/getNamespaces()
Story details: https://app.shortcut.com/particle/story/95530
How to test?
git checkout sc-95530/introduce-getDefinition-function
npm i
npm run test:ci
; observe linter, tests, and coverage stats.docs/reference.md
; ask questions if anything isn't clear.