@bonsae/nrg 0.10.0 → 0.11.0

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 CHANGED
@@ -155,6 +155,9 @@ src/
155
155
  │ │ └── index.ts # registerTypes, exports
156
156
  │ ├── constants.ts
157
157
  │ └── validator.ts # AJV-based validation
158
+ ├── test/ # Test utilities for consumers
159
+ │ ├── index.ts # createNode, receive, close, reset
160
+ │ └── mocks.ts # RED and Node-RED node mocks
158
161
  ├── vite/ # Build tooling
159
162
  │ ├── plugin.ts # Vite plugin factory
160
163
  │ ├── plugins/ # Dev server, build orchestration
@@ -167,6 +170,37 @@ src/
167
170
  └── server.json
168
171
  ```
169
172
 
173
+ ## Testing
174
+
175
+ Test your nodes' server-side logic with `@bonsae/nrg/test`:
176
+
177
+ ```bash
178
+ pnpm add -D vitest
179
+ ```
180
+
181
+ ```typescript
182
+ // tests/my-node.test.ts
183
+ import { describe, it, expect } from "vitest";
184
+ import { createNode } from "@bonsae/nrg/test";
185
+ import MyNode from "../src/server/nodes/my-node";
186
+
187
+ describe("my-node", () => {
188
+ it("should process messages", async () => {
189
+ const { node } = await createNode(MyNode, {
190
+ config: { greeting: "hello" },
191
+ });
192
+
193
+ await node.receive({ payload: "world" });
194
+
195
+ expect(node.sent(0)).toEqual([{ payload: "hello world" }]);
196
+ });
197
+ });
198
+ ```
199
+
200
+ ```bash
201
+ npx vitest run
202
+ ```
203
+
170
204
  ## Development
171
205
 
172
206
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonsae/nrg",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "NRG framework — build Node-RED nodes with Vue 3, TypeScript, and JSON Schema",
5
5
  "author": "Allan Oricil <allanoricil@duck.com>",
6
6
  "license": "MIT",
@@ -14,10 +14,23 @@
14
14
  "type": "string",
15
15
  "description": "Display name shown in the palette and workspace"
16
16
  },
17
+ "paletteLabel": {
18
+ "type": "string",
19
+ "description": "Label shown in the palette. Falls back to 'label' if not set."
20
+ },
17
21
  "description": {
18
22
  "type": "string",
19
23
  "description": "Node description for this language. Overrides the class-level description in auto-generated help docs."
20
24
  },
25
+ "inputLabels": {
26
+ "type": "string",
27
+ "description": "Label for the input port."
28
+ },
29
+ "outputLabels": {
30
+ "type": "array",
31
+ "items": { "type": "string" },
32
+ "description": "Labels for output ports, one per port."
33
+ },
21
34
  "configs": {
22
35
  "$ref": "#/$defs/labelMap",
23
36
  "description": "Labels for config properties"
package/server/index.cjs CHANGED
@@ -39,6 +39,7 @@ __export(index_exports, {
39
39
  defineIONode: () => defineIONode,
40
40
  defineModule: () => defineModule,
41
41
  defineSchema: () => defineSchema,
42
+ initValidator: () => initValidator,
42
43
  registerType: () => registerType,
43
44
  registerTypes: () => registerTypes
44
45
  });
@@ -530,12 +531,8 @@ var Node = class {
530
531
  var IONode = class extends Node {
531
532
  static align;
532
533
  static color;
533
- static labelStyle;
534
- static paletteLabel;
535
534
  static inputs = 0;
536
535
  static outputs = 0;
537
- static inputLabels;
538
- static outputLabels;
539
536
  static inputSchema;
540
537
  static outputsSchema;
541
538
  static validateInput = false;
@@ -688,11 +685,7 @@ function defineIONode(def) {
688
685
  static color = def.color ?? "#a6bbcf";
689
686
  static inputs = def.inputs ?? 1;
690
687
  static outputs = def.outputs ?? 1;
691
- static paletteLabel = def.paletteLabel;
692
- static inputLabels = def.inputLabels;
693
- static outputLabels = def.outputLabels;
694
688
  static align = def.align;
695
- static labelStyle = def.labelStyle;
696
689
  static configSchema = def.configSchema;
697
690
  static credentialsSchema = def.credentialsSchema;
698
691
  static settingsSchema = def.settingsSchema;
@@ -1043,6 +1036,7 @@ function defineModule(definition) {
1043
1036
  defineIONode,
1044
1037
  defineModule,
1045
1038
  defineSchema,
1039
+ initValidator,
1046
1040
  registerType,
1047
1041
  registerTypes
1048
1042
  });