node-red-trexmes-commands 0.0.1
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 +674 -0
- package/README.md +25 -0
- package/package.json +30 -0
- package/src/icons/trex.png +0 -0
- package/src/locales/en-US/trexcommands.html +166 -0
- package/src/locales/en-US/trexcommands.json +58 -0
- package/src/trexcommands.html +388 -0
- package/src/trexcommands.js +417 -0
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# node-red-trexmes-commands
|
|
2
|
+
|
|
3
|
+
This is a [Node-Red][1] package that communicates with a [trex Mes][2] system
|
|
4
|
+
|
|
5
|
+
# Install
|
|
6
|
+
|
|
7
|
+
Run the following command in the root directory of your Node-RED install
|
|
8
|
+
|
|
9
|
+
npm install node-red-trexmes-commands
|
|
10
|
+
|
|
11
|
+
# Usage
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# Requirements
|
|
15
|
+
|
|
16
|
+
The package currently requires [Node.js 18.16][1] or higher.
|
|
17
|
+
|
|
18
|
+
# Authors
|
|
19
|
+
|
|
20
|
+
[Asaf Yurdakul][4]
|
|
21
|
+
|
|
22
|
+
[1]:http://nodered.org
|
|
23
|
+
[2]:https://mertyazilim.com.tr/
|
|
24
|
+
[4]:https://github.com/asafyurdakul
|
|
25
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "node-red-trexmes-commands",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A node-red node to execute commands for Trex Mes Systems",
|
|
5
|
+
"main": "trexcommands.js",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"mssql": "^10.0.0",
|
|
8
|
+
"mustache": "^4.2.0"
|
|
9
|
+
},
|
|
10
|
+
"node-red": {
|
|
11
|
+
"version": ">=2.0.0",
|
|
12
|
+
"nodes": {
|
|
13
|
+
"trexcommands": "src/trexcommands.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"src/"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"node-red",
|
|
21
|
+
"trex-mes",
|
|
22
|
+
"trex",
|
|
23
|
+
"mes"
|
|
24
|
+
],
|
|
25
|
+
"author": "asafyurdakul",
|
|
26
|
+
"license": "GPL-3.0-or-later",
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=16"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
<script type="text/html" data-help-name="trexMes-CN">
|
|
2
|
+
<p>Config node for Node-RED to trexMes Commands</p>
|
|
3
|
+
<h4>Connection setup</h4>
|
|
4
|
+
<p>
|
|
5
|
+
You can use environment variables in any connection field, using
|
|
6
|
+
<i><a href="http://mustache.github.io/mustache.5.html" target="_new">mustache</a></i>
|
|
7
|
+
format.
|
|
8
|
+
</p>
|
|
9
|
+
<p>
|
|
10
|
+
Example: <i>{{{environment variable name}}}</i>; or<br />
|
|
11
|
+
Server: MyAwesomeSQLServer-{{{ENV_NODE}}}.company.com
|
|
12
|
+
</p>
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
<script type="text/html" data-help-name="trexMes-CMD">
|
|
18
|
+
<p>Node for Node-RED to trexMes Commands</p>
|
|
19
|
+
|
|
20
|
+
<h3>Foreword</h3>
|
|
21
|
+
<dl class="message-properties">
|
|
22
|
+
Examples have been included to help you do some common tasks.
|
|
23
|
+
<a onclick="RED.actions.invoke('core:show-examples-import-dialog')" href="#">Click here</a> to import an example or press the hamburger menu <a class="button" href="#"><i class="fa fa-bars"></i></a> select <b>import</b> then <b>examples</b> or press <kbd>ctrl+i</kbd>
|
|
24
|
+
</dl>
|
|
25
|
+
|
|
26
|
+
<h3>Query Mode...</h3>
|
|
27
|
+
<div style="padding-left: 15px;">
|
|
28
|
+
<p>Select the execution mode, this can be "Query", "Stored procedure" or "Bulk Insert"</p>
|
|
29
|
+
<div class="form-tips" style="width: 100%">
|
|
30
|
+
TIP: Query mode can be set in the UI or dynamically via msg, flow, global or env. The value sent must be either "query", "execute" or "bulk"
|
|
31
|
+
</div>
|
|
32
|
+
<p>INFO: TVP variables are only supported in stored procedures. Some variable types are not supported by the underlying SQL driver.
|
|
33
|
+
</p>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<h3>Query...</h3>
|
|
37
|
+
<div style="padding-left: 15px;">
|
|
38
|
+
<p>Enter the query or stored procedure name to execute. It is possible to use <i><a href="http://mustache.github.io/mustache.5.html" target="_new">mustache</a></i> format to access properties of the msg, flow context and global context.</p>
|
|
39
|
+
<div class="form-tips" style="width: 100%">
|
|
40
|
+
TIP: Query can be set in the UI or dynamically via msg, flow, global or env. The value sent can also contain mustache items.
|
|
41
|
+
</div>
|
|
42
|
+
<br>
|
|
43
|
+
<p>Query Examples (with mustache and parameters)...
|
|
44
|
+
<ul>
|
|
45
|
+
<li><code style="white-space: normal;">SELECT TOP {{{flow.maxRows}}} * FROM [MyTable] WHERE Name = @name AND quantity >= {{{global.minQty}}}</code></li>
|
|
46
|
+
<li><code style="white-space: normal;">INSERT INTO [MyTable] (id, name, quantity) VALUES (@id, '{{{payload.name}}}', {{{payload.qty}}})</code></li>
|
|
47
|
+
<li><code style="white-space: normal;">UPDATE [MyTable] SET quantity = @quantity WHERE id = {{{payload.id}}}</code></li>
|
|
48
|
+
<li><code style="white-space: normal;">DELETE FROM [MyTable] WHERE id = @id</code></li>
|
|
49
|
+
</ul>
|
|
50
|
+
</p>
|
|
51
|
+
<div class="form-tips" style="width: 100%">Query mode tips...
|
|
52
|
+
<ul>
|
|
53
|
+
<li>To access <code>msg</code> properties, just use the variable name. e.g.
|
|
54
|
+
<code>SELECT top {{{payload}}} * from [MyTable]</code></li>
|
|
55
|
+
<li>To access <code>flow</code> and <code>global</code> properties,
|
|
56
|
+
specify them in the mustache e.g.
|
|
57
|
+
<code>SELECT {{{flow.name}}} FROM {{{global.table_name}}}</code></li>
|
|
58
|
+
<li>To prevent certain characters being escaped, use triple curly brackets. e.g.
|
|
59
|
+
<code>{{{flow.my_string}}}</code> </li>
|
|
60
|
+
</ul>
|
|
61
|
+
</div>
|
|
62
|
+
<div class="form-tips" style="width: 100%">Execute tips...
|
|
63
|
+
<ul>
|
|
64
|
+
<li>The query should be just the name of the stored procedure (don't include <code>exec</code>)</li>
|
|
65
|
+
<li>Parameters can be entered in the procedure query
|
|
66
|
+
(but are not necessary - just enter the matching parameter name in the <code>Parameters</code> list) </li>
|
|
67
|
+
</ul>
|
|
68
|
+
</div>
|
|
69
|
+
<div class="form-tips" style="width: 100%">Bulk Insert tips...
|
|
70
|
+
<ul>
|
|
71
|
+
<li>The query should be just the name table to bulk insert into</li>
|
|
72
|
+
<li>Data to bulk insert must be provided to the <code>Rows (bulk data)</code> field as either ...
|
|
73
|
+
<ul>
|
|
74
|
+
<li>an array of array rows e.g. <code>[ [col1_value, col2_value], [col1_value, col2_value] ]</code></li>
|
|
75
|
+
<li>an array of object rows e.g. <code>[ {col1:"value", col2:"value"}, {col1:"value", col2:"value"} ]</code></li>
|
|
76
|
+
</ul>
|
|
77
|
+
</li>
|
|
78
|
+
</ul>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
<br>
|
|
82
|
+
<p>INFO: When the 'Result type' is set to 'Driver output'...
|
|
83
|
+
<ul>
|
|
84
|
+
<li>Multiple results can be returned in the <code>recordsets</code> array if multiple queries are
|
|
85
|
+
executed.</li>
|
|
86
|
+
<li>It is recommended the user checks the value(s) in the <code>rowsAffected</code> property to confirm
|
|
87
|
+
operation - especially when performing INSERT, UPDATE and DELETE operations.</li>
|
|
88
|
+
</ul>
|
|
89
|
+
</p>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<h3>Parameters...</h3>
|
|
93
|
+
<div style="padding-left: 15px;">
|
|
94
|
+
<p>Input and Output Parameters can be specified for a query or procedure. In bulk mode, the parameters represent the columns of the table</p>
|
|
95
|
+
<div class="form-tips" style="width: 100%">
|
|
96
|
+
TIP: Query can be set in the UI or dynamically via msg, flow, global in the following format...<br>
|
|
97
|
+
<code><pre style="white-space: pre;">[
|
|
98
|
+
{
|
|
99
|
+
"output": false,
|
|
100
|
+
"name": "parameter name",
|
|
101
|
+
"type": "parameter type",
|
|
102
|
+
"value": "parameter value"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"output": true,
|
|
106
|
+
"name": "parameter name",
|
|
107
|
+
"type": "parameter type"
|
|
108
|
+
}
|
|
109
|
+
]</pre></code>
|
|
110
|
+
</div>
|
|
111
|
+
<br>
|
|
112
|
+
<p>Query Examples (with parameters)...
|
|
113
|
+
<div style="padding-left: 15px;">
|
|
114
|
+
<code style="font-weight: bold;">Query</code>
|
|
115
|
+
<div style="padding-left: 15px;">
|
|
116
|
+
<code style="white-space: normal;">SELECT TOP {{{payload.maxRows}}} * FROM [MyTable] WHERE Name = @name AND quantity >= @minQty</code>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
<div style="padding-left: 15px;">
|
|
120
|
+
<code style="font-weight: bold;">Parameters</code>
|
|
121
|
+
<ul>
|
|
122
|
+
<li>
|
|
123
|
+
<span>In/Out </span><code style="white-space: normal;">input</code>
|
|
124
|
+
<span>, Name </span><code style="white-space: normal;">name</code>
|
|
125
|
+
<span>, Type </span><code style="white-space: normal;">varchar(20)</code>
|
|
126
|
+
<span>, Value </span><code style="white-space: normal;">stephen</code>
|
|
127
|
+
</li>
|
|
128
|
+
<li>
|
|
129
|
+
<span>In/Out </span><code style="white-space: normal;">input</code>
|
|
130
|
+
<span>, Name </span><code style="white-space: normal;">minQty</code>
|
|
131
|
+
<span>, Type </span><code style="white-space: normal;">int</code>
|
|
132
|
+
<span>, Value </span><code style="white-space: normal;">5</code>
|
|
133
|
+
</li>
|
|
134
|
+
</ul>
|
|
135
|
+
</div>
|
|
136
|
+
</p>
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
<h3>Output options...</h3>
|
|
140
|
+
<div style="padding-left: 15px;">
|
|
141
|
+
<h4>Output property</h4>
|
|
142
|
+
<ul>
|
|
143
|
+
<li>The field to write the results to. Typically this is <code>msg.payload</code></li>
|
|
144
|
+
</ul>
|
|
145
|
+
<h4>Output type (not used for "Bulk Insert" mode)</h4>
|
|
146
|
+
<ul>
|
|
147
|
+
<li><b>Original output</b>: The property specified by 'Output property' will be populated with a single recordset (if
|
|
148
|
+
any). This is the same as earlier mssql-plus version - for compatibility</li>
|
|
149
|
+
<li><b>Driver output</b>: The property specified by 'Output property' will be populated with the result of the query
|
|
150
|
+
direct from the driver output. This format can return multiple recordsets and other information. Add a
|
|
151
|
+
debug node to see all available properties returned.</li>
|
|
152
|
+
</ul>
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
<h3>Error Handling...</h3>
|
|
156
|
+
<div style="padding-left: 15px;">
|
|
157
|
+
<ul>
|
|
158
|
+
<li><b>Send in msg.error</b>: Error will be written to <code>msg.error</code> and the msg will be sent in the
|
|
159
|
+
output. Users should check the output msg for presence of <code>msg.error</code> after each MSSQL node (same
|
|
160
|
+
functionality as previous version - for compatibility)</li>
|
|
161
|
+
<li><b>Throw error</b>: This will cause an error to be thrown instead of being sent in the output. Users can use the
|
|
162
|
+
<code>catch</code> node to detect and handle errors</li>
|
|
163
|
+
</ul>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
</script>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"trexMes-CMD": {
|
|
3
|
+
"common": {
|
|
4
|
+
"editor": "Editor",
|
|
5
|
+
"query": "Query",
|
|
6
|
+
"execute_procedure": "Execute Procedure"
|
|
7
|
+
},
|
|
8
|
+
"node": {
|
|
9
|
+
"label": {
|
|
10
|
+
"name": "Name",
|
|
11
|
+
"connection": "Connection",
|
|
12
|
+
"query_mode": "Operation mode",
|
|
13
|
+
"editor": "Expected Input Format",
|
|
14
|
+
"error_handling": "Error Handling",
|
|
15
|
+
"error_handling_send_in_msg": "Send in msg.error",
|
|
16
|
+
"error_handling_throw": "Throw error"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"connection": {
|
|
20
|
+
"label": {
|
|
21
|
+
"name": "Name",
|
|
22
|
+
"name_ph": "Connection Name",
|
|
23
|
+
"server": "Server",
|
|
24
|
+
"server_ph": "Server name or IP",
|
|
25
|
+
"port": "Port",
|
|
26
|
+
"username": "Username",
|
|
27
|
+
"password": "Password",
|
|
28
|
+
"domain": "Domain",
|
|
29
|
+
"database": "Database",
|
|
30
|
+
"companyId": "Company Id",
|
|
31
|
+
"userId": "User Id",
|
|
32
|
+
"tds": {
|
|
33
|
+
"title": "TDS Version",
|
|
34
|
+
"v7_4": "7_4 (SQL Server 2012 ~ 2022)",
|
|
35
|
+
"v7_3_b": "7_3_B (SQL Server 2008R2)",
|
|
36
|
+
"v7_3_a": "7_3_A (SQL Server 2008)",
|
|
37
|
+
"v7_2": "7_2 (SQL Server 2005)",
|
|
38
|
+
"v7_1": "7_1 (SQL Server 2000)"
|
|
39
|
+
},
|
|
40
|
+
"encryption": "Use Encryption?",
|
|
41
|
+
"encryption_tip": "SQL Databases hosted on Azure will need this checked.",
|
|
42
|
+
"utc": "Assume UTC?",
|
|
43
|
+
"utc_tip": "Pass time values in UTC or local time.",
|
|
44
|
+
"connect_timeout": "Connect Timeout",
|
|
45
|
+
"connect_timeout_tip": "The number of milliseconds before the attempt to connect is considered failed.",
|
|
46
|
+
"request_timeout": "Request Timeout",
|
|
47
|
+
"request_timeout_tip": "The number of milliseconds before a request is considered failed, or 0 for no timeout.",
|
|
48
|
+
"cancel_timeout": "Cancel Timeout",
|
|
49
|
+
"cancel_timeout_tip": "The number of milliseconds before the cancel (abort) of a request is considered failed.",
|
|
50
|
+
"max_pool_size": "Max Pool Size",
|
|
51
|
+
"parse_json": "JSON Support?",
|
|
52
|
+
"arith_abort": "ARITHABORT?",
|
|
53
|
+
"arith_abort_tooltip": "Ends a query when an overflow or divide-by-zero error occurs during query execution. Should normally be enabled.",
|
|
54
|
+
"read_only_intent": "ReadOnly Intent"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|