@theotherwillembotha/node-red-plugincore 0.0.50

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.
Files changed (180) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +190 -0
  3. package/build/GenerateNodes.d.ts +2 -0
  4. package/build/GenerateNodes.d.ts.map +1 -0
  5. package/build/GenerateNodes.js +36 -0
  6. package/build/Nodes.html +1729 -0
  7. package/build/Nodes.js +32 -0
  8. package/build/Plugins.js +74 -0
  9. package/build/core/NodeConstructor.d.ts +188 -0
  10. package/build/core/NodeConstructor.d.ts.map +1 -0
  11. package/build/core/NodeConstructor.js +679 -0
  12. package/build/core/NodeGenerator.d.ts +37 -0
  13. package/build/core/NodeGenerator.d.ts.map +1 -0
  14. package/build/core/NodeGenerator.js +300 -0
  15. package/build/core/Utils.d.ts +7 -0
  16. package/build/core/Utils.d.ts.map +1 -0
  17. package/build/core/Utils.js +19 -0
  18. package/build/core/logger/LoggerDecorator.d.ts +2 -0
  19. package/build/core/logger/LoggerDecorator.d.ts.map +1 -0
  20. package/build/core/logger/LoggerDecorator.js +93 -0
  21. package/build/core/logger/node/ConsoleLoggerConfigNode.d.ts +16 -0
  22. package/build/core/logger/node/ConsoleLoggerConfigNode.d.ts.map +1 -0
  23. package/build/core/logger/node/ConsoleLoggerConfigNode.html +131 -0
  24. package/build/core/logger/node/ConsoleLoggerConfigNode.js +47 -0
  25. package/build/core/logger/node/LoggerConfigNode.d.ts +30 -0
  26. package/build/core/logger/node/LoggerConfigNode.d.ts.map +1 -0
  27. package/build/core/logger/node/LoggerConfigNode.html +307 -0
  28. package/build/core/logger/node/LoggerConfigNode.js +60 -0
  29. package/build/core/logger/node/LokiLoggerConfigNode.d.ts +20 -0
  30. package/build/core/logger/node/LokiLoggerConfigNode.d.ts.map +1 -0
  31. package/build/core/logger/node/LokiLoggerConfigNode.html +153 -0
  32. package/build/core/logger/node/LokiLoggerConfigNode.js +52 -0
  33. package/build/core/logger/node/RestLoggerConfigNode.d.ts +24 -0
  34. package/build/core/logger/node/RestLoggerConfigNode.d.ts.map +1 -0
  35. package/build/core/logger/node/RestLoggerConfigNode.html +209 -0
  36. package/build/core/logger/node/RestLoggerConfigNode.js +57 -0
  37. package/build/core/logger/service/LoggerService.d.ts +88 -0
  38. package/build/core/logger/service/LoggerService.d.ts.map +1 -0
  39. package/build/core/logger/service/LoggerService.js +204 -0
  40. package/build/core/logger/service/LoggerServiceTypes.d.ts +24 -0
  41. package/build/core/logger/service/LoggerServiceTypes.d.ts.map +1 -0
  42. package/build/core/logger/service/LoggerServiceTypes.js +30 -0
  43. package/build/core/logger/template/LoggerTemplate.d.ts +11 -0
  44. package/build/core/logger/template/LoggerTemplate.d.ts.map +1 -0
  45. package/build/core/logger/template/LoggerTemplate.html +328 -0
  46. package/build/core/logger/template/LoggerTemplate.js +12 -0
  47. package/build/core/metrics/MetricsDecorator.d.ts +40 -0
  48. package/build/core/metrics/MetricsDecorator.d.ts.map +1 -0
  49. package/build/core/metrics/MetricsDecorator.js +166 -0
  50. package/build/core/metrics/node/CounterMetricConfigNode.d.ts +16 -0
  51. package/build/core/metrics/node/CounterMetricConfigNode.d.ts.map +1 -0
  52. package/build/core/metrics/node/CounterMetricConfigNode.html +48 -0
  53. package/build/core/metrics/node/CounterMetricConfigNode.js +61 -0
  54. package/build/core/metrics/node/GaugeMetricConfigNode.d.ts +17 -0
  55. package/build/core/metrics/node/GaugeMetricConfigNode.d.ts.map +1 -0
  56. package/build/core/metrics/node/GaugeMetricConfigNode.html +48 -0
  57. package/build/core/metrics/node/GaugeMetricConfigNode.js +61 -0
  58. package/build/core/metrics/node/MetricsConfigNode.d.ts +14 -0
  59. package/build/core/metrics/node/MetricsConfigNode.d.ts.map +1 -0
  60. package/build/core/metrics/node/MetricsConfigNode.html +21 -0
  61. package/build/core/metrics/node/MetricsConfigNode.js +56 -0
  62. package/build/core/metrics/node/TimerMetricConfigNode.d.ts +28 -0
  63. package/build/core/metrics/node/TimerMetricConfigNode.d.ts.map +1 -0
  64. package/build/core/metrics/node/TimerMetricConfigNode.html +190 -0
  65. package/build/core/metrics/node/TimerMetricConfigNode.js +101 -0
  66. package/build/core/metrics/service/MetricsService.d.ts +187 -0
  67. package/build/core/metrics/service/MetricsService.d.ts.map +1 -0
  68. package/build/core/metrics/service/MetricsService.js +385 -0
  69. package/build/core/metrics/template/CounterMetricTemplate.d.ts +5 -0
  70. package/build/core/metrics/template/CounterMetricTemplate.d.ts.map +1 -0
  71. package/build/core/metrics/template/CounterMetricTemplate.html +40 -0
  72. package/build/core/metrics/template/CounterMetricTemplate.js +12 -0
  73. package/build/core/metrics/template/GaugeMetricTemplate.d.ts +5 -0
  74. package/build/core/metrics/template/GaugeMetricTemplate.d.ts.map +1 -0
  75. package/build/core/metrics/template/GaugeMetricTemplate.html +39 -0
  76. package/build/core/metrics/template/GaugeMetricTemplate.js +12 -0
  77. package/build/core/metrics/template/MetricsTemplate.d.ts +8 -0
  78. package/build/core/metrics/template/MetricsTemplate.d.ts.map +1 -0
  79. package/build/core/metrics/template/MetricsTemplate.html +54 -0
  80. package/build/core/metrics/template/MetricsTemplate.js +12 -0
  81. package/build/core/metrics/template/TimerMetricTemplate.d.ts +5 -0
  82. package/build/core/metrics/template/TimerMetricTemplate.d.ts.map +1 -0
  83. package/build/core/metrics/template/TimerMetricTemplate.html +39 -0
  84. package/build/core/metrics/template/TimerMetricTemplate.js +12 -0
  85. package/build/core/other/InputDecorator.d.ts +3 -0
  86. package/build/core/other/InputDecorator.d.ts.map +1 -0
  87. package/build/core/other/InputDecorator.js +43 -0
  88. package/build/core/other/service/InputService.d.ts +16 -0
  89. package/build/core/other/service/InputService.d.ts.map +1 -0
  90. package/build/core/other/service/InputService.js +31 -0
  91. package/build/core/other/service/SettingsService.d.ts +25 -0
  92. package/build/core/other/service/SettingsService.d.ts.map +1 -0
  93. package/build/core/other/service/SettingsService.js +74 -0
  94. package/build/core/other/template/BasicTemplate.d.ts +5 -0
  95. package/build/core/other/template/BasicTemplate.d.ts.map +1 -0
  96. package/build/core/other/template/BasicTemplate.html +76 -0
  97. package/build/core/other/template/BasicTemplate.js +11 -0
  98. package/build/core/other/template/SettingsTemplate.d.ts +5 -0
  99. package/build/core/other/template/SettingsTemplate.d.ts.map +1 -0
  100. package/build/core/other/template/SettingsTemplate.html +128 -0
  101. package/build/core/other/template/SettingsTemplate.js +11 -0
  102. package/build/core/tagging/NodeDescriptionDecorator.d.ts +17 -0
  103. package/build/core/tagging/NodeDescriptionDecorator.d.ts.map +1 -0
  104. package/build/core/tagging/NodeDescriptionDecorator.js +25 -0
  105. package/build/core/tagging/service/NodeTypeService.d.ts +15 -0
  106. package/build/core/tagging/service/NodeTypeService.d.ts.map +1 -0
  107. package/build/core/tagging/service/NodeTypeService.js +47 -0
  108. package/build/core/webhook/WebhookDecorator.d.ts +3 -0
  109. package/build/core/webhook/WebhookDecorator.d.ts.map +1 -0
  110. package/build/core/webhook/WebhookDecorator.js +45 -0
  111. package/build/core/webhook/node/WebhookServerConfigNode.d.ts +16 -0
  112. package/build/core/webhook/node/WebhookServerConfigNode.d.ts.map +1 -0
  113. package/build/core/webhook/node/WebhookServerConfigNode.html +61 -0
  114. package/build/core/webhook/node/WebhookServerConfigNode.js +40 -0
  115. package/build/core/webhook/service/ReverseProxyTypeService.d.ts +29 -0
  116. package/build/core/webhook/service/ReverseProxyTypeService.d.ts.map +1 -0
  117. package/build/core/webhook/service/ReverseProxyTypeService.js +24 -0
  118. package/build/core/webhook/service/WebhookServerService.d.ts +52 -0
  119. package/build/core/webhook/service/WebhookServerService.d.ts.map +1 -0
  120. package/build/core/webhook/service/WebhookServerService.js +146 -0
  121. package/build/core/webhook/template/WebhookTemplate.d.ts +22 -0
  122. package/build/core/webhook/template/WebhookTemplate.d.ts.map +1 -0
  123. package/build/core/webhook/template/WebhookTemplate.html +434 -0
  124. package/build/core/webhook/template/WebhookTemplate.js +12 -0
  125. package/build/index.d.ts +33 -0
  126. package/build/index.d.ts.map +1 -0
  127. package/build/index.js +55 -0
  128. package/package.json +67 -0
  129. package/src/GenerateNodes.ts +42 -0
  130. package/src/core/NodeConstructor.ts +889 -0
  131. package/src/core/NodeGenerator.ts +331 -0
  132. package/src/core/Utils.ts +19 -0
  133. package/src/core/logger/LoggerDecorator.ts +105 -0
  134. package/src/core/logger/node/ConsoleLoggerConfigNode.html +131 -0
  135. package/src/core/logger/node/ConsoleLoggerConfigNode.ts +46 -0
  136. package/src/core/logger/node/LoggerConfigNode.html +307 -0
  137. package/src/core/logger/node/LoggerConfigNode.ts +95 -0
  138. package/src/core/logger/node/LokiLoggerConfigNode.html +153 -0
  139. package/src/core/logger/node/LokiLoggerConfigNode.ts +58 -0
  140. package/src/core/logger/node/RestLoggerConfigNode.html +209 -0
  141. package/src/core/logger/node/RestLoggerConfigNode.ts +67 -0
  142. package/src/core/logger/service/LoggerService.ts +317 -0
  143. package/src/core/logger/service/LoggerServiceTypes.ts +26 -0
  144. package/src/core/logger/template/LoggerTemplate.html +328 -0
  145. package/src/core/logger/template/LoggerTemplate.ts +23 -0
  146. package/src/core/metrics/MetricsDecorator.ts +227 -0
  147. package/src/core/metrics/node/CounterMetricConfigNode.html +48 -0
  148. package/src/core/metrics/node/CounterMetricConfigNode.ts +62 -0
  149. package/src/core/metrics/node/GaugeMetricConfigNode.html +48 -0
  150. package/src/core/metrics/node/GaugeMetricConfigNode.ts +62 -0
  151. package/src/core/metrics/node/MetricsConfigNode.html +21 -0
  152. package/src/core/metrics/node/MetricsConfigNode.ts +55 -0
  153. package/src/core/metrics/node/TimerMetricConfigNode.html +190 -0
  154. package/src/core/metrics/node/TimerMetricConfigNode.ts +118 -0
  155. package/src/core/metrics/service/MetricsService.ts +560 -0
  156. package/src/core/metrics/template/CounterMetricTemplate.html +40 -0
  157. package/src/core/metrics/template/CounterMetricTemplate.ts +15 -0
  158. package/src/core/metrics/template/GaugeMetricTemplate.html +39 -0
  159. package/src/core/metrics/template/GaugeMetricTemplate.ts +15 -0
  160. package/src/core/metrics/template/MetricsTemplate.html +54 -0
  161. package/src/core/metrics/template/MetricsTemplate.ts +18 -0
  162. package/src/core/metrics/template/TimerMetricTemplate.html +39 -0
  163. package/src/core/metrics/template/TimerMetricTemplate.ts +14 -0
  164. package/src/core/other/InputDecorator.ts +57 -0
  165. package/src/core/other/service/InputService.ts +36 -0
  166. package/src/core/other/service/SettingsService.ts +103 -0
  167. package/src/core/other/template/BasicTemplate.html +76 -0
  168. package/src/core/other/template/BasicTemplate.ts +15 -0
  169. package/src/core/other/template/SettingsTemplate.html +128 -0
  170. package/src/core/other/template/SettingsTemplate.ts +17 -0
  171. package/src/core/tagging/NodeDescriptionDecorator.ts +39 -0
  172. package/src/core/tagging/service/NodeTypeService.ts +67 -0
  173. package/src/core/webhook/WebhookDecorator.ts +70 -0
  174. package/src/core/webhook/node/WebhookServerConfigNode.html +61 -0
  175. package/src/core/webhook/node/WebhookServerConfigNode.ts +38 -0
  176. package/src/core/webhook/service/ReverseProxyTypeService.ts +46 -0
  177. package/src/core/webhook/service/WebhookServerService.ts +211 -0
  178. package/src/core/webhook/template/WebhookTemplate.html +434 -0
  179. package/src/core/webhook/template/WebhookTemplate.ts +36 -0
  180. package/src/index.ts +47 -0
