{"action":"created","issue":{"url":"https://api.github.com/repos/node-red/node-red-web-nodes/issues/226","repository_url":"https://api.github.com/repos/node-red/node-red-web-nodes","labels_url":"https://api.github.com/repos/node-red/node-red-web-nodes/issues/226/labels{/name}","comments_url":"https://api.github.com/repos/node-red/node-red-web-nodes/issues/226/comments","events_url":"https://api.github.com/repos/node-red/node-red-web-nodes/issues/226/events","html_url":"https://github.com/node-red/node-red-web-nodes/pull/226","id":349304392,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3NDU0NTk3","number":226,"title":"overhaul of Box node","user":{"login":"boneskull","id":924465,"node_id":"MDQ6VXNlcjkyNDQ2NQ==","avatar_url":"https://avatars3.githubusercontent.com/u/924465?v=4","gravatar_id":"","url":"https://api.github.com/users/boneskull","html_url":"https://github.com/boneskull","followers_url":"https://api.github.com/users/boneskull/followers","following_url":"https://api.github.com/users/boneskull/following{/other_user}","gists_url":"https://api.github.com/users/boneskull/gists{/gist_id}","starred_url":"https://api.github.com/users/boneskull/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boneskull/subscriptions","organizations_url":"https://api.github.com/users/boneskull/orgs","repos_url":"https://api.github.com/users/boneskull/repos","events_url":"https://api.github.com/users/boneskull/events{/privacy}","received_events_url":"https://api.github.com/users/boneskull/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-08-09T21:53:04Z","updated_at":"2018-09-13T22:32:24Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/node-red/node-red-web-nodes/pulls/226","html_url":"https://github.com/node-red/node-red-web-nodes/pull/226","diff_url":"https://github.com/node-red/node-red-web-nodes/pull/226.diff","patch_url":"https://github.com/node-red/node-red-web-nodes/pull/226.patch"},"body":"I mentioned this in Slack recently, but quick backstory:\r\n\r\nI 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:\r\n\r\n1.  The OAuth2 authentication was essentially broken; Node-RED would need near-constant contact with Box to keep tokens alive (this is still a problem, but is the nature of the beast)\r\n2.  There was no way to download arbitrary files\r\n3.  There was no way to update file information (this is *not* the same thing as \"metadata\" in Box parlance)\r\n\r\nThis PR addresses the issues by:\r\n\r\n1.  Implementing a second authentication method, OAuth2+JWT, which is recommended for server-to-server authentication.\r\n2.  Implementing a \"list folder\" Node, which returns an array of all files in a folder\r\n3.  Implementing a \"update file info\" Node, which allows properties (such as `tags`) to be assigned to a file\r\n\r\n(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.)\r\n\r\n**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.\r\n\r\n# Breaking Changes\r\n\r\n- Message input properties are now expected to be within the `payload`,\r\n  not hanging directly off of the message\r\n- Credential format has changed and is now stored (as received) verbatim\r\n  from the Box SDK\r\n- `box watch` (events) Node no longer holds opinions about what the\r\n  events look like--it no longer filters, modifies, or aggregates the\r\n  events and the event data--the event data format now mirrors the Box\r\n  API documentation (which means it's at least documented somewhere).\r\n  Note that the Enterprise Event Stream events *have a different format*\r\n  than the User Event Stream events!\r\n- Essentially, existing flows and configurations will break, and this\r\n  must be a major release.\r\n\r\n# Enhancements\r\n\r\n- Add OAuth2+JWT authentication mode for persistence\r\n- Add \"box folder items\" Node to list the contents of a folder; accepts\r\n  a folder ID, offset, and limit\r\n- Add \"box update file info\" Node to modify file information (e.g.,\r\n  tags)\r\n- Add support for \"download by file ID\" in `box in` (download) Node\r\n- Add support for file representations to `box in` Node; as appropriate,\r\n  any download can be \"downloaded as\" plain text, PDF, and various-sized\r\n  images\r\n- Add support for Enterprise Event Streams in `box watch` (event) Node\r\n- Add support for long-polling in User Event Streams in `box watch` Node\r\n- Add an output to `box out` (upload) Node\r\n- Add preflight checks to all uploads to avoid wasting time/bandwidth on\r\n  large, failed uploads in `box out` Node\r\n- Add automatic file creation and new version creation in `box out`\r\n  Node; if a file does not exist it will be created, otherwise a new\r\n  version will be created.\r\n- Add stub for developer token authentication mode\r\n\r\n# Refactors\r\n\r\n- consume [Box's Node SDK](https://www.npmjs.com/package/box-node-sdk)\r\n  directly\r\n- move much logic into `lib/box-api.js`, which is the configuration Node\r\n  itself; is now essentially an adapter for the Box Node SDK\r\n- create `TokenStore` class, corresponding to interface defined by the\r\n  Box Node SDK, to manage tokens for OAuth2 authentication--essentially\r\n  an adapter to Node-RED's credentials system\r\n- new palette and grid labels for various Nodes, since they were all\r\n  previously the same\r\n- split runtime `.js` files into one-per-Node; `box.js` now simply loads\r\n  all files in `lib/`\r\n- some ES2015+ enhancements\r\n- use Promises where possible\r\n- mixins provided for API functionality which changes depending on\r\n  authentication mode\r\n- some improvements to non-idiomatic JS\r\n- some docstring improvements\r\n- some locale string normalization\r\n\r\n# Fixes / Other\r\n\r\n- use canonical method to skip a suite in Box tests\r\n- remove unused `should-sinon` from `package.json`\r\n- update `package-lock.json`\r\n- rewrite most tests due to changes in authentication and HTTP requests\r\n  incurred by the use of the Box SDK; I would recommend actually testing\r\n  at a higher level and stubbing SDK methods to avoid worrying about\r\n  what the requests look like--we don't actually care, because that's\r\n  the Box SDK's problem!\r\n- add tests, though could use plenty more; the test helper isn't ready\r\n  yet, and unfortunately I don't have time to work on it\r\n- exempt `box/**/*.js` from JSHint checks, since I was fighting with it;\r\n  see #225"},"comment":{"url":"https://api.github.com/repos/node-red/node-red-web-nodes/issues/comments/421173596","html_url":"https://github.com/node-red/node-red-web-nodes/pull/226#issuecomment-421173596","issue_url":"https://api.github.com/repos/node-red/node-red-web-nodes/issues/226","id":421173596,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMTE3MzU5Ng==","user":{"login":"boneskull","id":924465,"node_id":"MDQ6VXNlcjkyNDQ2NQ==","avatar_url":"https://avatars3.githubusercontent.com/u/924465?v=4","gravatar_id":"","url":"https://api.github.com/users/boneskull","html_url":"https://github.com/boneskull","followers_url":"https://api.github.com/users/boneskull/followers","following_url":"https://api.github.com/users/boneskull/following{/other_user}","gists_url":"https://api.github.com/users/boneskull/gists{/gist_id}","starred_url":"https://api.github.com/users/boneskull/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boneskull/subscriptions","organizations_url":"https://api.github.com/users/boneskull/orgs","repos_url":"https://api.github.com/users/boneskull/repos","events_url":"https://api.github.com/users/boneskull/events{/privacy}","received_events_url":"https://api.github.com/users/boneskull/received_events","type":"User","site_admin":false},"created_at":"2018-09-13T22:32:24Z","updated_at":"2018-09-13T22:32:24Z","author_association":"NONE","body":"this was released in v1.21.0 of box-node-sdk; I've updated the version requirement."}}
{"actor":{"display_login":"boneskull"}}