@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
package/README.md
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
# @theotherwillembotha/node-red-plugincore
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A TypeScript framework for building production-grade Node-RED plugins with built-in support for structured logging, Prometheus metrics, and webhook servers.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This package has two roles:
|
|
6
|
+
|
|
7
|
+
1. **Config nodes** — a set of shared configuration nodes (loggers, metric collectors, webhook server) that are installed into Node-RED and referenced by other nodes in a flow.
|
|
8
|
+
2. **Developer framework** — a TypeScript base library that plugin authors extend to build their own Node-RED nodes, with decorators and templates that wire in logging, metrics, and webhooks automatically.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Plugin ecosystem
|
|
13
|
+
|
|
14
|
+
This framework is the foundation for a growing set of Node-RED plugins. The following plugins are currently available:
|
|
15
|
+
|
|
16
|
+
| Plugin | Description |
|
|
17
|
+
|--------|-------------|
|
|
18
|
+
| [@theotherwillembotha/node-red-telemetry](https://github.com/theotherwillembotha/nodered_telemetry) | Ready-to-use flow nodes for structured logging and Prometheus metrics — Logger, Counter, Gauge, and Timer nodes that attach to the config nodes provided by this package. |
|
|
19
|
+
|
|
20
|
+
Additional plugins will be listed here as they are published.
|
|
6
21
|
|
|
7
22
|
---
|
|
8
23
|
|
|
@@ -10,41 +25,57 @@ A core framework for building production-grade Node-RED plugins, with built-in s
|
|
|
10
25
|
|
|
11
26
|
### Installation
|
|
12
27
|
|
|
13
|
-
Either use the **Manage Palette** option in the Node-RED editor, or run the following
|
|
28
|
+
Either use the **Manage Palette** option in the Node-RED editor, or run the following in your Node-RED user directory (typically `~/.node-red`):
|
|
14
29
|
|
|
15
30
|
```bash
|
|
16
31
|
npm install @theotherwillembotha/node-red-plugincore
|
|
17
32
|
```
|
|
18
33
|
|
|
34
|
+
This installs the config nodes below and makes them available in your palette. Typically you would also install a plugin such as [node-red-telemetry](https://github.com/theotherwillembotha/nodered_telemetry) to get the actual flow nodes that reference them.
|
|
35
|
+
|
|
19
36
|
### Config nodes
|
|
20
37
|
|
|
21
|
-
|
|
38
|
+
Config nodes are shared resources configured once and referenced across your flow. They appear under their own groups in the palette sidebar.
|
|
22
39
|
|
|
23
40
|
#### Logging
|
|
24
41
|
|
|
25
|
-
Three logger
|
|
42
|
+
Three logger backends are supported. All expose the same interface and are interchangeable — any node built with the `@Logger` decorator can use any of them.
|
|
26
43
|
|
|
27
44
|
| Node | Description |
|
|
28
45
|
|------|-------------|
|
|
29
|
-
| **Console Logger** | Writes log output to stdout via Winston.
|
|
30
|
-
| **REST Logger** | Ships log entries to a remote HTTP endpoint. |
|
|
31
|
-
| **Loki Logger** |
|
|
46
|
+
| **Console Logger** | Writes structured log output to stdout via Winston. Ideal for development and containerised deployments that forward stdout to a log aggregator. |
|
|
47
|
+
| **REST Logger** | Ships log entries to a remote HTTP/HTTPS endpoint. Supports Basic and API Key authentication. |
|
|
48
|
+
| **Loki Logger** | Pushes log entries to a Grafana Loki instance via the Loki HTTP API. Supports multi-tenant deployments. |
|
|
32
49
|
|
|
33
50
|
#### Metrics
|
|
34
51
|
|
|
35
|
-
Prometheus-compatible metric collectors. A
|
|
52
|
+
Prometheus-compatible metric collectors. A scrape endpoint (`/metrics`) is provided automatically once any metric node is deployed.
|
|
36
53
|
|
|
37
54
|
| Node | Description |
|
|
38
55
|
|------|-------------|
|
|
56
|
+
| **Metrics Config** | Top-level Prometheus registry. One per deployment. |
|
|
39
57
|
| **Counter Metric** | An ever-increasing counter (e.g. messages processed, errors). |
|
|
40
58
|
| **Gauge Metric** | A value that goes up and down (e.g. queue depth, active connections). |
|
|
41
|
-
| **Timer Metric** | A histogram for measuring durations (e.g. processing time per message). |
|
|
59
|
+
| **Timer Metric** | A histogram or summary for measuring durations (e.g. processing time per message). |
|
|
60
|
+
|
|
61
|
+

|
|
62
|
+
|
|
63
|
+
**Counter** and **Gauge** share the same layout — a name, a description, and an optional reset-on-deploy toggle:
|
|
64
|
+
|
|
65
|
+

|
|
66
|
+

|
|
67
|
+
|
|
68
|
+
The **Timer** config adds a metric type selector (Histogram or Summary) with configurable bucket or percentile strategies:
|
|
69
|
+
|
|
70
|
+

|
|
42
71
|
|
|
43
72
|
#### Webhook Server
|
|
44
73
|
|
|
45
74
|
| Node | Description |
|
|
46
75
|
|------|-------------|
|
|
47
|
-
| **Webhook Server** | Runs an Express v5 HTTP server on a configurable port. Supports reverse proxy configuration
|
|
76
|
+
| **Webhook Server** | Runs an Express v5 HTTP server on a configurable local port. Supports optional reverse proxy configuration so that registered webhook paths know their publicly-visible address. |
|
|
77
|
+
|
|
78
|
+

|
|
48
79
|
|
|
49
80
|
---
|
|
50
81
|
|
|
@@ -53,7 +84,7 @@ Prometheus-compatible metric collectors. A running Prometheus scrape endpoint is
|
|
|
53
84
|
### Prerequisites
|
|
54
85
|
|
|
55
86
|
- Node.js 18+
|
|
56
|
-
- Node-RED
|
|
87
|
+
- Node-RED 4+
|
|
57
88
|
- TypeScript 5+ with `experimentalDecorators` and `emitDecoratorMetadata` enabled
|
|
58
89
|
|
|
59
90
|
### Installation
|
|
@@ -75,7 +106,7 @@ Your `tsconfig.json` must include:
|
|
|
75
106
|
|
|
76
107
|
### Defining a node
|
|
77
108
|
|
|
78
|
-
Extend `BaseNode` and annotate the class with `@NodeDescription`. The decorator registers the node type, its editor HTML file, the palette group it appears in, and any shared templates it
|
|
109
|
+
Extend `BaseNode` (or `ConfigNode` for config nodes) and annotate the class with `@NodeDescription`. The decorator registers the node type, its editor HTML file, the palette group it appears in, and any shared templates it composes in.
|
|
79
110
|
|
|
80
111
|
```typescript
|
|
81
112
|
import {
|
|
@@ -115,30 +146,35 @@ class MyNode extends BaseNode<MyNodeConfig> {
|
|
|
115
146
|
}
|
|
116
147
|
```
|
|
117
148
|
|
|
149
|
+
The `LoggerTemplate` fragment is automatically composed into the node's editor panel, giving the user a logger selector and optional message template override with no additional HTML required.
|
|
150
|
+
|
|
118
151
|
### Available decorators
|
|
119
152
|
|
|
120
153
|
| Decorator | Property type | What it injects |
|
|
121
154
|
|-----------|--------------|-----------------|
|
|
122
155
|
| `@Logger()` | `Log` | Winston logger wired to a user-selected logger config node |
|
|
123
156
|
| `@Metrics({...})` | `CounterMetric` / `GaugeMetric` / `HistogramMetric` | Prometheus metric collector |
|
|
124
|
-
| `@Webhook()` | — | Registers the node with the webhook server |
|
|
125
|
-
| `@onInput()` | method | Wires the method as the Node-RED input message handler |
|
|
157
|
+
| `@Webhook()` | — | Registers the node's routes with the webhook server |
|
|
158
|
+
| `@onInput()` | method | Wires the method as the Node-RED `input` message handler |
|
|
126
159
|
|
|
127
160
|
### Templates
|
|
128
161
|
|
|
129
|
-
Templates bundle reusable UI fragments that compose into any node's editor panel.
|
|
162
|
+
Templates bundle reusable UI fragments that compose into any node's editor panel. Include them in the `templates` array of `@NodeDescription`.
|
|
130
163
|
|
|
131
164
|
| Template | Adds to editor |
|
|
132
165
|
|----------|---------------|
|
|
133
|
-
| `LoggerTemplate` | Logger
|
|
134
|
-
| `MetricsTemplate` | Metrics
|
|
135
|
-
| `
|
|
166
|
+
| `LoggerTemplate` | Logger backend selector and optional message template override |
|
|
167
|
+
| `MetricsTemplate` | Metrics enable toggle and collector reference |
|
|
168
|
+
| `CounterMetricTemplate` | Counter config node reference |
|
|
169
|
+
| `GaugeMetricTemplate` | Gauge config node reference |
|
|
170
|
+
| `TimerMetricTemplate` | Timer config node reference |
|
|
171
|
+
| `WebhookTemplate` | Webhook server reference, path, auth, and reverse proxy config |
|
|
136
172
|
| `SettingsTemplate` | General settings section |
|
|
137
173
|
| `BasicTemplate` | Base styles shared by all nodes |
|
|
138
174
|
|
|
139
175
|
### Registering nodes for generation
|
|
140
176
|
|
|
141
|
-
Create a `GenerateNodes.ts` at the root of your `src/` directory. This is the composition root — register every service, template, and node, then call `.generate()` to emit the Node-RED entry files.
|
|
177
|
+
Create a `GenerateNodes.ts` at the root of your `src/` directory. This is the composition root — register every service, template, and node, then call `.generate()` to emit the two Node-RED entry files (`Nodes.js` and `Plugins.js`).
|
|
142
178
|
|
|
143
179
|
```typescript
|
|
144
180
|
import { NodeGenerator } from "@theotherwillembotha/node-red-plugincore";
|
|
@@ -160,11 +196,14 @@ new NodeGenerator("./src/")
|
|
|
160
196
|
process.exit(0);
|
|
161
197
|
```
|
|
162
198
|
|
|
199
|
+
Only register the services and config nodes your plugin actually depends on. You do not need to re-register nodes from this package if your plugin does not expose them directly.
|
|
200
|
+
|
|
163
201
|
### Wiring up package.json
|
|
164
202
|
|
|
165
203
|
```json
|
|
166
204
|
{
|
|
167
205
|
"node-red": {
|
|
206
|
+
"version": ">=4.0.0",
|
|
168
207
|
"nodes": { "my-plugin": "./build/Nodes.js" },
|
|
169
208
|
"plugins": { "my-plugin": "./build/Plugins.js" }
|
|
170
209
|
}
|
|
@@ -174,7 +213,7 @@ process.exit(0);
|
|
|
174
213
|
### Build
|
|
175
214
|
|
|
176
215
|
```bash
|
|
177
|
-
npm run build # clean → tsc →
|
|
216
|
+
npm run build # clean → tsc → generate node files → copy icons
|
|
178
217
|
npm run clean # remove build/
|
|
179
218
|
```
|
|
180
219
|
|
package/build/GenerateNodes.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const DelegatedConfigReferenceNode_js_1 = require("./core/other/node/DelegatedConfigReferenceNode.js");
|
|
3
4
|
const NodeTypeService_js_1 = require("./core/tagging/service/NodeTypeService.js");
|
|
4
5
|
const index_js_1 = require("./index.js");
|
|
5
6
|
const index_js_2 = require("./index.js");
|
|
@@ -23,6 +24,7 @@ new index_js_1.NodeGenerator("./src/core/")
|
|
|
23
24
|
.registerTemplate(index_js_1.TimerMetricTemplate)
|
|
24
25
|
.registerTemplate(index_js_2.WebhookTemplate)
|
|
25
26
|
// nodes
|
|
27
|
+
.registerNode(DelegatedConfigReferenceNode_js_1.DelegatedConfigReferenceNode)
|
|
26
28
|
.registerNode(index_js_1.ConsoleLoggerConfigNode)
|
|
27
29
|
.registerNode(index_js_1.RestLoggerConfigNode)
|
|
28
30
|
.registerNode(index_js_1.LokiLoggerConfigNode)
|