@@ -0,0 +1,307 @@
1
+
2
+ <script type="text/javascript" template-section="onCompose">
3
+ node
4
+ .addDefault("name", {value:"Logger Example", required:true})
5
+ .addDefault("platform", {value:"rest", required:true})
6
+ .addDefault("template", {value:`message:{{msg}}`, required:true})
7
+ .addDefault("level", {value:"info", required:true})
8
+
9
+ // platform rest:
10
+ .addDefault("platform_rest_url", {})
11
+ .addDefault("platform_rest_ignoresslerror", {})
12
+ .addDefault("platform_rest_auth_type", {})
13
+ .addDefault("platform_rest_auth_basic_username", {})
14
+ .addDefault("platform_rest_auth_basic_password", {})
15
+ .addDefault("platform_rest_auth_apikey_mechanism", {})
16
+ .addDefault("platform_rest_auth_apikey_name", {})
17
+ .addDefault("platform_rest_auth_apikey_value", {})
18
+
19
+ // platform loki:
20
+ .addDefault("platform_loki_host", {})
21
+ .addDefault("platform_loki_tenantID", {})
22
+ .addDefault("platform_loki_userid", {})
23
+ .addDefault("platform_loki_authtoken", {})
24
+
25
+ .setPaletteLabel("Logger Config Node")
26
+ .setLabel(function() {return this.name })
27
+
28
+ </script>
29
+
30
+ <script type="text/javascript" template-section="onIncludeEditPrepare">
31
+ {
32
+ let node = this;
33
+
34
+ let showSelectedPlatform = (value) => {
35
+ let loggerConfig = $("#LoggerConfig");
36
+ loggerConfig.find(".platform").each((i, t) => {
37
+ t = $(t);
38
+ if(t.hasClass(`platform-${value}`)){ t.show(); }
39
+ else { t.hide(); }
40
+ });
41
+
42
+ $("#LoggerConfig").find(`.platform-${value}`).find(`.platform-${value}-input.required`).each((i, entry) => {
43
+ let id = entry.id.replace("node-config-input-", "");
44
+ if(node._def.defaults[id]){
45
+ node._def.defaults[id].required = true;
46
+ }
47
+ else{
48
+ console.log(`you forgot to define ${id} in the defaults for LoggerConfigNode`);
49
+ }
50
+ });
51
+
52
+ Object.entries(node._def.defaults)
53
+ .filter(([k, v]) => k.startsWith(`platform_`))
54
+ .filter(([k, v]) => !k.startsWith(`platform_${value}_`))
55
+ .forEach(([k, v]) => v.required = false );
56
+
57
+ node.platform = value;
58
+ }
59
+
60
+ let showSelectedRestAuthMethod = (value) => {
61
+ $("#LoggerConfig")
62
+ .find(".platform.platform-rest").first()
63
+ .find(".platform-rest-auth")
64
+ .each((i, t) => {
65
+ t = $(t);
66
+ if(t.hasClass(`auth-${value}`)){ t.show(); }
67
+ else { t.hide(); }
68
+ });
69
+ }
70
+
71
+ let levelSelection = $("#node-config-input-level");
72
+ levelSelection.typedInput({type:"level", types:[{
73
+ value: "level",
74
+ options: [
75
+ { value: "DEBUG", label: "debug"},
76
+ { value: "INFO", label: "info"},
77
+ { value: "WARNING", label: "warning"},
78
+ { value: "ERROR", label: "error"},
79
+ ]
80
+ }]});
81
+
82
+ let platformSelection = $("#node-config-input-platform");
83
+ platformSelection.typedInput({type:"platform", types:[{
84
+ value: "platform",
85
+ options: [
86
+ { value: "console", label:"Console"},
87
+ { value: "rest", label: "Http / Https"},
88
+ { value: "loki", label: "Loki"},
89
+ // { value: "elasticsearch", label: "ElasticSearch"},
90
+ // { value: "datadog", label: "Datadog"},
91
+ // { value: "graylog", label: "Graylog"},
92
+ ]
93
+ }]});
94
+ platformSelection.on("change", () => showSelectedPlatform(platformSelection.val()));
95
+
96
+ let platformRestAuthType = $("#node-config-input-platform_rest_auth_type");
97
+ platformRestAuthType.typedInput({type:"authtype", types:[{
98
+ value: "authtype",
99
+ options: [
100
+ { value: "none", label: "None"},
101
+ { value: "basic", label: "Basic"},
102
+ { value: "apikey", label: "ApiKey"}
103
+ ]
104
+ }]});
105
+ platformRestAuthType.on("change", () => showSelectedRestAuthMethod(platformRestAuthType.val()));
106
+
107
+
108
+ let apiKeyMechanism = $("#node-config-input-platform_rest_auth_apikey_mechanism");
109
+ apiKeyMechanism.typedInput({type:"apikeymechansim", types:[{
110
+ value: "apikeymechansim",
111
+ options: [
112
+ { value: "header", label: "Header"},
113
+ { value: "queryparam", label: "Query Param"},
114
+ { value: "matrixparam", label: "Matrix Param"}
115
+ ]
116
+ }]});
117
+
118
+ this.editor = RED.editor.createEditor({
119
+ id: 'node-config-input-templateEditor',
120
+ mode: 'ace/mode/handlebars',
121
+ value: this.template
122
+ });
123
+
124
+
125
+ // setup defaults //
126
+ if(node.platform){
127
+ platformSelection.typedInput('value',node.platform);
128
+ }
129
+ showSelectedPlatform(platformSelection.val());
130
+ }
131
+ </script>
132
+
133
+ <script type="text/javascript" template-section="onIncludeEditSave">
134
+ {
135
+ let node = this;
136
+
137
+ this.template = this.editor.getValue();
138
+ this.editor.destroy();
139
+ delete this.editor;
140
+
141
+ // TODO: when saving the node, we need to remove all the platform_XXXX config values
142
+ // that are not supposed to be populated. For instance, when you switch from a loki to
143
+ // rest logger, the loki logger should be zeroed out.
144
+ }
145
+
146
+ </script>
147
+
148
+ <script type="text/html" template-section="onIncludeEditForm">
149
+ <div id="LoggerConfig">
150
+ <div class="form-row">
151
+ <label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
152
+ <input type="text" id="node-config-input-name" />
153
+ </div>
154
+
155
+ <div class="form-row">
156
+ <label for="node-config-input-level"><i class="fa fa-tag"></i> Level</label>
157
+ <input type="text" id="node-config-input-level" />
158
+ </div>
159
+
160
+ <div class="form-row">
161
+ <label for="node-config-input-platform"><i class="fa fa-tag"></i> Platform</label>
162
+ <input type="text" id="node-config-input-platform" />
163
+ </div>
164
+
165
+ <div class="platform platform-console">
166
+ </div>
167
+
168
+ <div class="platform platform-rest">
169
+ <div class="form-row">
170
+ <label for="node-config-input-platform_rest_url"><i class="fa fa-tag"></i> URL</label>
171
+ <input class="platform-rest-input required" type="text" id="node-config-input-platform_rest_url" />
172
+ </div>
173
+ <div class="form-row">
174
+ <input type="checkbox" id="node-config-input-platform_rest_ignoresslerror" style="margin:8px 0 10px 102px; width:20px;" />
175
+ <label style="width:auto" for="node-config-input-platform_rest_ignoresslerror"><span>Ignore Invalid SSL certificates</span></label>
176
+ </div>
177
+ <div class="form-row">
178
+ <label for="node-config-input-platform_rest_auth_type"><i class="fa fa-tag"></i> Authentication</label>
179
+ <input class="platform-rest-input required" type="text" id="node-config-input-platform_rest_auth_type" />
180
+ </div>
181
+ <div class="form-row platform-rest-auth auth-basic">
182
+ <label for="node-config-input-platform_rest_auth_basic_username"><i class="fa fa-tag"></i> Username</label>
183
+ <input class="platform-rest-input" type="text" id="node-config-input-platform_rest_auth_basic_username" />
184
+ </div>
185
+ <div class="form-row platform-rest-auth auth-basic">
186
+ <label for="node-config-input-platform_rest_auth_basic_password"><i class="fa fa-tag"></i> Password</label>
187
+ <input class="platform-rest-input" type="password" id="node-config-input-platform_rest_auth_basic_password" />
188
+ </div>
189
+ <div class="form-row platform-rest-auth auth-apikey">
190
+ <label for="node-config-input-platform_rest_auth_apikey_mechanism"><i class="fa fa-tag"></i> Mechanism</label>
191
+ <input class="platform-rest-input" type="text" id="node-config-input-platform_rest_auth_apikey_mechanism" />
192
+ </div>
193
+ <div class="form-row platform-rest-auth auth-apikey">
194
+ <label for="node-config-input-platform_rest_auth_apikey_name"><i class="fa fa-tag"></i> APIKey name</label>
195
+ <input class="platform-rest-input" type="text" id="node-config-input-platform_rest_auth_apikey_name" />
196
+ </div>
197
+ <div class="form-row platform-rest-auth auth-apikey">
198
+ <label for="node-config-input-platform_rest_auth_apikey_value"><i class="fa fa-tag"></i> APIKey value</label>
199
+ <input class="platform-rest-input" type="text" id="node-config-input-platform_rest_auth_apikey_value" />
200
+ </div>
201
+ </div>
202
+
203
+ <div class="platform platform-loki">
204
+ <div class="form-row">
205
+ <label for="node-config-input-platform_loki_host"><i class="fa fa-tag"></i> Host</label>
206
+ <input class="platform-loki-input required" type="text" id="node-config-input-platform_loki_host" />
207
+ </div>
208
+ <div class="form-row">
209
+ <label for="node-config-input-platform_loki_tenantID"><i class="fa fa-tag"></i> TenantID</label>
210
+ <input class="platform-loki-input" type="text" id="node-config-input-platform_loki_tenantID" />
211
+ </div>
212
+ <div class="form-row">
213
+ <label for="node-config-input-platform_loki_userid"><i class="fa fa-tag"></i> Username</label>
214
+ <input class="platform-loki-input" type="text" id="node-config-input-platform_loki_userid" />
215
+ </div>
216
+ <div class="form-row">
217
+ <label for="node-config-input-platform_loki_authtoken"><i class="fa fa-tag"></i> AuthToken</label>
218
+ <input class="platform-loki-input" type="password" id="node-config-input-platform_loki_authtoken" />
219
+ </div>
220
+ </div>
221
+
222
+ <div class="platform platform-elasticsearch">
223
+ ELASTIC SEARCH
224
+ </div>
225
+
226
+ <div class="platform platform-datadog">
227
+ DATADOG
228
+ </div>
229
+
230
+ <div class="platform platform-graylog">
231
+ GRAYLOG
232
+ </div>
233
+
234
+ <div class="form-row">
235
+ <label for="node-config-input-templateEditor"><i class="fa fa-tag"></i> Template</label>
236
+ <div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-config-input-templateEditor"></div>
237
+ </div>
238
+ </div>
239
+ </script>
240
+
241
+ <script type="text/markdown" template-section="onIncludeDocumentation">
242
+ Configuration node for the Logger Integration
243
+
244
+ ## Inputs
245
+ : *name* (string) : The common name for the logger Configuration
246
+ : *level* (level) : The logging level - debug, info, warning, error
247
+ : *platform*(string) : The common name for the logger Configuration
248
+ : *template*(mustache) : A template for the log messages.
249
+
250
+ ## Logger platform
251
+ Currently supported logging platforms
252
+
253
+ ### Console
254
+ The log message will be printed out to stdio
255
+
256
+ ### Http / Https
257
+ Publish the message to an http endpoint using a http / https POST command.
258
+
259
+ : *url* (url) : The endpoint for the url where requests are to be posted to.
260
+ : *ignore ssl errors* (boolean) : If enabled, the invalid ssl certificates will be ignored.
261
+ : *authentication* (auth method) : what auth method should be used for the http request. (none, basic, api key)
262
+
263
+ #### Authentication
264
+ ##### Basic
265
+ Provides basic authentication using the Authorization header
266
+
267
+ : *username* (string) : the username used for basic authentication
268
+ : *password* (string) : the password used for basic authentication
269
+
270
+ ##### APIKey
271
+ Provides authentication using a matrix parameter, header or query parameter and an apikey
272
+
273
+ : *mechanism* (mechanism) : the mechanism that will be used for transmitting the key (header, queryparam, matrixparam)
274
+ : *apikey name* (string) : the name of the key used for api authentication. (path variable or query param name)
275
+ : *apikey value*(string) : the value of the api key that will be transmitted. (beware of special characters)
276
+
277
+ ### Loki
278
+ Publish the message to a loki endpoint.
279
+
280
+ : *host* (string) : the host and port\ of the loki instance that it being logged to
281
+ : *tenant* (string) : the tenant id that will be used to log to
282
+ : *username* (string) : the username for the loki instance.
283
+ : *authtoken* (string) : the authtoken for the loki instance.
284
+
285
+ # Mustache Templating
286
+ Mustache / Handlebars are used for building up the logged message payloads that are sent to the logging backend.
287
+ The resultant message will be interpreted as a string, meaning care should be taken in the event that a string representation of a json object is built.
288
+
289
+ ### Provided Properties
290
+ A couple of values are provided to the logging context by default.
291
+
292
+ : *msg* (object) : an object containing the payload or message that should be parsed through the template.
293
+ : *currentTime* (object) : a string containing the current time in ISO8601 format
294
+
295
+ ### Mustache Helpers
296
+ In addition to the provided properties, some "helpers" have also been provided to assist in serialization.
297
+
298
+ : *json* (helper) : converts a json object to a string using the JSON.stringify method.
299
+
300
+ ## Examples
301
+ - {{{json msg}}} - serializes the the msg object to json format.
302
+
303
+ # References
304
+ - [Mustache - Wikipedia](https://en.wikipedia.org/wiki/Mustache_(template_system))
305
+ - [Mustache - Playground](https://jgonggrijp.gitlab.io/wontache/playground.html)
306
+ </script>
307
+
@@ -0,0 +1,95 @@
1
+ // LOGGER is officially deprecated. Do not use it.
2
+ import { Node } from "node-red";
3
+ import { ConfigNode, ConfigNodeConfig, NodeDescriptor } from "../../NodeConstructor"
4
+ import { NewLogger, Log, LoggerRegistration, LoggerService, RestLoggerConfig } from "../service/LoggerService"
5
+ import { SourceUtility } from "../../NodeGenerator";
6
+ import { ApiKeyMechanismType, Level, PlatformType, RestAuthType } from "../service/LoggerServiceTypes";
7
+
8
+ interface LoggerConfigNodeConfig extends ConfigNodeConfig {
9
+
10
+ id: string;
11
+ platform: PlatformType;
12
+ level:Level;
13
+ platfrom:PlatformType;
14
+ template:string;
15
+
16
+ platform_rest_url: string;
17
+ platform_rest_auth_type: RestAuthType;
18
+ platform_rest_auth_basic_username:string;
19
+ platform_rest_auth_basic_password:string;
20
+ platform_rest_auth_apikey_mechanism:ApiKeyMechanismType;
21
+ platform_rest_auth_apikey_name:string;
22
+ platform_rest_auth_apikey_value:string;
23
+
24
+ platform_loki_host:string,
25
+ platform_loki_userid?:string,
26
+ platform_loki_authtoken?:string,
27
+ platform_loki_tenantID?:string
28
+ }
29
+
30
+ export class LoggerConfigNode extends ConfigNode<LoggerConfigNodeConfig> {
31
+
32
+ private _logger!: NewLogger<any>;
33
+
34
+ constructor(node: Node, config: LoggerConfigNodeConfig){
35
+ super(node, config);
36
+ let _this = this;
37
+
38
+ // instantiate the logger.
39
+ let loggerConfig:any;
40
+
41
+ if(config.platform === PlatformType.console){
42
+ loggerConfig = {
43
+ id:this.id(),
44
+ type:PlatformType.console,
45
+ template:config.template,
46
+ level:config.level,
47
+ }
48
+ }
49
+
50
+ if(config.platform === PlatformType.rest){
51
+ loggerConfig = {
52
+ id:this.id(),
53
+ type:PlatformType.rest,
54
+ template:config.template,
55
+ level:config.level,
56
+ url: config.platform_rest_url,
57
+ auth_type: config.platform_rest_auth_type,
58
+ auth_basic_username:config.platform_rest_auth_basic_username,
59
+ auth_basic_password:config.platform_rest_auth_basic_password,
60
+ auth_apikey_mechanism:config.platform_rest_auth_apikey_mechanism,
61
+ auth_apikey_name:config.platform_rest_auth_apikey_name,
62
+ auth_apikey_value:config.platform_rest_auth_apikey_value,
63
+ } as RestLoggerConfig;
64
+ }
65
+
66
+ if(config.platform === PlatformType.loki){
67
+ loggerConfig = {
68
+ id:this.id(),
69
+ type:PlatformType.loki,
70
+ template:config.template,
71
+ level:config.level,
72
+ host:config.platform_loki_host,
73
+ userid:config.platform_loki_userid,
74
+ authtoken:config.platform_loki_authtoken,
75
+ tenantID:config.platform_loki_tenantID,
76
+ }
77
+ }
78
+
79
+ this._logger = LoggerService.get(loggerConfig);
80
+ }
81
+
82
+ public registerLogger(registration:LoggerRegistration):Log {
83
+ return this._logger.register(registration)
84
+ }
85
+
86
+ static override getNodeDescriptor():NodeDescriptor {
87
+ return new NodeDescriptor(
88
+ "config",
89
+ "LoggerConfigNode",
90
+ SourceUtility.getSourcePath("/build/", "/src/") + "LoggerConfigNode.html",
91
+ "@theotherwillembotha/node-red-plugincore")
92
+ .addDependency(LoggerService)
93
+ .addTag("Core")
94
+ }
95
+ }
@@ -0,0 +1,153 @@
1
+
2
+ <script type="text/javascript" template-section="onCompose">
3
+ node
4
+ .addDefault("name", {value:"Logger Example", required:true})
5
+ .addDefault("template", {value:`message:{{msg}}`, required:true})
6
+ .addDefault("level", {value:"info", required:true})
7
+
8
+ .addDefault("loki_host", {})
9
+ .addDefault("loki_tenantID", {})
10
+ .addDefault("loki_userid", {})
11
+ .addDefault("loki_authtoken", {})
12
+
13
+ .setPaletteLabel("Loki Logger Config Node")
14
+ .setLabel(function() {return this.name })
15
+ </script>
16
+
17
+ <script type="text/javascript" template-section="onIncludeEditPrepare">
18
+ {
19
+ let node = this;
20
+
21
+ let levelSelection = $("#node-config-input-level");
22
+ levelSelection.typedInput({type:"level", types:[{
23
+ value: "level",
24
+ options: [
25
+ { value: "DEBUG", label: "debug"},
26
+ { value: "INFO", label: "info"},
27
+ { value: "WARNING", label: "warning"},
28
+ { value: "ERROR", label: "error"},
29
+ ]
30
+ }]});
31
+
32
+ this.editor = RED.editor.createEditor({
33
+ id: 'node-config-input-templateEditor',
34
+ mode: 'ace/mode/handlebars',
35
+ value: this.template
36
+ });
37
+ }
38
+ </script>
39
+
40
+ <script type="text/javascript" template-section="onIncludeEditSave">
41
+ {
42
+ let node = this;
43
+
44
+ this.template = this.editor.getValue();
45
+ this.editor.destroy();
46
+ delete this.editor;
47
+ }
48
+
49
+ </script>
50
+
51
+ <script type="text/html" template-section="onIncludeEditForm">
52
+ <div id="LoggerConfig">
53
+ <div class="form-row">
54
+ <label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
55
+ <input type="text" id="node-config-input-name" />
56
+ </div>
57
+
58
+ <div class="form-row">
59
+ <label for="node-config-input-level"><i class="fa fa-tag"></i> Level</label>
60
+ <input type="text" id="node-config-input-level" />
61
+ </div>
62
+
63
+ <div class="form-row">
64
+ <label for="node-config-input-loki_host"><i class="fa fa-tag"></i> Host</label>
65
+ <input class="required" type="text" id="node-config-input-loki_host" />
66
+ </div>
67
+ <div class="form-row">
68
+ <label for="node-config-input-loki_tenantID"><i class="fa fa-tag"></i> TenantID</label>
69
+ <input class="" type="text" id="node-config-input-loki_tenantID" />
70
+ </div>
71
+ <div class="form-row">
72
+ <label for="node-config-input-loki_userid"><i class="fa fa-tag"></i> Username</label>
73
+ <input class="" type="text" id="node-config-input-loki_userid" />
74
+ </div>
75
+ <div class="form-row">
76
+ <label for="node-config-input-loki_authtoken"><i class="fa fa-tag"></i> AuthToken</label>
77
+ <input class="" type="password" id="node-config-input-loki_authtoken" />
78
+ </div>
79
+
80
+ <div class="form-row">
81
+ <label for="node-config-input-templateEditor"><i class="fa fa-tag"></i> Template</label>
82
+ <div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-config-input-templateEditor"></div>
83
+ </div>
84
+ </div>
85
+ </script>
86
+
87
+ <script type="text/markdown" template-section="onIncludeDocumentation">
88
+ Configuration node for the Logger Integration
89
+
90
+ ## Inputs
91
+ : *name* (string) : The common name for the logger Configuration
92
+ : *level* (level) : The logging level - debug, info, warning, error
93
+ : *platform*(string) : The common name for the logger Configuration
94
+ : *template*(mustache) : A template for the log messages.
95
+
96
+ ## Logger platform
97
+ Currently supported logging platforms
98
+
99
+ ### Console
100
+ The log message will be printed out to stdio
101
+
102
+ ### Http / Https
103
+ Publish the message to an http endpoint using a http / https POST command.
104
+
105
+ : *url* (url) : The endpoint for the url where requests are to be posted to.
106
+ : *ignore ssl errors* (boolean) : If enabled, the invalid ssl certificates will be ignored.
107
+ : *authentication* (auth method) : what auth method should be used for the http request. (none, basic, api key)
108
+
109
+ #### Authentication
110
+ ##### Basic
111
+ Provides basic authentication using the Authorization header
112
+
113
+ : *username* (string) : the username used for basic authentication
114
+ : *password* (string) : the password used for basic authentication
115
+
116
+ ##### APIKey
117
+ Provides authentication using a matrix parameter, header or query parameter and an apikey
118
+
119
+ : *mechanism* (mechanism) : the mechanism that will be used for transmitting the key (header, queryparam, matrixparam)
120
+ : *apikey name* (string) : the name of the key used for api authentication. (path variable or query param name)
121
+ : *apikey value*(string) : the value of the api key that will be transmitted. (beware of special characters)
122
+
123
+ ### Loki
124
+ Publish the message to a loki endpoint.
125
+
126
+ : *host* (string) : the host and port\ of the loki instance that it being logged to
127
+ : *tenant* (string) : the tenant id that will be used to log to
128
+ : *username* (string) : the username for the loki instance.
129
+ : *authtoken* (string) : the authtoken for the loki instance.
130
+
131
+ # Mustache Templating
132
+ Mustache / Handlebars are used for building up the logged message payloads that are sent to the logging backend.
133
+ The resultant message will be interpreted as a string, meaning care should be taken in the event that a string representation of a json object is built.
134
+
135
+ ### Provided Properties
136
+ A couple of values are provided to the logging context by default.
137
+
138
+ : *msg* (object) : an object containing the payload or message that should be parsed through the template.
139
+ : *currentTime* (object) : a string containing the current time in ISO8601 format
140
+
141
+ ### Mustache Helpers
142
+ In addition to the provided properties, some "helpers" have also been provided to assist in serialization.
143
+
144
+ : *json* (helper) : converts a json object to a string using the JSON.stringify method.
145
+
146
+ ## Examples
147
+ - {{{json msg}}} - serializes the the msg object to json format.
148
+
149
+ # References
150
+ - [Mustache - Wikipedia](https://en.wikipedia.org/wiki/Mustache_(template_system))
151
+ - [Mustache - Playground](https://jgonggrijp.gitlab.io/wontache/playground.html)
152
+ </script>
153
+
@@ -0,0 +1,58 @@
1
+
2
+ import { Node } from "node-red";
3
+ import { ConfigNode, ConfigNodeConfig } from "../../NodeConstructor"
4
+ import { NewLogger, Log, LoggerRegistration, LoggerService } from "../service/LoggerService"
5
+ import { SourceUtility } from "../../NodeGenerator";
6
+ import { Level, PlatformType } from "../service/LoggerServiceTypes";
7
+ import { NodeDescription } from "../../tagging/NodeDescriptionDecorator";
8
+
9
+ interface LokiLoggerConfigNodeConfig extends ConfigNodeConfig {
10
+
11
+ id: string;
12
+ level:Level;
13
+ template:string;
14
+
15
+ loki_host:string,
16
+ loki_userid?:string,
17
+ loki_authtoken?:string,
18
+ loki_tenantID?:string
19
+ }
20
+
21
+ @NodeDescription({
22
+ id:"LokiLoggerConfigNode",
23
+ name:"Loki Logger",
24
+ group:"config",
25
+ sourceFile:SourceUtility.getSourcePath("/build/", "/src/") + "LokiLoggerConfigNode.html",
26
+ package: "@theotherwillembotha/node-red-plugincore",
27
+ dependencies:[ LoggerService ],
28
+ tags: [ "LoggerType" ]
29
+ })
30
+ export class LokiLoggerConfigNode extends ConfigNode<LokiLoggerConfigNodeConfig> {
31
+
32
+ private _logger!: NewLogger<any>;
33
+
34
+ constructor(node: Node, config: LokiLoggerConfigNodeConfig){
35
+ super(node, config);
36
+ let _this = this;
37
+
38
+ // instantiate the logger.
39
+ let loggerConfig:any;
40
+
41
+ loggerConfig = {
42
+ id:this.id(),
43
+ type:PlatformType.loki,
44
+ template:config.template,
45
+ level:config.level,
46
+ host:config.loki_host,
47
+ userid:config.loki_userid,
48
+ authtoken:config.loki_authtoken,
49
+ tenantID:config.loki_tenantID,
50
+ }
51
+
52
+ this._logger = LoggerService.get(loggerConfig);
53
+ }
54
+
55
+ public registerLogger(registration:LoggerRegistration):Log {
56
+ return this._logger.register(registration)
57
+ }
58
+ }