@5minds/node-red-contrib-processcube 1.15.0-develop-8bd107-mai2rzad → 1.15.0-fix-waiting-for-usertask-a05829-manzzxtm

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": "@5minds/node-red-contrib-processcube",
3
- "version": "1.15.0-develop-8bd107-mai2rzad",
3
+ "version": "1.15.0-fix-waiting-for-usertask-a05829-manzzxtm",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "scripts": {
@@ -27,20 +27,109 @@
27
27
  </script>
28
28
 
29
29
  <script type="text/markdown" data-help-name="processcube-google-docs-mail-template">
30
- Download the zip folder from the link and include the Images with cid-Tags.
31
- Replace the field {{field}} or ///field/// with the content from the payload.
30
+ # Email Template Renderer (with Google Drive/Docs Support)
31
+
32
+ This Node-RED template module downloads a ZIP archive from a URL, extracts an HTML file and embedded images, replaces placeholders, and prepares the HTML content with inline attachments (CID) for email delivery.
33
+
34
+ ## Google Drive / Docs Link Support
35
+
36
+ The ZIP file must be publicly accessible via a **shared Google Drive link** (at least “Anyone with the link can view”). The following link formats are supported:
37
+
38
+ ```js
39
+ // Format 0: Google Docs (export as ZIP)
40
+ const editMatch = link.match(/https:\/\/docs\.google\.com\/document\/d\/([^/]+)/);
41
+ if (editMatch) {
42
+ const fileId = editMatch[1];
43
+ return `https://docs.google.com/document/d/${fileId}/export?format=zip`;
44
+ }
45
+
46
+ // Format 1: Google Drive – shared file
47
+ const fileMatch = link.match(/https:\/\/drive\.google\.com\/file\/d\/([^/]+)\/view/);
48
+ if (fileMatch) {
49
+ return `https://drive.google.com/uc?export=download&id=${fileMatch[1]}`;
50
+ }
51
+
52
+ // Format 2: Google Drive – open by ID
53
+ const openMatch = link.match(/https:\/\/drive\.google\.com\/open\?id=([^&]+)/);
54
+ if (openMatch) {
55
+ return `https://drive.google.com/uc?export=download&id=${openMatch[1]}`;
56
+ }
57
+ ```
58
+
59
+ > Make sure that the file is shared with one of these formats and publicly accessible.
60
+
61
+ ---
62
+
63
+ ## Processing Steps
64
+
65
+ 1. **Download** the ZIP archive from the URL.
66
+ 2. **Extract** the contents (expects one HTML file in the root directory).
67
+ 3. **Embed images**: All images referenced in `images/` will be replaced with `cid:` links.
68
+ 4. **Replace placeholders** in the following formats:
69
+ - `{{field}}`
70
+ - `///field///`
71
+ 5. **Output**:
72
+ - rendered HTML string
73
+ - `msg.attachments[]` containing Nodemailer-compatible inline files
74
+
75
+ ---
32
76
 
33
77
  ## Inputs
34
78
 
35
- : payload (json): Field for replace within the template ({{field}} or ///field///).
79
+ ### `payload` (JSON)
80
+
81
+ Fields for placeholder replacement. Example:
82
+
83
+ ```json
84
+ {
85
+ "user_name": "Martin",
86
+ "newsletter_date": "May 5, 2025",
87
+ "announcement": "Our new album will be released soon!"
88
+ }
89
+ ```
90
+
91
+ Used to replace `{{user_name}}` or `///user_name///` in the HTML template.
92
+
93
+ ---
36
94
 
37
95
  ## Outputs
38
96
 
39
- : payload (str): The renderted template.
40
- : attachments (array): The attachments of the email.
97
+ ### `payload` (String)
98
+
99
+ The rendered HTML content with embedded CID references and replaced placeholders.
100
+
101
+ ### `attachments` (Array)
102
+
103
+ Array of objects like:
104
+
105
+ ```json
106
+ {
107
+ "filename": "image1.png",
108
+ "path": "/path/to/file/image1.png",
109
+ "cid": "image1"
110
+ }
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Example
116
+
117
+ ```text
118
+ &lt;p&gt;Hello &#123;&#123;user_name&#125;&#125;,&lt;/p&gt;
119
+ &lt;img src=&quot;images/image1.png&quot;&gt;
120
+ ```
121
+
122
+ Becomes:
123
+
124
+ ```text
125
+ &lt;p&gt;Hello Martin,&lt;/p&gt;
126
+ &lt;img src=&quot;cid:image1&quot;&gt;
127
+ ```
128
+
129
+ ---
41
130
 
42
- ### References
131
+ ## References
43
132
 
44
- - [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
45
- - [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED integration in ProcessCube&copy;
133
+ - [The ProcessCube Developer Network](https://processcube.io) All documentation for the ProcessCube&copy; platform
134
+ - [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) Node-RED integration in ProcessCube&copy;
46
135
  </script>
@@ -9,10 +9,12 @@ module.exports = function (RED) {
9
9
  let subscribe = null;
10
10
 
11
11
  node.on('input', async function (msg) {
12
+ node.log("luis333 input")
12
13
  const client = node.engine.engineClient;
13
14
  const isUser = !!msg._client?.user && !!msg._client.user.accessToken;
14
15
  const userIdentity = isUser ? { userId: msg._client.user.id, token: msg._client.user.accessToken } : null;
15
16
  subscribe = async () => {
17
+ node.log("luis444 subscribing")
16
18
  if (!client) {
17
19
  node.error('No engine configured.', msg);
18
20
  return;
@@ -21,6 +23,7 @@ module.exports = function (RED) {
21
23
  const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg);
22
24
 
23
25
  subscription = await client.userTasks.onUserTaskWaiting(async (userTaskWaitingNotification) => {
26
+ node.log("luis555 got task")
24
27
  const newQuery = {
25
28
  flowNodeInstanceId: userTaskWaitingNotification.flowNodeInstanceId,
26
29
  ...query,
@@ -57,6 +60,7 @@ module.exports = function (RED) {
57
60
  };
58
61
 
59
62
  try {
63
+ node.log("luis777 query for old")
60
64
  const matchingFlowNodes = await client.userTasks.query(suspendedQuery, {identity: userIdentity});
61
65
 
62
66
  if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length >= 1) {