@jambonz/node-red-contrib-jambonz 2.4.30 → 2.4.31

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jambonz/node-red-contrib-jambonz",
3
- "version": "2.4.30",
3
+ "version": "2.4.31",
4
4
  "description": "Node-RED nodes for jambonz platform",
5
5
  "keywords": [
6
6
  "node-red"
@@ -74,7 +74,8 @@
74
74
  amd_timers_decisionTimeoutMs: {},
75
75
  amd_timers_greetingCompletionTimeoutMs:{},
76
76
  amd_timers_noSpeechTimeoutMs: {},
77
- amd_timers_toneTimeoutMs: {}
77
+ amd_timers_toneTimeoutMs: {},
78
+ amd_digitCount: {},
78
79
  },
79
80
  inputs:1,
80
81
  outputs:1,
@@ -690,6 +691,10 @@
690
691
  <label for="node-input-amd_thresholdWordCount">Threshold Word Count</label>
691
692
  <input type="text" id="node-input-amd_thresholdWordCount">
692
693
  </div>
694
+ <div class="form-row">
695
+ <label for="node-input-amd_digitCount">Digit Count</label>
696
+ <input type="text" id="node-input-amd_digitCount">
697
+ </div>
693
698
  <div class="form-row">
694
699
  <label for="node-input-amd_timers_decisionTimeoutMs">Decision Timeout</label>
695
700
  <input type="text" id="node-input-amd_timers_decisionTimeoutMs">
package/src/nodes/dial.js CHANGED
@@ -138,6 +138,7 @@ module.exports = function(RED) {
138
138
  data.amd = {}
139
139
  data.amd.actionHook = _amd_actionHook;
140
140
  config.amd_thresholdWordCount && (data.amd.thresholdWordCount = Number(config.amd_thresholdWordCount))
141
+ config.amd_digitCount && (data.amd.digitCount = Number(config.amd_digitCount))
141
142
  data.amd.timers = {
142
143
  ...(config.amd_timers_decisionTimeoutMs && {decisionTimeoutMs: Number(config.amd_timers_decisionTimeoutMs)}),
143
144
  ...(config.amd_timers_greetingCompletionTimeoutMs && {greetingCompletionTimeoutMs: Number(config.amd_timers_greetingCompletionTimeoutMs)}),
@@ -1,6 +1,14 @@
1
1
  <!-- Javascript -->
2
2
  <script type="text/javascript">
3
-
3
+
4
+ function formatjson(e) {
5
+ e.preventDefault();
6
+ e = s.getValue() || "";
7
+ try {
8
+ e = JSON.stringify(JSON.parse(e), null, 4)
9
+ } catch (e) {}
10
+ s.getSession().setValue(e || "", -1)
11
+ }
4
12
 
5
13
  RED.nodes.registerType('generic',{
6
14
  category: 'jambonz',
@@ -8,20 +16,32 @@
8
16
  defaults: {
9
17
  name: {value: ''},
10
18
  verb: {required: true},
11
- data: {value: '{}'},
12
- dataType: {value: 'json'},
19
+ data: { value: '',
20
+ validate: function(v) {
21
+ return (typeof(JSON.parse(v)) == 'object')
22
+ }
23
+ },
13
24
  },
14
25
  inputs:1,
15
26
  outputs:1,
16
27
  icon: "font-awesome/fa-cubes",
17
28
  label: function() { return this.name || 'generic';},
18
29
  oneditprepare: function() {
19
- $('#node-input-data').typedInput({
20
- default: $('#node-input-dataType').val(),
21
- types: ['json','msg', 'flow', 'global', 'jsonata', 'env'],
22
- typeField: $('#node-input-dataType')
23
- });
24
- }
30
+ this.editor = RED.editor.createEditor({
31
+ id: 'node-input-data-editor',
32
+ mode: 'ace/mode/json',
33
+ value: this.data
34
+ });
35
+ },
36
+ oneditsave: function() {
37
+ this.data = this.editor.getValue();
38
+ this.editor.destroy();
39
+ delete this.editor;
40
+ },
41
+ oneditcancel: function() {
42
+ this.editor.destroy();
43
+ delete this.editor;
44
+ }
25
45
  });
26
46
  </script>
27
47
 
@@ -35,11 +55,12 @@
35
55
  <label for="node-input-verb">Verb</label>
36
56
  <input type="text" id="node-input-verb" placeholder="verb">
37
57
  </div>
38
- <div class="form-row">
39
- <label for="node-input-data">Attributes</label>
40
- <input type="text" id="node-input-data">
41
- <input type="hidden" id="node-input-dataType">
42
- </div>
58
+ <div class="form-row" style="position: relative; height: 250px;">
59
+ <label for="node-input-data"><i class="fa fa-code"></i> Attributes</label>
60
+ <div style="position: absolute; right: 0; bottom: 0; top: 0; left: 100px;">
61
+ <div id="node-input-data-editor" style="width: 100%; height: 100%;"></div>
62
+ </div>
63
+ </div>
43
64
  </script>
44
65
 
45
66
  <!-- Help Text -->
@@ -1,4 +1,5 @@
1
1
  var {appendVerb, new_resolve} = require('./libs')
2
+ const assert = require('node:assert/strict');
2
3
 
3
4
  module.exports = function(RED) {
4
5
  function generic(config) {
@@ -6,12 +7,21 @@ module.exports = function(RED) {
6
7
  var node = this;
7
8
  node.verb = config.verb
8
9
  node.on('input', async function(msg) {
9
- let data = await new_resolve(RED, config.data, config.dataType, node, msg);
10
- appendVerb(msg, {
11
- ...{verb: node.verb},
12
- ...data
13
- });
14
- node.send(msg);
10
+ if (config.data.length==0) config.data='{}';
11
+ const _data = await new_resolve(RED, config.data, 'mustache', node, msg);
12
+ try {
13
+ const data = JSON.parse(_data)
14
+ assert.ok(typeof(data)=='object')
15
+ appendVerb(msg, {
16
+ ...{verb: node.verb},
17
+ ...data
18
+ });
19
+ node.send(msg);
20
+ } catch (error) {
21
+ console.error(error)
22
+ node.error(`Invalid Attributes object: ${_data}`)
23
+ }
24
+
15
25
  });
16
26
  }
17
27
  RED.nodes.registerType('generic', generic);
@@ -508,7 +508,7 @@
508
508
  <div class="form-row">
509
509
  <label for="node-input-dubSay">Say Text</label>
510
510
  <input type="text" id="node-input-dubSay" placeholder="Text">
511
- <input type="hidden" id="node-input-tagType">
511
+ <input type="hidden" id="node-input-dubSayType">
512
512
  </div>
513
513
  <div class="form-row">
514
514
  <label for="node-input-dubLoop">Loop</label>