Tags: tulip/node-red-tulip-api
Tags
Upgrade to version 0.3.0 (#10) Upgrade with features and bug fixes, and bumps the package to v0.3.0. New features: - Option for machine attribute node to submit dynamic or batched writes from input message. - Support for Tulip API requests using the Tulip nodes to use use a proxy (set by environment variable `http_proxy`) - Option to retain input message properties Fixes: - `tulip-tables` node default label is `tulip-tables` instead of `tulip-machine-attribute` - Wraps `tulip-tables` in IIFE to fix global variable scope - Encode `tulip-tables` API request path parameters
Remove request as a dependency Removes deprecated package `request` as a dependency. Refactors code to use `http`/`https` packages instead. Separates code to do an HTTP request into a common utils file. The other changes here are just formatting cleanup. # Test Plan Here's an example test flow that you should set up to point to a Tulip table and Tulip machine attribute on your factory instance, using an API bot with all permissions (or at least table read/write and machine attribute write). Specifically, you'll need to: - [ ] in your node-red installation (local, not Tulip edge device), add dependency to package.json: `"@tulip/node-red-tulip-api": "git+ssh://git@github.com:tulip/node-red-tulip-api.git#kathy.remove-request"` - [ ] rerun `npm install` - [ ] check in node-red palette that version of node-red-tulip-api is 0.2.1 - [ ] copy-paste the following flow into node-red - [ ] fill in the bot credentials for the API auth node (click into one of the tulip nodes, edit the existing api auth - it is shared between all the tulip nodes) - [ ] copy-paste the device/machine ids for an integer machine attribute - [ ] deploy flow - [ ] run the first inject; check that the timestamp shows up in factory under the designated machine attribute - [ ] run the second inject, should print 0 in debug console & a new table should show up on your factory instance ("my table") ``` [{"id":"60040c12.ce99b4","type":"tulip-machine-attribute","z":"c0f9d2ab.33f02","name":"tulip-machine-attribute","apiAuth":"825e6b19.72cb38","keepAlive":true,"keepAliveMsecs":10000,"deviceInfo":"{\"machineId\":\"xG9uMBp8yuDb3eGik\", \"attributeId\":\"wWhCvj6trj5WKxLZv\"}","payloadSource":"payload","payloadType":"msg","x":360,"y":80,"wires":[[]]},{"id":"c44104c8.8d51c8","type":"tulip-tables","z":"c0f9d2ab.33f02","name":"tulip-tables","apiAuth":"825e6b19.72cb38","keepAlive":true,"keepAliveMsecs":10000,"queryType":"1","tableId":"","queryId":"","aggregationId":"","recordId":"","fieldId":"","sortBy":"_sequenceNumber","sortByFieldId":"","sortDir":"asc","function":"sum","filterAggregator":"all","limit":10,"offset":0,"includeDeleted":false,"includeTotalCount":false,"allowRecordsInUse":false,"field":[],"filters":[],"sortOptions":[],"body":"{\"label\":\"my table\",\"description\":\"a table\",\"columns\":[{\"name\":\"a_column\",\"label\":\"a column\",\"description\":\"a column?\",\"dataType\":{\"type\":\"integer\"},\"hidden\":false,\"unique\":false}]}","x":350,"y":200,"wires":[["5924db0b.043834","e6dc3fe8.d8a2f"]]},{"id":"72eccfad.e03df","type":"inject","z":"c0f9d2ab.33f02","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":80,"wires":[["60040c12.ce99b4"]]},{"id":"5164a0c4.e4798","type":"inject","z":"c0f9d2ab.33f02","name":"Create table","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":200,"wires":[["c44104c8.8d51c8"]]},{"id":"5924db0b.043834","type":"debug","z":"c0f9d2ab.33f02","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":550,"y":160,"wires":[]},{"id":"e6dc3fe8.d8a2f","type":"change","z":"c0f9d2ab.33f02","name":"","rules":[{"t":"set","p":"tableId","pt":"msg","to":"payload.id","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":200,"wires":[["5696e130.71bbf"]]},{"id":"5696e130.71bbf","type":"tulip-tables","z":"c0f9d2ab.33f02","name":"tulip-tables","apiAuth":"825e6b19.72cb38","keepAlive":true,"keepAliveMsecs":10000,"queryType":"7","tableId":"","queryId":"","aggregationId":"","recordId":"","fieldId":"","sortBy":"_sequenceNumber","sortByFieldId":"","sortDir":"asc","function":"sum","filterAggregator":"all","limit":10,"offset":0,"includeDeleted":false,"includeTotalCount":false,"allowRecordsInUse":false,"field":[],"filters":[],"sortOptions":[],"body":"{}","x":750,"y":200,"wires":[["89792e96.95fdf"]]},{"id":"89792e96.95fdf","type":"debug","z":"c0f9d2ab.33f02","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":940,"y":200,"wires":[]},{"id":"825e6b19.72cb38","type":"tulip-api-auth","name":"tulip-api-auth","protocol":"https","hostname":"kathyc.tulip.co","port":""}] ```