Pārlūkot izejas kodu

fix: Template's multi-line description, required marker, and input-mode error

Collapse the @description JSDoc to a single line since the node_store.cpp
parser only captures the first line of a multi-line description. Restore
required: ['template'] in configSchema so the editor still shows the
required-field marker in the default config mode. Throw a clear error when
templateSource is 'input' but templateField is unset, instead of leaking
"undefined" into the error message. Document the single-line @description
constraint in docs/nodes.md.
fszontagh 1 mēnesi atpakaļ
vecāks
revīzija
95bab5bd97
2 mainītis faili ar 7 papildinājumiem un 7 dzēšanām
  1. 1 1
      docs/nodes.md
  2. 6 6
      nodes/core/template.js

+ 1 - 1
docs/nodes.md

@@ -80,7 +80,7 @@ The comment block at the top of the file defines node metadata:
 | `@name` | Yes | Display name shown in UI |
 | `@category` | Yes | Category for grouping (e.g., `http`, `data`, `email`) |
 | `@version` | Yes | Semantic version (e.g., `1.0.0`) |
-| `@description` | Yes | Brief description of node functionality |
+| `@description` | Yes | Brief description of node functionality. Must be a single line - the parser captures only the first line of a multi-line `@description` |
 | `@icon` | No | Lucide icon name (e.g., `globe`, `mail`, `database`) |
 | `@trigger` | No | Add this tag if the node is a trigger (starts workflows) |
 

+ 6 - 6
nodes/core/template.js

@@ -3,11 +3,7 @@
  * @name Template
  * @category data
  * @version 1.0.0
- * @description Render text from a template. In "config" mode the {{...}} placeholders in the
- * template are already resolved by the engine before this node runs, so rendering only catches
- * whatever the engine could not fill in. In "input" mode the template text is read from the
- * input data at run time, where its {{...}} placeholders are still intact, and this node
- * renders them against the input.
+ * @description Render text from a template, either typed into the config or read from the input data at run time
  * @icon file-text
  */
 
@@ -38,7 +34,8 @@ const configSchema = {
             title: 'Output Field',
             default: 'text'
         }
-    }
+    },
+    required: ['template']
 };
 
 const inputSchema = {
@@ -62,6 +59,9 @@ async function execute(config, input, context) {
     let template;
     if (templateSource === 'input') {
         const templateField = config.templateField;
+        if (!templateField) {
+            throw new Error('Template: Template Field must be set when the template comes from the input');
+        }
         template = smartbotic.utils.getFieldValue(input, templateField);
         if (typeof template !== 'string' || template === '') {
             throw new Error('Template: no template text found at "' + templateField + '"');