@node-red/nodes 3.0.0-beta.3 → 3.0.0-beta.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/core/common/20-inject.html +1 -1
- package/core/common/21-debug.html +1 -1
- package/core/common/60-link.html +1 -1
- package/core/common/60-link.js +7 -10
- package/core/function/10-function.html +1 -1
- package/core/function/80-template.js +24 -0
- package/core/function/89-delay.js +13 -9
- package/core/parsers/70-CSV.js +5 -2
- package/core/sequence/17-split.js +4 -2
- package/examples/function/delay/06 - Simple Queue with release +149 -0
- package/locales/ja/function/10-function.html +1 -1
- package/locales/ja/messages.json +1 -0
- package/locales/ja/network/10-mqtt.html +1 -1
- package/package.json +2 -2
package/core/common/60-link.html
CHANGED
|
@@ -221,7 +221,7 @@
|
|
|
221
221
|
function onAdd() {
|
|
222
222
|
if (this.name === '_DEFAULT_') {
|
|
223
223
|
this.name = ''
|
|
224
|
-
RED.actions.invoke("core:generate-node-names", this)
|
|
224
|
+
RED.actions.invoke("core:generate-node-names", this, {generateHistory: false})
|
|
225
225
|
}
|
|
226
226
|
for (var i=0;i<this.links.length;i++) {
|
|
227
227
|
var n = RED.nodes.node(this.links[i]);
|
package/core/common/60-link.js
CHANGED
|
@@ -109,16 +109,13 @@ module.exports = function(RED) {
|
|
|
109
109
|
},
|
|
110
110
|
remove(node) {
|
|
111
111
|
const target = generateTarget(node);
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (targs.length === 0) {
|
|
120
|
-
delete registry.name[tn.name];
|
|
121
|
-
}
|
|
112
|
+
const targs = this.getTargets(target.name);
|
|
113
|
+
const idx = getIndex(targs, target.id);
|
|
114
|
+
if (idx > -1) {
|
|
115
|
+
targs.splice(idx, 1);
|
|
116
|
+
}
|
|
117
|
+
if (targs.length === 0) {
|
|
118
|
+
delete registry.name[tn.name];
|
|
122
119
|
}
|
|
123
120
|
delete registry.id[target.id];
|
|
124
121
|
},
|
|
@@ -44,6 +44,14 @@ module.exports = function(RED) {
|
|
|
44
44
|
return undefined;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
function parseEnv(key) {
|
|
48
|
+
var match = /^env\.(.+)/.exec(key);
|
|
49
|
+
if (match) {
|
|
50
|
+
return match[1];
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
47
55
|
/**
|
|
48
56
|
* Custom Mustache Context capable to collect message property and node
|
|
49
57
|
* flow and global context
|
|
@@ -74,6 +82,11 @@ module.exports = function(RED) {
|
|
|
74
82
|
return value;
|
|
75
83
|
}
|
|
76
84
|
|
|
85
|
+
// try env
|
|
86
|
+
if (parseEnv(name)) {
|
|
87
|
+
return this.cachedContextTokens[name];
|
|
88
|
+
}
|
|
89
|
+
|
|
77
90
|
// try flow/global context:
|
|
78
91
|
var context = parseContext(name);
|
|
79
92
|
if (context) {
|
|
@@ -156,6 +169,17 @@ module.exports = function(RED) {
|
|
|
156
169
|
var tokens = extractTokens(mustache.parse(template));
|
|
157
170
|
var resolvedTokens = {};
|
|
158
171
|
tokens.forEach(function(name) {
|
|
172
|
+
var env_name = parseEnv(name);
|
|
173
|
+
if (env_name) {
|
|
174
|
+
var promise = new Promise((resolve, reject) => {
|
|
175
|
+
var val = RED.util.evaluateNodeProperty(env_name, 'env', node)
|
|
176
|
+
resolvedTokens[name] = val;
|
|
177
|
+
resolve();
|
|
178
|
+
});
|
|
179
|
+
promises.push(promise);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
|
|
159
183
|
var context = parseContext(name);
|
|
160
184
|
if (context) {
|
|
161
185
|
var type = context.type;
|
|
@@ -275,18 +275,22 @@ module.exports = function(RED) {
|
|
|
275
275
|
if (msg.hasOwnProperty("flush")) {
|
|
276
276
|
var len = node.buffer.length;
|
|
277
277
|
if (typeof(msg.flush) == 'number') { len = Math.min(Math.floor(msg.flush),len); }
|
|
278
|
-
|
|
279
|
-
const msgInfo = node.buffer.shift();
|
|
280
|
-
if (Object.keys(msgInfo.msg).length > 1) {
|
|
281
|
-
node.send(msgInfo.msg);
|
|
282
|
-
msgInfo.done();
|
|
283
|
-
}
|
|
284
|
-
len = len - 1;
|
|
285
|
-
}
|
|
286
|
-
if (node.buffer.length === 0) {
|
|
278
|
+
if (len === 0) {
|
|
287
279
|
clearInterval(node.intervalID);
|
|
288
280
|
node.intervalID = -1;
|
|
289
281
|
}
|
|
282
|
+
else {
|
|
283
|
+
while (len > 0) {
|
|
284
|
+
const msgInfo = node.buffer.shift();
|
|
285
|
+
if (Object.keys(msgInfo.msg).length > 1) {
|
|
286
|
+
node.send(msgInfo.msg);
|
|
287
|
+
msgInfo.done();
|
|
288
|
+
}
|
|
289
|
+
len = len - 1;
|
|
290
|
+
}
|
|
291
|
+
clearInterval(node.intervalID);
|
|
292
|
+
node.intervalID = setInterval(sendMsgFromBuffer, node.rate);
|
|
293
|
+
}
|
|
290
294
|
node.status({fill:"blue",shape:"dot",text:node.buffer.length});
|
|
291
295
|
done();
|
|
292
296
|
}
|
package/core/parsers/70-CSV.js
CHANGED
|
@@ -89,6 +89,9 @@ module.exports = function(RED) {
|
|
|
89
89
|
else if (msg.payload[s][t].toString().indexOf(node.sep) !== -1) { // add quotes if any "commas"
|
|
90
90
|
msg.payload[s][t] = node.quo + msg.payload[s][t].toString() + node.quo;
|
|
91
91
|
}
|
|
92
|
+
else if (msg.payload[s][t].toString().indexOf("\n") !== -1) { // add quotes if any "\n"
|
|
93
|
+
msg.payload[s][t] = node.quo + msg.payload[s][t].toString() + node.quo;
|
|
94
|
+
}
|
|
92
95
|
}
|
|
93
96
|
ou += msg.payload[s].join(node.sep) + node.ret;
|
|
94
97
|
}
|
|
@@ -112,7 +115,7 @@ module.exports = function(RED) {
|
|
|
112
115
|
q = q.replace(/"/g, '""');
|
|
113
116
|
ou += node.quo + q + node.quo + node.sep;
|
|
114
117
|
}
|
|
115
|
-
else if (q.indexOf(node.sep) !== -1) { // add quotes if any "commas"
|
|
118
|
+
else if (q.indexOf(node.sep) !== -1 || p.indexOf("\n") !== -1) { // add quotes if any "commas" or "\n"
|
|
116
119
|
ou += node.quo + q + node.quo + node.sep;
|
|
117
120
|
}
|
|
118
121
|
else { ou += q + node.sep; } // otherwise just add
|
|
@@ -134,7 +137,7 @@ module.exports = function(RED) {
|
|
|
134
137
|
p = p.replace(/"/g, '""');
|
|
135
138
|
ou += node.quo + p + node.quo + node.sep;
|
|
136
139
|
}
|
|
137
|
-
else if (p.indexOf(node.sep) !== -1) { // add quotes if any "commas"
|
|
140
|
+
else if (p.indexOf(node.sep) !== -1 || p.indexOf("\n") !== -1) { // add quotes if any "commas" or "\n"
|
|
138
141
|
ou += node.quo + p + node.quo + node.sep;
|
|
139
142
|
}
|
|
140
143
|
else { ou += p + node.sep; } // otherwise just add
|
|
@@ -314,11 +314,13 @@ module.exports = function(RED) {
|
|
|
314
314
|
if (err) {
|
|
315
315
|
return done(err);
|
|
316
316
|
}
|
|
317
|
-
msgInfo.
|
|
317
|
+
msgInfo.msg.payload = result;
|
|
318
|
+
msgInfo.send(msgInfo.msg);
|
|
318
319
|
done();
|
|
319
320
|
});
|
|
320
321
|
} else {
|
|
321
|
-
msgInfo.
|
|
322
|
+
msgInfo.msg.payload = result;
|
|
323
|
+
msgInfo.send(msgInfo.msg);
|
|
322
324
|
done();
|
|
323
325
|
}
|
|
324
326
|
} else {
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "48d660b3a4109400",
|
|
4
|
+
"type": "inject",
|
|
5
|
+
"z": "9e5f48c16729e4f0",
|
|
6
|
+
"name": "inject",
|
|
7
|
+
"props": [
|
|
8
|
+
{
|
|
9
|
+
"p": "payload"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"repeat": "",
|
|
13
|
+
"crontab": "",
|
|
14
|
+
"once": false,
|
|
15
|
+
"onceDelay": 0.1,
|
|
16
|
+
"topic": "",
|
|
17
|
+
"payload": "",
|
|
18
|
+
"payloadType": "date",
|
|
19
|
+
"x": 185,
|
|
20
|
+
"y": 795,
|
|
21
|
+
"wires": [
|
|
22
|
+
[
|
|
23
|
+
"e0f9e206681f3504"
|
|
24
|
+
]
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"id": "e0f9e206681f3504",
|
|
29
|
+
"type": "delay",
|
|
30
|
+
"z": "9e5f48c16729e4f0",
|
|
31
|
+
"name": "",
|
|
32
|
+
"pauseType": "rate",
|
|
33
|
+
"timeout": "5",
|
|
34
|
+
"timeoutUnits": "seconds",
|
|
35
|
+
"rate": "1",
|
|
36
|
+
"nbRateUnits": "30",
|
|
37
|
+
"rateUnits": "second",
|
|
38
|
+
"randomFirst": "1",
|
|
39
|
+
"randomLast": "5",
|
|
40
|
+
"randomUnits": "seconds",
|
|
41
|
+
"drop": false,
|
|
42
|
+
"allowrate": false,
|
|
43
|
+
"outputs": 1,
|
|
44
|
+
"x": 430,
|
|
45
|
+
"y": 795,
|
|
46
|
+
"wires": [
|
|
47
|
+
[
|
|
48
|
+
"e470f1d794e1bef9",
|
|
49
|
+
"af7cea1dfb797a75"
|
|
50
|
+
]
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": "943543cf7a1958e4",
|
|
55
|
+
"type": "change",
|
|
56
|
+
"z": "9e5f48c16729e4f0",
|
|
57
|
+
"name": "set flush to 1",
|
|
58
|
+
"rules": [
|
|
59
|
+
{
|
|
60
|
+
"t": "set",
|
|
61
|
+
"p": "flush",
|
|
62
|
+
"pt": "msg",
|
|
63
|
+
"to": "1",
|
|
64
|
+
"tot": "num"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"t": "delete",
|
|
68
|
+
"p": "payload",
|
|
69
|
+
"pt": "msg"
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"action": "",
|
|
73
|
+
"property": "",
|
|
74
|
+
"from": "",
|
|
75
|
+
"to": "",
|
|
76
|
+
"reg": false,
|
|
77
|
+
"x": 510,
|
|
78
|
+
"y": 915,
|
|
79
|
+
"wires": [
|
|
80
|
+
[
|
|
81
|
+
"e0f9e206681f3504"
|
|
82
|
+
]
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"id": "e470f1d794e1bef9",
|
|
87
|
+
"type": "function",
|
|
88
|
+
"z": "9e5f48c16729e4f0",
|
|
89
|
+
"name": "Do something that takes a few seconds",
|
|
90
|
+
"func": "\n//send on the message between 3 and 6 seconds later\nsetTimeout(\n function() { \n node.send(msg) \n }, \n Math.random() * 3000 + 3000\n);\nreturn null;",
|
|
91
|
+
"outputs": 1,
|
|
92
|
+
"noerr": 0,
|
|
93
|
+
"initialize": "",
|
|
94
|
+
"finalize": "",
|
|
95
|
+
"libs": [],
|
|
96
|
+
"x": 760,
|
|
97
|
+
"y": 795,
|
|
98
|
+
"wires": [
|
|
99
|
+
[
|
|
100
|
+
"943543cf7a1958e4",
|
|
101
|
+
"859258551b8389b7"
|
|
102
|
+
]
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"id": "af7cea1dfb797a75",
|
|
107
|
+
"type": "debug",
|
|
108
|
+
"z": "9e5f48c16729e4f0",
|
|
109
|
+
"name": "IN",
|
|
110
|
+
"active": true,
|
|
111
|
+
"tosidebar": true,
|
|
112
|
+
"console": false,
|
|
113
|
+
"tostatus": false,
|
|
114
|
+
"complete": "payload",
|
|
115
|
+
"targetType": "msg",
|
|
116
|
+
"statusVal": "",
|
|
117
|
+
"statusType": "auto",
|
|
118
|
+
"x": 710,
|
|
119
|
+
"y": 735,
|
|
120
|
+
"wires": []
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"id": "859258551b8389b7",
|
|
124
|
+
"type": "debug",
|
|
125
|
+
"z": "9e5f48c16729e4f0",
|
|
126
|
+
"name": "OUT",
|
|
127
|
+
"active": true,
|
|
128
|
+
"tosidebar": true,
|
|
129
|
+
"console": false,
|
|
130
|
+
"tostatus": false,
|
|
131
|
+
"complete": "payload",
|
|
132
|
+
"targetType": "msg",
|
|
133
|
+
"statusVal": "",
|
|
134
|
+
"statusType": "auto",
|
|
135
|
+
"x": 895,
|
|
136
|
+
"y": 735,
|
|
137
|
+
"wires": []
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"id": "ecaaf26326da10ee",
|
|
141
|
+
"type": "comment",
|
|
142
|
+
"z": "9e5f48c16729e4f0",
|
|
143
|
+
"name": "Simple Queue with release",
|
|
144
|
+
"info": "This example shows how to use a delay node set to rate limit mode as a simple queue to feed a\nprocess that may take some time to complete. Once that process completes the feedback is then\nset to flush out the next message - thus running the \"loop\" as fast as possible with no overlaps.\n\n**Note**: only the `msg.flush` property msut be set - otherwise the other properties that are fed \nback will be added as another new message to the queue.",
|
|
145
|
+
"x": 235,
|
|
146
|
+
"y": 915,
|
|
147
|
+
"wires": []
|
|
148
|
+
}
|
|
149
|
+
]
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
<p>返却/sendの対象は次のとおりです:</p>
|
|
29
29
|
<ul>
|
|
30
30
|
<li>単一メッセージオブジェクト - 最初の出力に接続されたノードに渡されます</li>
|
|
31
|
-
<li>メッセージオブジェクトの配列 - 対応する出力に接続されたノードに渡されます</li>
|
|
31
|
+
<li>メッセージオブジェクトの配列 - 対応する出力に接続されたノードに渡されます</li>
|
|
32
32
|
</ul>
|
|
33
33
|
<p>注: 初期化処理の実行はノードの初期化中に行われます。そのため、初期化処理タブにsendを記述した場合に後続ノードでメッセージを受け取れないことがあります。</p>
|
|
34
34
|
<p>配列要素が配列の場合には、複数のメッセージを対応する出力に送出します。</p>
|
package/locales/ja/messages.json
CHANGED
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
<dt class="optional">userProperties <span class="property-type">オブジェクト</span></dt>
|
|
90
90
|
<dd><b>MQTTv5</b>: メッセージのユーザプロパティ</dd>
|
|
91
91
|
<dt class="optional">messageExpiryInterval <span class="property-type">数値</span></dt>
|
|
92
|
-
<dd><b>MQTTv5</b>: 秒単位のメッセージの有効期限</dd>
|
|
92
|
+
<dd><b>MQTTv5</b>: 秒単位のメッセージの有効期限</dd>
|
|
93
93
|
<dt class="optional">topicAlias <span class="property-type">数値</span></dt>
|
|
94
94
|
<dd><b>MQTTv5</b>: 使用するMQTTトピックエイリアス</dd>
|
|
95
95
|
</dl>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-red/nodes",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"denque": "2.0.1",
|
|
29
29
|
"form-data": "4.0.0",
|
|
30
30
|
"fs-extra": "10.1.0",
|
|
31
|
-
"got": "11.8.
|
|
31
|
+
"got": "11.8.5",
|
|
32
32
|
"hash-sum": "2.0.0",
|
|
33
33
|
"hpagent": "1.0.0",
|
|
34
34
|
"https-proxy-agent": "5.0.1",
|