@accede/node-red-contrib-odbcwritenow 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,52 +1,85 @@
1
1
  # node-red-odbcwritenow
2
2
 
3
- 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.
3
+ Node-RED node for downloading MYOB data from ODBCWriteNow / MYOBSync.
4
4
 
5
- ## Features
6
- - Node-RED palette node that talks to ODBC WriteNow
7
- - Read/write operations against MYOB AccountRight via the ODBC WriteNow API
8
- - Simple config for credentials and endpoint base URL
5
+ This package provides one node type: `odbcwritenow-get`.
6
+
7
+ ## What It Does
8
+
9
+ The node builds and calls:
10
+
11
+ ```text
12
+ https://myobsync.accede.com.au/download/{what}/json/{page}?apikey={apikey}[&filters=...][&datefrom=...][&dateto=...][&orderby=...]
13
+ ```
14
+
15
+ It then:
16
+
17
+ - sends parsed JSON rows to output 1
18
+ - sends "no data" completion messages to output 2
9
19
 
10
20
  ## Prerequisites
11
- - Node-RED ≥ 4.x installed and running
12
- - An active **ODBC WriteNow** account + API key
21
+
22
+ - Node-RED `>= 4.0.0`
23
+ - Valid ODBCWriteNow / MYOBSync API key
13
24
 
14
25
  ## Install
15
26
 
27
+ Install in your Node-RED user directory:
28
+
16
29
  ```bash
17
- # install into your Node-RED user dir
18
30
  cd ~/.node-red
19
- npm install DarkAxi0m/node-red-odbcwritenow
31
+ npm install @accede/node-red-contrib-odbcwritenow
20
32
  ```
21
33
 
22
- Restart Node-RED.
34
+ Restart Node-RED after installation.
23
35
 
24
- If you manage Node-RED as a service:
25
- ```bash
26
- sudo systemctl restart nodered
27
- ```
36
+ ## Node Configuration
28
37
 
29
- ## Usage
38
+ Editor fields:
30
39
 
31
- 1. In the Node-RED editor, open the palette and drag **ODBC WriteNow** onto your flow.
32
- 2. Double-click the node and set:
33
- - **Base URL**: your ODBC WriteNow endpoint (e.g. `https://myobsync.accede.com.au/`)
34
- - **API Key**: your issued key
35
- - **Operation/Path**: API route you need (e.g. download/upload endpoints per docs)
36
- - **Params/Body**: any query/body fields required for your action
40
+ - `Name` (optional)
41
+ - `What` (required): dataset/resource name, for example `sales_invoice_item`
42
+ - `OrderBy` (optional): default sort expression
43
+ - `APIKey` (required unless provided in `msg.apikey`)
37
44
 
38
- Refer to the ODBC WriteNow developer docs for the exact routes and parameters.
45
+ ## Runtime Inputs (`msg`)
39
46
 
40
- Example (generic pattern):
41
- ```text
42
- GET /api/download?table=Customers&updatedSince=2024-01-01
43
- POST /api/upload (JSON body with rows)
44
- ```
47
+ You can override behavior per message:
48
+
49
+ - `msg.page` (default `0`)
50
+ - `msg.apikey` (overrides configured API key)
51
+ - `msg.orderby` (overrides configured order by)
52
+ - `msg.filters`
53
+ - `msg.datefrom`
54
+ - `msg.dateto`
55
+
56
+ ## Outputs
57
+
58
+ `odbcwritenow-get` has 2 outputs:
59
+
60
+ 1. Data output
61
+ - `msg.payload`: parsed JSON array returned by the API
62
+ - `msg.rows`: number of rows in `payload`
63
+ - `msg.page`, `msg.what`, `msg.retry`
64
+
65
+ 2. No-data output
66
+ - emitted when response contains `"no data found"`
67
+ - `msg.payload = []`
68
+ - `msg.nodata = true`
69
+ - `msg.complete = true`
70
+
71
+ ## Status Behavior
72
+
73
+ - Blue ring: currently fetching
74
+ - Green dot: rows returned
75
+ - Green ring: no data found
76
+ - Red ring: timeout/token error retries or request/parsing error
77
+
78
+ ## Notes
79
+
80
+ - Base URL is currently fixed to `https://myobsync.accede.com.au`.
81
+ - Timeout and token error responses are retried recursively.
45
82
 
46
83
  ## License
47
- ISC © Accede Holdings PTY LTD. See `LICENSE`.
48
84
 
49
- ## Links
50
- - Repo: [DarkAxi0m/node-red-odbcwritenow](https://github.com/DarkAxi0m/node-red-odbcwritenow)
51
- - [ODBC WriteNow – Overview & pricing](https://odbcwritenow.com/)
52
- - [ODBC WriteNow – Developer docs](https://odbcwritenow.com/developers/)
85
+ ISC. See [LICENSE](LICENSE).
package/odbcwritenow.js CHANGED
@@ -9,6 +9,7 @@ async function DoImport(msg, url, node) {
9
9
 
10
10
  datastr = await response.text();
11
11
  if (datastr.toLowerCase().includes("no data found")) {
12
+ console.log("no data found");
12
13
  msg.nodata = true
13
14
  msg.complete = true
14
15
  msg.payload = []
@@ -33,6 +34,8 @@ async function DoImport(msg, url, node) {
33
34
  //Everything looks good
34
35
  const data = JSON.parse(datastr);
35
36
  msg.rows = data.length
37
+ console.log("Page:", data.page, "Rows:", data.length)
38
+
36
39
  node.status({ fill: "green", shape: "dot", text: `#${msg.page}: ${msg.rows} Rows` })
37
40
  msg.payload = data;
38
41
  node.send([msg, null]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@accede/node-red-contrib-odbcwritenow",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {