Update docs and add import logging

This commit is contained in:
2026-03-05 10:28:26 +10:30
parent 97d255a1d5
commit 3fe1433a5d
2 changed files with 68 additions and 32 deletions
+65 -32
View File
@@ -1,52 +1,85 @@
# node-red-odbcwritenow # node-red-odbcwritenow
Node-RED node for accessing MYOB data via **ODBCWriteNow**. Useful when you want AccountRight-style ODBC-style reads/writes in Node-RED without wrangling the raw HTTP yourself. Node-RED node for downloading MYOB data from ODBCWriteNow / MYOBSync.
## Features This package provides one node type: `odbcwritenow-get`.
- Node-RED palette node that talks to ODBC WriteNow
- Read/write operations against MYOB AccountRight via the ODBC WriteNow API ## What It Does
- Simple config for credentials and endpoint base URL
The node builds and calls:
```text
https://myobsync.accede.com.au/download/{what}/json/{page}?apikey={apikey}[&filters=...][&datefrom=...][&dateto=...][&orderby=...]
```
It then:
- sends parsed JSON rows to output 1
- sends "no data" completion messages to output 2
## Prerequisites ## Prerequisites
- Node-RED ≥ 4.x installed and running
- An active **ODBC WriteNow** account + API key - Node-RED `>= 4.0.0`
- Valid ODBCWriteNow / MYOBSync API key
## Install ## Install
Install in your Node-RED user directory:
```bash ```bash
# install into your Node-RED user dir
cd ~/.node-red cd ~/.node-red
npm install DarkAxi0m/node-red-odbcwritenow npm install @accede/node-red-contrib-odbcwritenow
``` ```
Restart Node-RED. Restart Node-RED after installation.
If you manage Node-RED as a service: ## Node Configuration
```bash
sudo systemctl restart nodered
```
## Usage Editor fields:
1. In the Node-RED editor, open the palette and drag **ODBC WriteNow** onto your flow. - `Name` (optional)
2. Double-click the node and set: - `What` (required): dataset/resource name, for example `sales_invoice_item`
- **Base URL**: your ODBC WriteNow endpoint (e.g. `https://myobsync.accede.com.au/`) - `OrderBy` (optional): default sort expression
- **API Key**: your issued key - `APIKey` (required unless provided in `msg.apikey`)
- **Operation/Path**: API route you need (e.g. download/upload endpoints per docs)
- **Params/Body**: any query/body fields required for your action
Refer to the ODBC WriteNow developer docs for the exact routes and parameters. ## Runtime Inputs (`msg`)
Example (generic pattern): You can override behavior per message:
```text
GET /api/download?table=Customers&updatedSince=2024-01-01 - `msg.page` (default `0`)
POST /api/upload (JSON body with rows) - `msg.apikey` (overrides configured API key)
``` - `msg.orderby` (overrides configured order by)
- `msg.filters`
- `msg.datefrom`
- `msg.dateto`
## Outputs
`odbcwritenow-get` has 2 outputs:
1. Data output
- `msg.payload`: parsed JSON array returned by the API
- `msg.rows`: number of rows in `payload`
- `msg.page`, `msg.what`, `msg.retry`
2. No-data output
- emitted when response contains `"no data found"`
- `msg.payload = []`
- `msg.nodata = true`
- `msg.complete = true`
## Status Behavior
- Blue ring: currently fetching
- Green dot: rows returned
- Green ring: no data found
- Red ring: timeout/token error retries or request/parsing error
## Notes
- Base URL is currently fixed to `https://myobsync.accede.com.au`.
- Timeout and token error responses are retried recursively.
## License ## License
ISC © Accede Holdings PTY LTD. See `LICENSE`.
## Links ISC. See [LICENSE](LICENSE).
- Repo: [DarkAxi0m/node-red-odbcwritenow](https://github.com/DarkAxi0m/node-red-odbcwritenow)
- [ODBC WriteNow Overview & pricing](https://odbcwritenow.com/)
- [ODBC WriteNow Developer docs](https://odbcwritenow.com/developers/)
+3
View File
@@ -9,6 +9,7 @@ async function DoImport(msg, url, node) {
datastr = await response.text(); datastr = await response.text();
if (datastr.toLowerCase().includes("no data found")) { if (datastr.toLowerCase().includes("no data found")) {
console.log("no data found");
msg.nodata = true msg.nodata = true
msg.complete = true msg.complete = true
msg.payload = [] msg.payload = []
@@ -33,6 +34,8 @@ async function DoImport(msg, url, node) {
//Everything looks good //Everything looks good
const data = JSON.parse(datastr); const data = JSON.parse(datastr);
msg.rows = data.length msg.rows = data.length
console.log("Page:", data.page, "Rows:", data.length)
node.status({ fill: "green", shape: "dot", text: `#${msg.page}: ${msg.rows} Rows` }) node.status({ fill: "green", shape: "dot", text: `#${msg.page}: ${msg.rows} Rows` })
msg.payload = data; msg.payload = data;
node.send([msg, null]); node.send([msg, null]);