@theotherwillembotha/node-red-plugincore 0.0.50 → 0.0.51
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/README.md +60 -21
- package/build/GenerateNodes.js +2 -0
- package/build/Nodes.html +174 -250
- package/build/Nodes.js +2 -0
- package/build/core/NodeConstructor.d.ts +4 -2
- package/build/core/NodeConstructor.d.ts.map +1 -1
- package/build/core/NodeConstructor.js +5 -3
- package/build/core/NodeGenerator.js +8 -8
- package/build/core/logger/node/ConsoleLoggerConfigNode.html +20 -61
- package/build/core/logger/node/LokiLoggerConfigNode.d.ts +1 -1
- package/build/core/logger/node/LokiLoggerConfigNode.html +37 -73
- package/build/core/logger/node/LokiLoggerConfigNode.js +1 -1
- package/build/core/logger/node/RestLoggerConfigNode.html +51 -77
- package/build/core/logger/node/RestLoggerConfigNode.js +1 -1
- package/build/core/logger/service/LoggerService.d.ts +1 -1
- package/build/core/logger/service/LoggerService.d.ts.map +1 -1
- package/build/core/logger/service/LoggerService.js +2 -3
- package/build/core/logger/template/LoggerTemplate.d.ts.map +1 -1
- package/build/core/logger/template/LoggerTemplate.html +15 -12
- package/build/core/logger/template/LoggerTemplate.js +1 -2
- package/build/core/metrics/MetricsDecorator.js +2 -2
- package/build/core/metrics/node/CounterMetricConfigNode.html +2 -2
- package/build/core/metrics/node/GaugeMetricConfigNode.html +2 -2
- package/build/core/metrics/node/GaugeMetricConfigNode.js +2 -2
- package/build/core/metrics/node/MetricsConfigNode.html +1 -1
- package/build/core/metrics/node/TimerMetricConfigNode.html +13 -13
- package/build/core/metrics/service/MetricsService.d.ts +1 -1
- package/build/core/metrics/service/MetricsService.js +6 -6
- package/build/core/metrics/template/CounterMetricTemplate.html +1 -1
- package/build/core/metrics/template/GaugeMetricTemplate.html +1 -1
- package/build/core/metrics/template/TimerMetricTemplate.html +1 -1
- package/build/core/other/node/DelegatedConfigReferenceNode.d.ts +57 -0
- package/build/core/other/node/DelegatedConfigReferenceNode.d.ts.map +1 -0
- package/build/core/other/node/DelegatedConfigReferenceNode.html +1 -0
- package/build/core/other/node/DelegatedConfigReferenceNode.js +79 -0
- package/build/core/tagging/NodeDescriptionDecorator.js +1 -1
- package/build/core/tagging/service/NodeTypeService.js +1 -1
- package/build/core/webhook/node/WebhookServerConfigNode.html +5 -5
- package/build/core/webhook/template/WebhookTemplate.html +18 -10
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/documentation/CounterMetricConfigNode.png +0 -0
- package/documentation/GaugeMetricConfigNode.png +0 -0
- package/documentation/MetricsConfigNode.png +0 -0
- package/documentation/TimerMetricConfigNode.png +0 -0
- package/documentation/WebhookNode.png +0 -0
- package/package.json +4 -3
- package/src/GenerateNodes.ts +3 -1
- package/src/core/NodeConstructor.ts +7 -4
- package/src/core/NodeGenerator.ts +8 -8
- package/src/core/logger/node/ConsoleLoggerConfigNode.html +20 -61
- package/src/core/logger/node/LokiLoggerConfigNode.html +37 -73
- package/src/core/logger/node/LokiLoggerConfigNode.ts +2 -2
- package/src/core/logger/node/RestLoggerConfigNode.html +51 -77
- package/src/core/logger/node/RestLoggerConfigNode.ts +1 -1
- package/src/core/logger/service/LoggerService.ts +3 -4
- package/src/core/logger/template/LoggerTemplate.html +15 -12
- package/src/core/logger/template/LoggerTemplate.ts +1 -2
- package/src/core/metrics/MetricsDecorator.ts +2 -2
- package/src/core/metrics/node/CounterMetricConfigNode.html +2 -2
- package/src/core/metrics/node/GaugeMetricConfigNode.html +2 -2
- package/src/core/metrics/node/GaugeMetricConfigNode.ts +2 -2
- package/src/core/metrics/node/MetricsConfigNode.html +1 -1
- package/src/core/metrics/node/MetricsConfigNode.ts +1 -1
- package/src/core/metrics/node/TimerMetricConfigNode.html +13 -13
- package/src/core/metrics/service/MetricsService.ts +6 -6
- package/src/core/metrics/template/CounterMetricTemplate.html +1 -1
- package/src/core/metrics/template/GaugeMetricTemplate.html +1 -1
- package/src/core/metrics/template/TimerMetricTemplate.html +1 -1
- package/src/core/other/node/DelegatedConfigReferenceNode.html +1 -0
- package/src/core/other/node/DelegatedConfigReferenceNode.ts +70 -0
- package/src/core/tagging/NodeDescriptionDecorator.ts +1 -1
- package/src/core/tagging/service/NodeTypeService.ts +1 -1
- package/src/core/webhook/node/WebhookServerConfigNode.html +5 -5
- package/src/core/webhook/template/WebhookTemplate.html +18 -10
- package/src/index.ts +1 -2
- package/build/core/logger/node/LoggerConfigNode.d.ts +0 -30
- package/build/core/logger/node/LoggerConfigNode.d.ts.map +0 -1
- package/build/core/logger/node/LoggerConfigNode.html +0 -307
- package/build/core/logger/node/LoggerConfigNode.js +0 -60
- package/src/core/logger/node/LoggerConfigNode.html +0 -307
- package/src/core/logger/node/LoggerConfigNode.ts +0 -95
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DelegatedConfigReferenceNode — a framework-internal sentinel type.
|
|
3
|
+
*
|
|
4
|
+
* PROBLEM
|
|
5
|
+
* Node-RED's reference counter (the usage count shown on config nodes in the
|
|
6
|
+
* Config sidebar) is driven by `updateConfigNodeUsers()` in nodes.js. That
|
|
7
|
+
* function only tracks a property as a config-node reference when two conditions
|
|
8
|
+
* are met:
|
|
9
|
+
* 1. `defaults[property].type` is set to a registered node type name.
|
|
10
|
+
* 2. That node type's `category` equals `"config"`.
|
|
11
|
+
*
|
|
12
|
+
* When a node property can reference *any* of several config-node types (e.g.
|
|
13
|
+
* ConsoleLoggerConfigNode, RestLoggerConfigNode, LokiLoggerConfigNode, or a
|
|
14
|
+
* future third-party logger), there is no single concrete type to declare.
|
|
15
|
+
* Leaving `type` blank causes the counter to stay at zero even when references
|
|
16
|
+
* exist, and the config node is incorrectly flagged as unused.
|
|
17
|
+
*
|
|
18
|
+
* WORKAROUND
|
|
19
|
+
* Register this no-op node with `category: "config"` so that its type name can
|
|
20
|
+
* be used as the `type` value in `addDefault(...)` calls where the referenced
|
|
21
|
+
* config node type is not known ahead of time (open/delegated reference).
|
|
22
|
+
* `updateConfigNodeUsers` will then pass both gates, look up the config node by
|
|
23
|
+
* its actual runtime ID, and correctly increment the counter.
|
|
24
|
+
*
|
|
25
|
+
* USAGE
|
|
26
|
+
* In a template or node's onCompose section, declare the property like this:
|
|
27
|
+
*
|
|
28
|
+
* .addDefault("myProp", { value: '', required: false, type: "DelegatedConfigReferenceNode" })
|
|
29
|
+
*
|
|
30
|
+
* Because the property name intentionally does NOT match the `node-input-X` /
|
|
31
|
+
* `node-config-input-X` naming convention, Node-RED will NOT auto-initialise
|
|
32
|
+
* the form element or auto-save the value. You must therefore:
|
|
33
|
+
* - Read the stored value manually in `onIncludeEditPrepare`
|
|
34
|
+
* e.g. $("#my-selector").val(node.myProp);
|
|
35
|
+
* - Write it back manually in `onIncludeEditSave`
|
|
36
|
+
* e.g. node.myProp = $("#my-selector").val();
|
|
37
|
+
*
|
|
38
|
+
* LONG-TERM
|
|
39
|
+
* A proper fix would be a Node-RED PR to make `updateConfigNodeUsers` use the
|
|
40
|
+
* already-parsed `_type.types` array (set by `parseNodePropertyTypeString`) so
|
|
41
|
+
* that pipe-separated multi-type strings such as
|
|
42
|
+
* "ConsoleLoggerConfigNode|RestLoggerConfigNode" work natively.
|
|
43
|
+
* Until that PR is accepted, this sentinel type is the recommended workaround
|
|
44
|
+
* within this framework.
|
|
45
|
+
*
|
|
46
|
+
* NOTE: This node has no UI, no edit form, and no runtime behaviour. It cannot
|
|
47
|
+
* be instantiated by users and should never appear as a flow node.
|
|
48
|
+
*/
|
|
49
|
+
import { Node } from "node-red";
|
|
50
|
+
import { ConfigNode, ConfigNodeConfig } from "../../NodeConstructor";
|
|
51
|
+
interface DelegatedConfigReferenceNodeConfig extends ConfigNodeConfig {
|
|
52
|
+
}
|
|
53
|
+
export declare class DelegatedConfigReferenceNode extends ConfigNode<DelegatedConfigReferenceNodeConfig> {
|
|
54
|
+
constructor(node: Node, config: DelegatedConfigReferenceNodeConfig);
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=DelegatedConfigReferenceNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DelegatedConfigReferenceNode.d.ts","sourceRoot":"","sources":["../../../../src/core/other/node/DelegatedConfigReferenceNode.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAIpE,UAAU,kCAAmC,SAAQ,gBAAgB;CAAG;AAExE,qBAOa,4BAA6B,SAAQ,UAAU,CAAC,kCAAkC,CAAC;gBAEhF,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,kCAAkC;CAGrE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!-- This section is intentionally left blank -->
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DelegatedConfigReferenceNode — a framework-internal sentinel type.
|
|
4
|
+
*
|
|
5
|
+
* PROBLEM
|
|
6
|
+
* Node-RED's reference counter (the usage count shown on config nodes in the
|
|
7
|
+
* Config sidebar) is driven by `updateConfigNodeUsers()` in nodes.js. That
|
|
8
|
+
* function only tracks a property as a config-node reference when two conditions
|
|
9
|
+
* are met:
|
|
10
|
+
* 1. `defaults[property].type` is set to a registered node type name.
|
|
11
|
+
* 2. That node type's `category` equals `"config"`.
|
|
12
|
+
*
|
|
13
|
+
* When a node property can reference *any* of several config-node types (e.g.
|
|
14
|
+
* ConsoleLoggerConfigNode, RestLoggerConfigNode, LokiLoggerConfigNode, or a
|
|
15
|
+
* future third-party logger), there is no single concrete type to declare.
|
|
16
|
+
* Leaving `type` blank causes the counter to stay at zero even when references
|
|
17
|
+
* exist, and the config node is incorrectly flagged as unused.
|
|
18
|
+
*
|
|
19
|
+
* WORKAROUND
|
|
20
|
+
* Register this no-op node with `category: "config"` so that its type name can
|
|
21
|
+
* be used as the `type` value in `addDefault(...)` calls where the referenced
|
|
22
|
+
* config node type is not known ahead of time (open/delegated reference).
|
|
23
|
+
* `updateConfigNodeUsers` will then pass both gates, look up the config node by
|
|
24
|
+
* its actual runtime ID, and correctly increment the counter.
|
|
25
|
+
*
|
|
26
|
+
* USAGE
|
|
27
|
+
* In a template or node's onCompose section, declare the property like this:
|
|
28
|
+
*
|
|
29
|
+
* .addDefault("myProp", { value: '', required: false, type: "DelegatedConfigReferenceNode" })
|
|
30
|
+
*
|
|
31
|
+
* Because the property name intentionally does NOT match the `node-input-X` /
|
|
32
|
+
* `node-config-input-X` naming convention, Node-RED will NOT auto-initialise
|
|
33
|
+
* the form element or auto-save the value. You must therefore:
|
|
34
|
+
* - Read the stored value manually in `onIncludeEditPrepare`
|
|
35
|
+
* e.g. $("#my-selector").val(node.myProp);
|
|
36
|
+
* - Write it back manually in `onIncludeEditSave`
|
|
37
|
+
* e.g. node.myProp = $("#my-selector").val();
|
|
38
|
+
*
|
|
39
|
+
* LONG-TERM
|
|
40
|
+
* A proper fix would be a Node-RED PR to make `updateConfigNodeUsers` use the
|
|
41
|
+
* already-parsed `_type.types` array (set by `parseNodePropertyTypeString`) so
|
|
42
|
+
* that pipe-separated multi-type strings such as
|
|
43
|
+
* "ConsoleLoggerConfigNode|RestLoggerConfigNode" work natively.
|
|
44
|
+
* Until that PR is accepted, this sentinel type is the recommended workaround
|
|
45
|
+
* within this framework.
|
|
46
|
+
*
|
|
47
|
+
* NOTE: This node has no UI, no edit form, and no runtime behaviour. It cannot
|
|
48
|
+
* be instantiated by users and should never appear as a flow node.
|
|
49
|
+
*/
|
|
50
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
51
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
52
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
53
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
54
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
55
|
+
};
|
|
56
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
57
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
58
|
+
};
|
|
59
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
+
exports.DelegatedConfigReferenceNode = void 0;
|
|
61
|
+
const NodeConstructor_1 = require("../../NodeConstructor");
|
|
62
|
+
const NodeGenerator_1 = require("../../NodeGenerator");
|
|
63
|
+
const NodeDescriptionDecorator_1 = require("../../tagging/NodeDescriptionDecorator");
|
|
64
|
+
let DelegatedConfigReferenceNode = class DelegatedConfigReferenceNode extends NodeConstructor_1.ConfigNode {
|
|
65
|
+
constructor(node, config) {
|
|
66
|
+
super(node, config);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.DelegatedConfigReferenceNode = DelegatedConfigReferenceNode;
|
|
70
|
+
exports.DelegatedConfigReferenceNode = DelegatedConfigReferenceNode = __decorate([
|
|
71
|
+
(0, NodeDescriptionDecorator_1.NodeDescription)({
|
|
72
|
+
id: "DelegatedConfigReferenceNode",
|
|
73
|
+
name: "DelegatedConfigReferenceNode",
|
|
74
|
+
group: "config",
|
|
75
|
+
sourceFile: NodeGenerator_1.SourceUtility.getSourcePath("/build/", "/src/") + "DelegatedConfigReferenceNode.html",
|
|
76
|
+
package: "@theotherwillembotha/node-red-plugincore",
|
|
77
|
+
}),
|
|
78
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
79
|
+
], DelegatedConfigReferenceNode);
|
|
@@ -4,7 +4,7 @@ exports.NodeDescription = NodeDescription;
|
|
|
4
4
|
const NodeConstructor_1 = require("../NodeConstructor");
|
|
5
5
|
function NodeDescription(config) {
|
|
6
6
|
return function (target) {
|
|
7
|
-
let descriptor = new NodeConstructor_1.NodeDescriptor(config.group, config.id, config.sourceFile, config.package);
|
|
7
|
+
let descriptor = new NodeConstructor_1.NodeDescriptor(config.group, config.id, config.name, config.sourceFile, config.package);
|
|
8
8
|
if (config.templates) {
|
|
9
9
|
for (let template of config.templates) {
|
|
10
10
|
descriptor.addTemplate(template.template, template.config);
|
|
@@ -16,7 +16,7 @@ class NodeTypeService extends NodeConstructor_1.BaseService {
|
|
|
16
16
|
let types = this.getNodeTypesForTag(tag).map(type => {
|
|
17
17
|
let description = type.getNodeDescriptor();
|
|
18
18
|
return {
|
|
19
|
-
"id": description.
|
|
19
|
+
"id": description.id(),
|
|
20
20
|
"name": description.name(),
|
|
21
21
|
};
|
|
22
22
|
});
|
|
@@ -18,25 +18,25 @@
|
|
|
18
18
|
</div>
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
<script type="text/html" template-section="onIncludeEditForm"
|
|
21
|
+
<script type="text/html" template-section="onIncludeEditForm">
|
|
22
22
|
<div id="WebhookServerConfig">
|
|
23
23
|
<div class="form-row">
|
|
24
|
-
<label for="node-config-input-name"><i class="fa fa-
|
|
24
|
+
<label class="towb_editorlabel" for="node-config-input-name"><i class="fa fa-font"></i> Name</label>
|
|
25
25
|
<input type="text" id="node-config-input-name" />
|
|
26
26
|
</div>
|
|
27
27
|
|
|
28
28
|
<div class="form-row">
|
|
29
|
-
<label for="node-config-input-port"><i class="fa fa-
|
|
29
|
+
<label class="towb_editorlabel" for="node-config-input-port"><i class="fa fa-plug"></i> Port</label>
|
|
30
30
|
<input type="number" id="node-config-input-port" />
|
|
31
31
|
</div>
|
|
32
32
|
|
|
33
33
|
<div class="form-row">
|
|
34
|
-
<label for="node-config-input-externalHost"><i class="fa fa-
|
|
34
|
+
<label class="towb_editorlabel" for="node-config-input-externalHost"><i class="fa fa-globe"></i> External Host</label>
|
|
35
35
|
<input type="text" id="node-config-input-externalHost" />
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
<div class="form-row">
|
|
39
|
-
<label for="node-config-input-externalPort"><i class="fa fa-
|
|
39
|
+
<label class="towb_editorlabel" for="node-config-input-externalPort"><i class="fa fa-plug"></i> External Port</label>
|
|
40
40
|
<input type="number" id="node-config-input-externalPort" />
|
|
41
41
|
</div>
|
|
42
42
|
<!-- add a button here to autmatically find an open port -->
|
|
@@ -133,6 +133,12 @@ node
|
|
|
133
133
|
return types;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
getProxyTypes().then(types => {
|
|
137
|
+
if(types.length === 0){
|
|
138
|
+
$("#section_reverseproxy_feature").hide();
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
136
142
|
let getProxies = async () => {
|
|
137
143
|
let proxies = [];
|
|
138
144
|
|
|
@@ -335,17 +341,17 @@ node
|
|
|
335
341
|
|
|
336
342
|
<div class="editorgroupborder">
|
|
337
343
|
<div class="form-row nomargin">
|
|
338
|
-
<label for="{{defaults.webhook}}">Server</label>
|
|
344
|
+
<label class="towb_editorlabel" for="{{defaults.webhook}}"><i class="fa fa-server"></i> Server</label>
|
|
339
345
|
<input id="{{defaults.webhook}}" placeholder="webhook" />
|
|
340
346
|
</div>
|
|
341
|
-
|
|
347
|
+
|
|
342
348
|
<div class="form-row">
|
|
343
|
-
<label for="{{defaults.webhookPath}}">Path</label>
|
|
349
|
+
<label class="towb_editorlabel" for="{{defaults.webhookPath}}"><i class="fa fa-link"></i> Path</label>
|
|
344
350
|
<input type="text" id="{{defaults.webhookPath}}" placeholder="/example" />
|
|
345
351
|
</div>
|
|
346
352
|
|
|
347
353
|
<div class="form-row">
|
|
348
|
-
<label for="{{defaults.webhookAuth}}">Authentication</label>
|
|
354
|
+
<label class="towb_editorlabel" for="{{defaults.webhookAuth}}"><i class="fa fa-lock"></i> Authentication</label>
|
|
349
355
|
<input type="text" id="{{defaults.webhookAuth}}" placeholder="none" />
|
|
350
356
|
</div>
|
|
351
357
|
|
|
@@ -354,33 +360,34 @@ node
|
|
|
354
360
|
|
|
355
361
|
<div class="webhookauth webhookauth-basic">
|
|
356
362
|
<div class="form-row">
|
|
357
|
-
<label for="{{defaults.webhookAuth_basic_username}}">
|
|
363
|
+
<label class="towb_editorlabel" for="{{defaults.webhookAuth_basic_username}}"><i class="fa fa-user"></i> Username</label>
|
|
358
364
|
<input type="text" id="{{defaults.webhookAuth_basic_username}}" placeholder="testUser" />
|
|
359
365
|
</div>
|
|
360
366
|
|
|
361
367
|
<div class="form-row">
|
|
362
|
-
<label for="{{defaults.webhookAuth_basic_password}}">
|
|
368
|
+
<label class="towb_editorlabel" for="{{defaults.webhookAuth_basic_password}}"><i class="fa fa-key"></i> Password</label>
|
|
363
369
|
<input type="password" id="{{defaults.webhookAuth_basic_password}}" placeholder="password" />
|
|
364
370
|
</div>
|
|
365
371
|
</div>
|
|
366
372
|
|
|
367
373
|
<div class="webhookauth webhookauth-apikey">
|
|
368
374
|
<div class="form-row">
|
|
369
|
-
<label for="{{defaults.webhookAuth_apikey_mechanism}}">
|
|
375
|
+
<label class="towb_editorlabel" for="{{defaults.webhookAuth_apikey_mechanism}}"><i class="fa fa-exchange"></i> Mechanism</label>
|
|
370
376
|
<input type="text" id="{{defaults.webhookAuth_apikey_mechanism}}"/>
|
|
371
377
|
</div>
|
|
372
378
|
|
|
373
379
|
<div class="form-row">
|
|
374
|
-
<label for="{{defaults.webhookAuth_apikey_key}}">APIKey
|
|
380
|
+
<label class="towb_editorlabel" for="{{defaults.webhookAuth_apikey_key}}"><i class="fa fa-id-badge"></i> APIKey name</label>
|
|
375
381
|
<input type="text" id="{{defaults.webhookAuth_apikey_key}}" placeholder="x-api-key" />
|
|
376
382
|
</div>
|
|
377
383
|
|
|
378
384
|
<div class="form-row">
|
|
379
|
-
<label for="{{defaults.webhookAuth_apikey_value}}">APIKey
|
|
385
|
+
<label class="towb_editorlabel" for="{{defaults.webhookAuth_apikey_value}}"><i class="fa fa-lock"></i> APIKey value</label>
|
|
380
386
|
<input type="text" id="{{defaults.webhookAuth_apikey_value}}" placeholder="testvalue" />
|
|
381
387
|
</div>
|
|
382
388
|
</div>
|
|
383
389
|
|
|
390
|
+
<div id="section_reverseproxy_feature">
|
|
384
391
|
<div class="form-row">
|
|
385
392
|
<label>Reverse Proxy</label>
|
|
386
393
|
<input type="checkbox" id="{{defaults.reverseProxies_enabled}}" style="width:20px; margin-right:5px;" />
|
|
@@ -392,8 +399,9 @@ node
|
|
|
392
399
|
<ol id="reverseproxylist_table" class="theotherwillembotha-compact-table"></ol>
|
|
393
400
|
</div>
|
|
394
401
|
</div>
|
|
402
|
+
</div>
|
|
403
|
+
|
|
395
404
|
|
|
396
|
-
|
|
397
405
|
</div>
|
|
398
406
|
</div>
|
|
399
407
|
</script>
|
package/build/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export * from "./core/Utils";
|
|
|
2
2
|
export * from "./core/NodeGenerator";
|
|
3
3
|
export * from "./core/NodeConstructor";
|
|
4
4
|
export * from "./core/logger/service/LoggerService";
|
|
5
|
-
export * from "./core/logger/node/LoggerConfigNode";
|
|
6
5
|
export * from "./core/logger/template/LoggerTemplate";
|
|
7
6
|
export * from "./core/logger/node/ConsoleLoggerConfigNode";
|
|
8
7
|
export * from "./core/logger/node/RestLoggerConfigNode";
|
|
@@ -18,6 +17,7 @@ export * from "./core/metrics/node/TimerMetricConfigNode";
|
|
|
18
17
|
export * from "./core/metrics/template/TimerMetricTemplate";
|
|
19
18
|
export * from "./core/tagging/service/NodeTypeService";
|
|
20
19
|
export * from "./core/tagging/NodeDescriptionDecorator";
|
|
20
|
+
export * from "./core/other/node/DelegatedConfigReferenceNode";
|
|
21
21
|
export * from "./core/other/service/InputService";
|
|
22
22
|
export * from "./core/other/service/SettingsService";
|
|
23
23
|
export * from "./core/other/template/BasicTemplate";
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,qCAAqC,CAAC;AACpD,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,qCAAqC,CAAC;AACpD,cAAc,uCAAuC,CAAC;AACtD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,yCAAyC,CAAC;AACxD,cAAc,yCAAyC,CAAC;AAGxD,cAAc,uCAAuC,CAAC;AACtD,cAAc,yCAAyC,CAAC;AACxD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,uCAAuC,CAAC;AACtD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,6CAA6C,CAAC;AAG5D,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AAGxD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,mCAAmC,CAAC;AAClD,cAAc,sCAAsC,CAAC;AACrD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AAGvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,6CAA6C,CAAC;AAG5D,cAAc,gDAAgD,CAAC;AAG/D,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -19,7 +19,6 @@ __exportStar(require("./core/NodeGenerator"), exports);
|
|
|
19
19
|
__exportStar(require("./core/NodeConstructor"), exports);
|
|
20
20
|
// LOGGER
|
|
21
21
|
__exportStar(require("./core/logger/service/LoggerService"), exports);
|
|
22
|
-
__exportStar(require("./core/logger/node/LoggerConfigNode"), exports);
|
|
23
22
|
__exportStar(require("./core/logger/template/LoggerTemplate"), exports);
|
|
24
23
|
__exportStar(require("./core/logger/node/ConsoleLoggerConfigNode"), exports);
|
|
25
24
|
__exportStar(require("./core/logger/node/RestLoggerConfigNode"), exports);
|
|
@@ -38,6 +37,7 @@ __exportStar(require("./core/metrics/template/TimerMetricTemplate"), exports);
|
|
|
38
37
|
__exportStar(require("./core/tagging/service/NodeTypeService"), exports);
|
|
39
38
|
__exportStar(require("./core/tagging/NodeDescriptionDecorator"), exports);
|
|
40
39
|
// OTHER
|
|
40
|
+
__exportStar(require("./core/other/node/DelegatedConfigReferenceNode"), exports);
|
|
41
41
|
__exportStar(require("./core/other/service/InputService"), exports);
|
|
42
42
|
__exportStar(require("./core/other/service/SettingsService"), exports);
|
|
43
43
|
__exportStar(require("./core/other/template/BasicTemplate"), exports);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theotherwillembotha/node-red-plugincore",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "A
|
|
3
|
+
"version": "0.0.51",
|
|
4
|
+
"description": "A core framework for building production-grade Node-RED plugins, with built-in support for structured logging, metrics, and webhook ingestion.",
|
|
5
5
|
"author": "Willem Botha (@theotherwillembotha)",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"keywords": [
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"url": "https://github.com/theotherwillembotha/nodered_plugincore/issues"
|
|
27
27
|
},
|
|
28
28
|
"types": "./build/index.d.ts",
|
|
29
|
-
"files": ["build/", "src/", "icons/", "LICENSE", "README.md"],
|
|
29
|
+
"files": ["build/", "src/", "icons/", "documentation/", "LICENSE", "README.md"],
|
|
30
30
|
"homepage": "https://github.com/theotherwillembotha/nodered_plugincore#readme",
|
|
31
31
|
"engines": {
|
|
32
32
|
"node": ">=18",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"winston-loki": "^6.1.3"
|
|
58
58
|
},
|
|
59
59
|
"node-red": {
|
|
60
|
+
"version": ">=4.0.0",
|
|
60
61
|
"nodes": {
|
|
61
62
|
"core": "./build/Nodes.js"
|
|
62
63
|
},
|
package/src/GenerateNodes.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
|
|
2
|
+
import { DelegatedConfigReferenceNode } from "./core/other/node/DelegatedConfigReferenceNode.js";
|
|
2
3
|
import { NodeTypeService } from "./core/tagging/service/NodeTypeService.js";
|
|
3
4
|
import { NodeGenerator, SettingsService, BasicTemplate, SettingsTemplate, TimerMetricTemplate, ConsoleLoggerConfigNode, RestLoggerConfigNode, LokiLoggerConfigNode } from "./index.js"
|
|
4
5
|
import { WebhookServerConfigNode, WebhookServerService, WebhookTemplate, } from "./index.js"
|
|
5
6
|
|
|
6
|
-
import {LoggerService, LoggerTemplate
|
|
7
|
+
import {LoggerService, LoggerTemplate } from "./index.js";
|
|
7
8
|
|
|
8
9
|
import { MetricsService, MetricsTemplate, CounterMetricTemplate, GaugeMetricTemplate} from "./index.js";
|
|
9
10
|
import { MetricsConfigNode, GaugeMetricConfigNode, TimerMetricConfigNode, CounterMetricConfigNode } from "./index.js";
|
|
@@ -27,6 +28,7 @@ new NodeGenerator("./src/core/")
|
|
|
27
28
|
.registerTemplate(WebhookTemplate)
|
|
28
29
|
|
|
29
30
|
// nodes
|
|
31
|
+
.registerNode(DelegatedConfigReferenceNode)
|
|
30
32
|
.registerNode(ConsoleLoggerConfigNode)
|
|
31
33
|
.registerNode(RestLoggerConfigNode)
|
|
32
34
|
.registerNode(LokiLoggerConfigNode)
|
|
@@ -79,15 +79,17 @@ export type NodeDependencyType = INamedType & (INodeClass | IServiceClass);
|
|
|
79
79
|
|
|
80
80
|
export class NodeDescriptor {
|
|
81
81
|
private _group:string;
|
|
82
|
-
private
|
|
82
|
+
private _id:string;
|
|
83
|
+
private _name:String;
|
|
83
84
|
private _sourceFile: string;
|
|
84
85
|
private _dependencies: DependencyType[] = []
|
|
85
86
|
private _templates:{template:ITemplateClass, config:TemplateConfig}[] = [];
|
|
86
87
|
private _package: string;
|
|
87
88
|
private _tags: string[] = [];
|
|
88
89
|
|
|
89
|
-
constructor(group:string, name:string, sourceFile:string, pkg:string){
|
|
90
|
+
constructor(group:string, id:string, name:string, sourceFile:string, pkg:string){
|
|
90
91
|
this._group = group;
|
|
92
|
+
this._id = id;
|
|
91
93
|
this._name = name;
|
|
92
94
|
this._sourceFile = sourceFile;
|
|
93
95
|
this._package = pkg;
|
|
@@ -114,6 +116,7 @@ export class NodeDescriptor {
|
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
public group(){ return this._group; }
|
|
119
|
+
public id(){ return this._id; }
|
|
117
120
|
public name(){ return this._name; }
|
|
118
121
|
public sourceFile() { return this._sourceFile; }
|
|
119
122
|
public package() { return this._package; }
|
|
@@ -857,7 +860,7 @@ let evalInContext = (context: any, js: string) => {
|
|
|
857
860
|
let buildNode = function(node:INodeClass){
|
|
858
861
|
// get the node descriptor and create the builder.
|
|
859
862
|
let nodeDescriptor = node.getNodeDescriptor();
|
|
860
|
-
let nodeBuilder = new NodeBuilder(nodeDescriptor.
|
|
863
|
+
let nodeBuilder = new NodeBuilder(nodeDescriptor.id(), nodeDescriptor.group());
|
|
861
864
|
|
|
862
865
|
// load the html source file
|
|
863
866
|
let uiDom = new JSDOM(fs.readFileSync(nodeDescriptor.sourceFile()));
|
|
@@ -873,7 +876,7 @@ let buildNode = function(node:INodeClass){
|
|
|
873
876
|
Object.values(sections).forEach(section => {
|
|
874
877
|
let sectionData = uiDom.window.document.querySelector(`[template-section='on${section}']`)?.innerHTML;
|
|
875
878
|
if(sectionData){
|
|
876
|
-
(nodeBuilder as any)[`add${section}`](nodeDescriptor.
|
|
879
|
+
(nodeBuilder as any)[`add${section}`](nodeDescriptor.id(), sectionData);
|
|
877
880
|
}
|
|
878
881
|
});
|
|
879
882
|
|
|
@@ -76,8 +76,8 @@ class NodeGenerator {
|
|
|
76
76
|
try{
|
|
77
77
|
// verify that we have dont already have this node.
|
|
78
78
|
let descriptor = node.getNodeDescriptor();
|
|
79
|
-
if(!this._nodes[descriptor.
|
|
80
|
-
this._nodes[descriptor.
|
|
79
|
+
if(!this._nodes[descriptor.id()]){
|
|
80
|
+
this._nodes[descriptor.id()] = {nodeClass:node, descriptor:descriptor};
|
|
81
81
|
// skip the recursive dependencies for now.
|
|
82
82
|
//descriptor.dependencies().forEach(dependency => this.addDependency(dependency));
|
|
83
83
|
}
|
|
@@ -117,7 +117,7 @@ class NodeGenerator {
|
|
|
117
117
|
// STEP 2. compose the HTMLStructure of each of the nodes.
|
|
118
118
|
let nodeHTMLOutut = Object.values(this._nodes)
|
|
119
119
|
.map(node => {
|
|
120
|
-
console.log(`Processing node: ${node.descriptor.
|
|
120
|
+
console.log(`Processing node: ${node.descriptor.id()}`);
|
|
121
121
|
|
|
122
122
|
return buildNode(node.nodeClass);
|
|
123
123
|
})
|
|
@@ -136,7 +136,7 @@ ${nodeHTMLOutut}
|
|
|
136
136
|
// 1. get a list of the files to import.
|
|
137
137
|
let importList = [
|
|
138
138
|
...Object.values(this._nodes).map(node => {
|
|
139
|
-
return `const ${node.descriptor.
|
|
139
|
+
return `const ${node.descriptor.id()} = require("${node.descriptor.package()}").${node.descriptor.id()};`;
|
|
140
140
|
//let nodeFile = "./" + node.group() + "/" + node.sourceFile();
|
|
141
141
|
//return `const ${node.name()} = require("${nodeFile}");`;
|
|
142
142
|
}),
|
|
@@ -145,7 +145,7 @@ ${nodeHTMLOutut}
|
|
|
145
145
|
|
|
146
146
|
// 2. get the exported modules that have to be regestered by the node manager.
|
|
147
147
|
let moduleExports = Object.values(this._nodes).map(node => {
|
|
148
|
-
return ` manager.registerNodeType("${node.descriptor.
|
|
148
|
+
return ` manager.registerNodeType("${node.descriptor.id()}", ${node.descriptor.id()});`;
|
|
149
149
|
}).join("\n");
|
|
150
150
|
|
|
151
151
|
fs.writeFileSync(nodesOutputFile + ".js", `
|
|
@@ -162,7 +162,7 @@ ${moduleExports}
|
|
|
162
162
|
|
|
163
163
|
`);
|
|
164
164
|
|
|
165
|
-
console.log(`Done building ${Object.keys(this._nodes).length} nodes\n${Object.values(this._nodes).map(node => " - " + node.descriptor.
|
|
165
|
+
console.log(`Done building ${Object.keys(this._nodes).length} nodes\n${Object.values(this._nodes).map(node => " - " + node.descriptor.id() + "\n").join("")}\n`);
|
|
166
166
|
|
|
167
167
|
let serviceExports = this._services.map(service => {
|
|
168
168
|
return ` manager.registerService(${service.name()}.${service.name()});`
|
|
@@ -243,10 +243,10 @@ module.exports = function (RED) {
|
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
private static generateHeader(node:NodeDescriptor){
|
|
246
|
-
let padding = ' '.repeat(Math.max(0, Math.floor(NodeGenerator.headerWidth - node.
|
|
246
|
+
let padding = ' '.repeat(Math.max(0, Math.floor(NodeGenerator.headerWidth - node.id().length)/2 ));
|
|
247
247
|
return `
|
|
248
248
|
<!-- *${'*'.repeat(NodeGenerator.headerWidth)}* -->
|
|
249
|
-
<!-- ${padding} ${node.
|
|
249
|
+
<!-- ${padding} ${node.id()} ${padding} -->
|
|
250
250
|
<!-- *${'*'.repeat(NodeGenerator.headerWidth)}* -->
|
|
251
251
|
`;
|
|
252
252
|
}
|
|
@@ -46,86 +46,45 @@
|
|
|
46
46
|
<script type="text/html" template-section="onIncludeEditForm">
|
|
47
47
|
<div id="LoggerConfig">
|
|
48
48
|
<div class="form-row">
|
|
49
|
-
<label for="node-config-input-name"><i class="fa fa-
|
|
49
|
+
<label class="towb_editorlabel" for="node-config-input-name"><i class="fa fa-font"></i> Name</label>
|
|
50
50
|
<input type="text" id="node-config-input-name" />
|
|
51
51
|
</div>
|
|
52
52
|
|
|
53
53
|
<div class="form-row">
|
|
54
|
-
<label for="node-config-input-level"><i class="fa fa-
|
|
54
|
+
<label class="towb_editorlabel" for="node-config-input-level"><i class="fa fa-signal"></i> Level</label>
|
|
55
55
|
<input type="text" id="node-config-input-level" />
|
|
56
56
|
</div>
|
|
57
57
|
|
|
58
58
|
<div class="form-row">
|
|
59
|
-
<label for="node-config-input-templateEditor"><i class="fa fa-
|
|
59
|
+
<label class="towb_editorlabel" for="node-config-input-templateEditor"><i class="fa fa-code"></i> Template</label>
|
|
60
60
|
<div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-config-input-templateEditor"></div>
|
|
61
61
|
</div>
|
|
62
62
|
</div>
|
|
63
63
|
</script>
|
|
64
64
|
|
|
65
65
|
<script type="text/markdown" template-section="onIncludeDocumentation">
|
|
66
|
-
|
|
66
|
+
Writes log output to the Node-RED runtime console (stdout). Suitable for local development and containerised environments where stdout is captured.
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
: *name*
|
|
70
|
-
: *level*
|
|
71
|
-
: *
|
|
72
|
-
: *template*(mustache) : A template for the log messages.
|
|
68
|
+
### Properties
|
|
69
|
+
: *name* (string) : A descriptive name for this logger configuration.
|
|
70
|
+
: *level* (level) : The minimum log level. Messages below this threshold are suppressed. Options: DEBUG, INFO, WARNING, ERROR.
|
|
71
|
+
: *template* (mustache) : A Mustache/Handlebars template that formats the log message body.
|
|
73
72
|
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
### Mustache Templating
|
|
74
|
+
Mustache/Handlebars templates build the message string written to the console.
|
|
76
75
|
|
|
77
|
-
|
|
78
|
-
The
|
|
76
|
+
#### Provided Properties
|
|
77
|
+
: *msg* (object) : The Node-RED message object passed through the node.
|
|
78
|
+
: *currentTime* (string) : The current time in ISO 8601 format.
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
#### Helpers
|
|
81
|
+
: *json* (helper) : Serialises an object to a JSON string using `JSON.stringify`.
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
: *authentication* (auth method) : what auth method should be used for the http request. (none, basic, api key)
|
|
83
|
+
#### Examples
|
|
84
|
+
- `{{{json msg}}}` — serialises the full message object as JSON.
|
|
86
85
|
|
|
87
|
-
####
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
: *username* (string) : the username used for basic authentication
|
|
92
|
-
: *password* (string) : the password used for basic authentication
|
|
93
|
-
|
|
94
|
-
##### APIKey
|
|
95
|
-
Provides authentication using a matrix parameter, header or query parameter and an apikey
|
|
96
|
-
|
|
97
|
-
: *mechanism* (mechanism) : the mechanism that will be used for transmitting the key (header, queryparam, matrixparam)
|
|
98
|
-
: *apikey name* (string) : the name of the key used for api authentication. (path variable or query param name)
|
|
99
|
-
: *apikey value*(string) : the value of the api key that will be transmitted. (beware of special characters)
|
|
100
|
-
|
|
101
|
-
### Loki
|
|
102
|
-
Publish the message to a loki endpoint.
|
|
103
|
-
|
|
104
|
-
: *host* (string) : the host and port\ of the loki instance that it being logged to
|
|
105
|
-
: *tenant* (string) : the tenant id that will be used to log to
|
|
106
|
-
: *username* (string) : the username for the loki instance.
|
|
107
|
-
: *authtoken* (string) : the authtoken for the loki instance.
|
|
108
|
-
|
|
109
|
-
# Mustache Templating
|
|
110
|
-
Mustache / Handlebars are used for building up the logged message payloads that are sent to the logging backend.
|
|
111
|
-
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.
|
|
112
|
-
|
|
113
|
-
### Provided Properties
|
|
114
|
-
A couple of values are provided to the logging context by default.
|
|
115
|
-
|
|
116
|
-
: *msg* (object) : an object containing the payload or message that should be parsed through the template.
|
|
117
|
-
: *currentTime* (object) : a string containing the current time in ISO8601 format
|
|
118
|
-
|
|
119
|
-
### Mustache Helpers
|
|
120
|
-
In addition to the provided properties, some "helpers" have also been provided to assist in serialization.
|
|
121
|
-
|
|
122
|
-
: *json* (helper) : converts a json object to a string using the JSON.stringify method.
|
|
123
|
-
|
|
124
|
-
## Examples
|
|
125
|
-
- {{{json msg}}} - serializes the the msg object to json format.
|
|
126
|
-
|
|
127
|
-
# References
|
|
128
|
-
- [Mustache - Wikipedia](https://en.wikipedia.org/wiki/Mustache_(template_system))
|
|
129
|
-
- [Mustache - Playground](https://jgonggrijp.gitlab.io/wontache/playground.html)
|
|
86
|
+
#### References
|
|
87
|
+
- [Mustache — Wikipedia](https://en.wikipedia.org/wiki/Mustache_(template_system))
|
|
88
|
+
- [Mustache — Playground](https://jgonggrijp.gitlab.io/wontache/playground.html)
|
|
130
89
|
</script>
|
|
131
90
|
|