@bonsae/node-red-salesforce 0.5.0 → 0.6.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
@@ -94,29 +94,71 @@ Call existing Apex endpoints deployed in your Salesforce org. Select the type (R
94
94
 
95
95
  ### Apex Code
96
96
 
97
- Deploy and execute custom Apex code directly from Node-RED. Select the type (Invocable or REST), enter a class name, and write your Apex method body in the built-in code editor. The node automatically deploys the class to Salesforce on Node-RED deploy and removes it when the node is deleted.
97
+ Deploy and execute custom Apex code directly from Node-RED. Select the type (Invocable Method or REST Resource), enter a class name, and write your Apex code in the built-in editor. The node automatically deploys the class to Salesforce on Node-RED deploy and removes it when the node is deleted.
98
98
 
99
- Your code receives the input as a `payload` string and returns any value:
99
+ You write the `run()` method and any helper methods or inner classes. The node wraps your code in the required Salesforce boilerplate (annotations, Input/Output classes, etc.):
100
100
 
101
101
  ```apex
102
- // Invocable example
103
- Map<String, Object> data = (Map<String, Object>) JSON.deserializeUntyped(payload);
104
- String name = (String) data.get('name');
105
- return 'Hello, ' + name + '!';
102
+ private static Object run(String payload) {
103
+ Map<String, Object> data = (Map<String, Object>) JSON.deserializeUntyped(payload);
104
+ String name = (String) data.get('name');
105
+ return 'Hello, ' + name + '!';
106
+ }
106
107
  ```
107
108
 
109
+ You can add helper methods and inner classes alongside `run()`:
110
+
108
111
  ```apex
109
- // REST example
110
- return new Map<String, Object>{ 'message' => 'Received: ' + payload };
112
+ private static Object run(String payload) {
113
+ Processor p = new Processor();
114
+ return p.process(payload);
115
+ }
116
+
117
+ public class Processor {
118
+ public String process(String input) {
119
+ return input.reverse();
120
+ }
121
+ }
111
122
  ```
112
123
 
113
- The class name prefix defaults to `NRG_` and can be overridden in `settings.js`:
124
+ The class name prefix defaults to `NRG_` and can be overridden in Node-RED `settings.js`:
114
125
 
115
126
  ```javascript
116
127
  salesforceApexCodeClassPrefix: "MY_"
117
128
  ```
118
129
 
119
- For REST mode, you also configure the URL mapping (e.g., `/my/endpoint/*`).
130
+ For REST Resource mode, you also configure the URL mapping (e.g., `/my/endpoint/*`) and HTTP method.
131
+
132
+ #### Apex Language Server (optional)
133
+
134
+ The Apex Code editor supports an optional Language Server that provides autocompletions, hover documentation, signature help, diagnostics, and SObject field completions from your connected org.
135
+
136
+ **Prerequisites**: Java 11+
137
+
138
+ **Setup**:
139
+
140
+ ```bash
141
+ # 1. Download the Apex Language Server JAR (one-time)
142
+ chmod +x scripts/setup-apex-lsp.sh
143
+ ./scripts/setup-apex-lsp.sh
144
+
145
+ # 2. Start the WebSocket bridge
146
+ node scripts/apex-lsp-server.mjs
147
+ ```
148
+
149
+ **Configure** in Node-RED `settings.js`:
150
+
151
+ ```javascript
152
+ salesforceApexCodeLanguageServerUrl: "ws://localhost:3001"
153
+ ```
154
+
155
+ The bridge spawns a Java LSP process per editor session and creates a temporary SFDX workspace for type resolution. SObject definitions are fetched from the connected org and cached for 30 minutes.
156
+
157
+ The bridge accepts `--port` and `--jar` flags:
158
+
159
+ ```bash
160
+ node scripts/apex-lsp-server.mjs --port 3002 --jar /path/to/apex-jorje-lsp.jar
161
+ ```
120
162
 
121
163
  ## Development
122
164
 
package/index.d.ts CHANGED
@@ -104,6 +104,7 @@ payload: TAny;
104
104
 
105
105
  export declare const SalesforceApexCodeSettingsSchema: Schema< {
106
106
  classPrefix: TString;
107
+ languageServerUrl: TString;
107
108
  }>;
108
109
 
109
110
  export declare class SalesforceApexInvocation extends IONode<Config_3, any, Input_2, Output_2> {
package/index.html CHANGED
@@ -63,4 +63,5 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
63
63
  LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK.
64
64
 
65
65
  -->
66
- <script type="module" src="resources/@bonsae/node-red-salesforce/index.dnWzY-T-.js" defer></script>
66
+ <script type="module" src="resources/@bonsae/node-red-salesforce/index.C1dzx4s2.js" defer></script>
67
+ <link rel="stylesheet" href="resources/@bonsae/node-red-salesforce/index.zXteTlSH.css">