@accede/node-red-contrib-odbcwritenow 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ ISC License
2
+
3
+ Copyright 2025 Accede Holdings PTY LTD
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # node-red-odbcwritenow
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.
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
9
+
10
+ ## Prerequisites
11
+ - Node-RED ≥ 4.x installed and running
12
+ - An active **ODBC WriteNow** account + API key
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ # install into your Node-RED user dir
18
+ cd ~/.node-red
19
+ npm install DarkAxi0m/node-red-odbcwritenow
20
+ ```
21
+
22
+ Restart Node-RED.
23
+
24
+ If you manage Node-RED as a service:
25
+ ```bash
26
+ sudo systemctl restart nodered
27
+ ```
28
+
29
+ ## Usage
30
+
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
37
+
38
+ Refer to the ODBC WriteNow developer docs for the exact routes and parameters.
39
+
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
+ ```
45
+
46
+ ## License
47
+ ISC © Accede Holdings PTY LTD. See `LICENSE`.
48
+
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/)
Binary file
@@ -0,0 +1,37 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('odbcwritenow-get',{
3
+ category: 'ODBCWriteNow',
4
+ color: '#2596be',
5
+ defaults: {
6
+ name: {value:""},
7
+ apikey: {value:""},
8
+ what: {value:""}
9
+ },
10
+ inputs: 1,
11
+ outputs: 2,
12
+ icon: "odbcwritenow.png",
13
+ label: function() {
14
+ return this.name||"Get " + this.what;
15
+ }
16
+ });
17
+ </script>
18
+
19
+ <script type="text/html" data-template-name="odbcwritenow-get">
20
+ <div class="form-row">
21
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
22
+ <input type="text" id="node-input-name" placeholder="Name">
23
+ </div>
24
+ <div class="form-row">
25
+ <label for="node-input-what"><i class="fa fa-lock"></i> What</label>
26
+ <input type="text" id="node-input-what" placeholder="sales_invoice_item">
27
+ </div>
28
+ <div class="form-row">
29
+ <label for="node-input-apikey"><i class="fa fa-lock"></i> APIKey</label>
30
+ <input type="text" id="node-input-apikey" placeholder="APIKey">
31
+ </div>
32
+ </script>
33
+
34
+ <script type="text/html" data-help-name="odbcwritenow-get">
35
+ <p>odbcwritenow downloader</p>
36
+ </script>
37
+
@@ -0,0 +1,81 @@
1
+ async function DoImport(msg, url, node) {
2
+ console.log('>', url)
3
+ msg.nodata = false
4
+ delete msg.complete
5
+ node.status({ fill: "blue", shape: "ring", text: `Fetching #${msg.page}: ${msg.what}` })
6
+ var datastr = ""
7
+ try {
8
+ const response = await fetch(url);
9
+
10
+ datastr = await response.text();
11
+ if (datastr.toLowerCase().includes("no data found")) {
12
+ msg.nodata = true
13
+ msg.complete = true
14
+ msg.payload = []
15
+ node.status({ fill: "green", shape: "ring", text: `#${msg.page}: No data found` })
16
+ return node.send([null, msg]);
17
+ }
18
+
19
+ //Errors and retrys etc
20
+ if (datastr.toLowerCase().includes("timeout")) {
21
+ node.status({ fill: "red", shape: "ring", text: `#${msg.page}: MYOB Gateway Timeout` })
22
+ console.error("******* MYOB Gateway Timeout", msg.retry, msg.page, url)
23
+ msg.retry = msg.retry + 1
24
+ return await DoImport(msg, url, node)
25
+ }
26
+ if (datastr.toLowerCase().includes("token error")) {
27
+ node.status({ fill: "red", shape: "ring", text: `#${msg.page}: MYOB Token Error` })
28
+ console.error("******* MYOB Token Error", msg.retry, msg.page, url)
29
+ msg.retry = msg.retry + 1
30
+ return await DoImport(msg, url, node)
31
+ }
32
+ //---------------------------------
33
+ //Everything looks good
34
+ const data = JSON.parse(datastr);
35
+ msg.rows = data.length
36
+ node.status({ fill: "green", shape: "dot", text: `#${msg.page}: ${msg.rows} Rows` })
37
+ msg.payload = data;
38
+ node.send([msg, null]);
39
+ } catch (error) {
40
+ node.status({ fill: "red", shape: "ring", text: error.message })
41
+ console.error(error.message)
42
+ console.log(datastr)
43
+ }
44
+
45
+ }
46
+
47
+
48
+ module.exports = function(RED) {
49
+ function ODBCWriteNowGet(config) {
50
+ RED.nodes.createNode(this, config);
51
+ var node = this;
52
+ node.status({ text: `` })
53
+ node.on('input', async function(msg) {
54
+ const page = parseInt(encodeURIComponent(msg.page || 0));
55
+ const apikey = encodeURIComponent(msg.apikey || config.apikey);
56
+ const what = encodeURIComponent(config.what)
57
+
58
+ msg.page = page
59
+ msg.what = what
60
+ msg.retry = 0
61
+
62
+ var filtersstr = "";
63
+ const filters = encodeURIComponent(msg.filters || "")
64
+ if (filters.length > 0) {
65
+ filtersstr += `&filters=${filters}`
66
+ }
67
+
68
+ const datefrom = encodeURIComponent(msg.datefrom || "")
69
+ if (datefrom.length > 0) {
70
+ filtersstr += `&datefrom=${datefrom}`
71
+ }
72
+
73
+ const url = `https://myobsync.accede.com.au/download/${what}/json/${page}?apikey=${apikey}${filtersstr}`;
74
+ DoImport(msg, url, node)
75
+
76
+ });
77
+ }
78
+ RED.nodes.registerType("odbcwritenow-get", ODBCWriteNowGet);
79
+
80
+ }
81
+
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@accede/node-red-contrib-odbcwritenow",
3
+ "version": "1.0.0",
4
+ "description": "Node-RED library for access in MYOB data via ODBCWriteNow",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "",
10
+ "license": "ISC",
11
+ "description": "",
12
+ "node-red": {
13
+ "version": ">=4.0.0",
14
+ "nodes": {
15
+ "odbcwritenow-get": "odbcwritenow.js"
16
+ }
17
+ },
18
+ "dependencies": {
19
+ "node-fetch": "^3.3.2"
20
+ }
21
+ }