-
Notifications
You must be signed in to change notification settings - Fork 159
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
overhaul of Box node #226
Open
boneskull
wants to merge
2
commits into
node-red:master
Choose a base branch
from
boneskull:box-jwt
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
overhaul of Box node #226
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Message input properties are now expected to be within the `payload`, not hanging directly off of the message - Credential format has changed and is now stored (as received) verbatim from the Box SDK - `box watch` (events) Node no longer holds opinions about what the events look like--it no longer filters, modifies, or aggregates the events and the event data--the event data format now mirrors the Box API documentation (which means it's at least documented somewhere). Note that the Enterprise Event Stream events *have a different format* than the User Event Stream events! - Essentially, existing flows and configurations will break, and this must be a major release. - Add OAuth2+JWT authentication mode for persistence - Add "box folder items" Node to list the contents of a folder; accepts a folder ID, offset, and limit - Add "box update file info" Node to modify file information (e.g., tags) - Add support for "download by file ID" in `box in` (download) Node - Add support for file representations to `box in` Node; as appropriate, any download can be "downloaded as" plain text, PDF, and various-sized images - Add support for Enterprise Event Streams in `box watch` (event) Node - Add support for long-polling in User Event Streams in `box watch` Node - Add an output to `box out` (upload) Node - Add preflight checks to all uploads to avoid wasting time/bandwidth on large, failed uploads in `box out` Node - Add automatic file creation and new version creation in `box out` Node; if a file does not exist it will be created, otherwise a new version will be created. - Add stub for developer token authentication mode - consume [Box's Node SDK](https://www.npmjs.com/package/box-node-sdk) directly - move much logic into `lib/box-api.js`, which is the configuration Node itself; is now essentially an adapter for the Box Node SDK - create `TokenStore` class, corresponding to interface defined by the Box Node SDK, to manage tokens for OAuth2 authentication--essentially an adapter to Node-RED's credentials system - new palette and grid labels for various Nodes, since they were all previously the same - split runtime `.js` files into one-per-Node; `box.js` now simply loads all files in `lib/` - some ES2015+ enhancements - use Promises where possible - mixins provided for API functionality which changes depending on authentication mode - some improvements to non-idiomatic JS - some docstring improvements - some locale string normalization - use canonical method to skip a suite in Box tests - remove unused `should-sinon` from `package.json` - update `package-lock.json` - rewrite most tests due to changes in authentication and HTTP requests incurred by the use of the Box SDK; I would recommend actually testing at a higher level and stubbing SDK methods to avoid worrying about what the requests look like--we don't actually care, because that's the Box SDK's problem! - add tests, though could use plenty more; the test helper isn't ready yet, and unfortunately I don't have time to work on it - exempt `box/**/*.js` from JSHint checks, since I was fighting with it; see node-red#225
The necessary PR in |
this was released in v1.21.0 of box-node-sdk; I've updated the version requirement. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I mentioned this in Slack recently, but quick backstory:
I was working on a talk showing how you can use Watson's NLU and Box in Node-RED to automatically tag documents based on their content. Unfortunately, I found the Box Node insufficient in three key areas:
This PR addresses the issues by:
tags
) to be assigned to a file(I have a demo of this, and there might even be a video of my talk available soon, but I think the audio is probably bad. 😬 I should probably just make a webcast.)
CAVEAT: I found a potential memory/resource leak in the Box SDK for Node.js which is corrected by in-progress PR box/box-node-sdk#304. Once that's merged and released, I'll update the dependency.
Breaking Changes
payload
,not hanging directly off of the message
from the Box SDK
box watch
(events) Node no longer holds opinions about what theevents look like--it no longer filters, modifies, or aggregates the
events and the event data--the event data format now mirrors the Box
API documentation (which means it's at least documented somewhere).
Note that the Enterprise Event Stream events have a different format
than the User Event Stream events!
must be a major release.
Enhancements
a folder ID, offset, and limit
tags)
box in
(download) Nodebox in
Node; as appropriate,any download can be "downloaded as" plain text, PDF, and various-sized
images
box watch
(event) Nodebox watch
Nodebox out
(upload) Nodelarge, failed uploads in
box out
Nodebox out
Node; if a file does not exist it will be created, otherwise a new
version will be created.
Refactors
directly
lib/box-api.js
, which is the configuration Nodeitself; is now essentially an adapter for the Box Node SDK
TokenStore
class, corresponding to interface defined by theBox Node SDK, to manage tokens for OAuth2 authentication--essentially
an adapter to Node-RED's credentials system
previously the same
.js
files into one-per-Node;box.js
now simply loadsall files in
lib/
authentication mode
Fixes / Other
should-sinon
frompackage.json
package-lock.json
incurred by the use of the Box SDK; I would recommend actually testing
at a higher level and stubbing SDK methods to avoid worrying about
what the requests look like--we don't actually care, because that's
the Box SDK's problem!
yet, and unfortunately I don't have time to work on it
box/**/*.js
from JSHint checks, since I was fighting with it;see jshint config isn't quite right #225