@accede/node-red-contrib-odbcwritenow 1.0.2 → 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 +65 -32
- package/odbcwritenow.html +6 -1
- package/odbcwritenow.js +12 -1
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -1,52 +1,85 @@
|
|
|
1
1
|
# node-red-odbcwritenow
|
|
2
2
|
|
|
3
|
-
Node-RED node for
|
|
3
|
+
Node-RED node for downloading MYOB data from ODBCWriteNow / MYOBSync.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
12
|
-
-
|
|
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
|
|
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
|
-
|
|
25
|
-
```bash
|
|
26
|
-
sudo systemctl restart nodered
|
|
27
|
-
```
|
|
36
|
+
## Node Configuration
|
|
28
37
|
|
|
29
|
-
|
|
38
|
+
Editor fields:
|
|
30
39
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
45
|
+
## Runtime Inputs (`msg`)
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
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.html
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
defaults: {
|
|
6
6
|
name: {value:""},
|
|
7
7
|
apikey: {value:""},
|
|
8
|
-
what: {value:""}
|
|
8
|
+
what: {value:""},
|
|
9
|
+
orderby: {value:""}
|
|
9
10
|
},
|
|
10
11
|
inputs: 1,
|
|
11
12
|
outputs: 2,
|
|
@@ -25,6 +26,10 @@
|
|
|
25
26
|
<label for="node-input-what"><i class="fa fa-lock"></i> What</label>
|
|
26
27
|
<input type="text" id="node-input-what" placeholder="sales_invoice_item">
|
|
27
28
|
</div>
|
|
29
|
+
<div class="form-row">
|
|
30
|
+
<label for="node-input-orderby"><i class="fa fa-lock"></i> OrderBy</label>
|
|
31
|
+
<input type="text" id="node-input-orderby" placeholder="OrderBy">
|
|
32
|
+
</div>
|
|
28
33
|
<div class="form-row">
|
|
29
34
|
<label for="node-input-apikey"><i class="fa fa-lock"></i> APIKey</label>
|
|
30
35
|
<input type="text" id="node-input-apikey" placeholder="APIKey">
|
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]);
|
|
@@ -54,11 +57,15 @@ module.exports = function(RED) {
|
|
|
54
57
|
const page = parseInt(encodeURIComponent(msg.page || 0));
|
|
55
58
|
const apikey = encodeURIComponent(msg.apikey || config.apikey);
|
|
56
59
|
const what = encodeURIComponent(config.what)
|
|
60
|
+
const orderby = encodeURIComponent(msg.orderby || config.orderby);
|
|
61
|
+
|
|
62
|
+
|
|
57
63
|
|
|
58
64
|
msg.page = page
|
|
59
65
|
msg.what = what
|
|
60
66
|
msg.retry = 0
|
|
61
67
|
|
|
68
|
+
var orderbystr = "";
|
|
62
69
|
var filtersstr = "";
|
|
63
70
|
const filters = encodeURIComponent(msg.filters || "")
|
|
64
71
|
if (filters.length > 0) {
|
|
@@ -75,7 +82,11 @@ module.exports = function(RED) {
|
|
|
75
82
|
filtersstr += `&dateto=${dateto}`
|
|
76
83
|
}
|
|
77
84
|
|
|
78
|
-
|
|
85
|
+
if (orderby.length > 0) {
|
|
86
|
+
orderbystr += `&orderby=${orderby}`
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const url = `https://myobsync.accede.com.au/download/${what}/json/${page}?apikey=${apikey}${filtersstr}${orderbystr}`;
|
|
79
90
|
DoImport(msg, url, node)
|
|
80
91
|
|
|
81
92
|
});
|
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@accede/node-red-contrib-odbcwritenow",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
8
|
},
|
|
9
9
|
"author": "",
|
|
10
10
|
"license": "ISC",
|
|
11
|
-
"description": "",
|
|
12
11
|
"node-red": {
|
|
13
|
-
|
|
12
|
+
"version": ">=4.0.0",
|
|
14
13
|
"nodes": {
|
|
15
14
|
"odbcwritenow-get": "odbcwritenow.js"
|
|
16
15
|
}
|