@bonsae/nrg-runtime 0.23.0 → 0.25.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonsae/nrg-runtime",
3
- "version": "0.23.0",
3
+ "version": "0.25.0",
4
4
  "description": "Runtime for Node-RED nodes built with @bonsae/nrg — no build tooling.",
5
5
  "author": "Allan Oricil <allanoricil@duck.com>",
6
6
  "license": "MIT",
package/server/index.cjs CHANGED
@@ -578,9 +578,10 @@ var IONode = class extends Node {
578
578
  try {
579
579
  nodeRedNode.log("Calling input");
580
580
  this.#currentInputMsg = msg;
581
- await Promise.resolve(this.#input(msg, send));
581
+ const result = await this.#input(msg, send);
582
582
  this.#sendToPort("complete", {
583
583
  ...msg,
584
+ ...result !== void 0 ? { output: result } : {},
584
585
  complete: {
585
586
  source: this.#nodeSource()
586
587
  },
@@ -590,9 +591,12 @@ var IONode = class extends Node {
590
591
  nodeRedNode.log("Input processed");
591
592
  } catch (error) {
592
593
  const errorMsg = error instanceof Error ? error.message : "Unknown error during input handling";
594
+ const errorData = error && typeof error === "object" ? { ...error } : {};
593
595
  this.#sendToPort("error", {
594
596
  ...msg,
595
597
  error: {
598
+ ...errorData,
599
+ name: error?.name ?? "Error",
596
600
  message: errorMsg,
597
601
  source: this.#nodeSource()
598
602
  },
@@ -616,6 +620,7 @@ var IONode = class extends Node {
616
620
  );
617
621
  }
618
622
  input(msg) {
623
+ return void 0;
619
624
  }
620
625
  async #input(msg, send) {
621
626
  const NodeClass = this.constructor;
@@ -630,7 +635,7 @@ var IONode = class extends Node {
630
635
  }
631
636
  this.#send = send;
632
637
  try {
633
- await Promise.resolve(this.input(msg));
638
+ return await Promise.resolve(this.input(msg));
634
639
  } finally {
635
640
  this.#send = void 0;
636
641
  }
package/types/server.d.ts CHANGED
@@ -727,7 +727,7 @@ export declare abstract class IONode<TConfig = any, TCredentials = any, TInput =
727
727
  protected readonly context: IONodeContext;
728
728
  constructor(RED: RED, node: NodeRedNode, config: IONodeConfig<TConfig>, credentials: IONodeCredentials<TCredentials>);
729
729
  [WIRE_HANDLERS](nodeRedNode: NodeRedNode, createdPromise: Promise<void>): void;
730
- input(msg: TInput): void | Promise<void>;
730
+ input(msg: TInput): unknown;
731
731
  send(msg: TOutput): void;
732
732
  get baseOutputs(): number;
733
733
  get totalOutputs(): number;
@@ -787,7 +787,7 @@ export interface IIONode<TConfig = any, TCredentials = any, TInput = any, TOutpu
787
787
  readonly y: number;
788
788
  readonly g: string | undefined;
789
789
  readonly wires: string[][];
790
- input(msg: TInput): void | Promise<void>;
790
+ input(msg: TInput): unknown;
791
791
  send(msg: TOutput): void;
792
792
  status(status: IONodeStatus): void;
793
793
  updateWires(wires: string[][]): void;
@@ -811,7 +811,7 @@ interface IONodeDefinition<TConfigSchema extends TSchema | undefined = undefined
811
811
  registered?(RED: RED): void | Promise<void>;
812
812
  created?(this: BoundIONode<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>): void | Promise<void>;
813
813
  closed?(this: BoundIONode<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>, removed?: boolean): void | Promise<void>;
814
- input?(this: BoundIONode<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>, msg: InferOr<TInputSchema, any>): void | Promise<void>;
814
+ input?(this: BoundIONode<TConfigSchema, TCredsSchema, TSettingsSchema, TInputSchema, TOutputsSchema>, msg: InferOr<TInputSchema, any>): unknown;
815
815
  }
816
816
  /**
817
817
  * Base class for configuration nodes that are shared across multiple nodes