n8n-nodes-base 1.96.1 → 1.97.1

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.
Files changed (34) hide show
  1. package/dist/nodes/Evaluation/EvaluationTrigger/EvaluationTrigger.node.ee.js +18 -13
  2. package/dist/nodes/Evaluation/EvaluationTrigger/EvaluationTrigger.node.ee.js.map +1 -1
  3. package/dist/nodes/Google/Gmail/GenericFunctions.js +1 -1
  4. package/dist/nodes/Google/Gmail/GenericFunctions.js.map +1 -1
  5. package/dist/nodes/Google/Gmail/v2/DraftDescription.js +7 -0
  6. package/dist/nodes/Google/Gmail/v2/DraftDescription.js.map +1 -1
  7. package/dist/nodes/Google/Gmail/v2/GmailV2.node.js +4 -0
  8. package/dist/nodes/Google/Gmail/v2/GmailV2.node.js.map +1 -1
  9. package/dist/nodes/Google/Gmail/v2/utils/draft.js +44 -0
  10. package/dist/nodes/Google/Gmail/v2/utils/draft.js.map +1 -0
  11. package/dist/nodes/HttpRequest/V3/HttpRequestV3.node.js +10 -4
  12. package/dist/nodes/HttpRequest/V3/HttpRequestV3.node.js.map +1 -1
  13. package/dist/nodes/HttpRequest/V3/utils/binaryData.js +37 -0
  14. package/dist/nodes/HttpRequest/V3/utils/binaryData.js.map +1 -0
  15. package/dist/nodes/HttpRequest/V3/utils/parse.js +34 -0
  16. package/dist/nodes/HttpRequest/V3/utils/parse.js.map +1 -0
  17. package/dist/nodes/Linear/CommentDescription.js +105 -0
  18. package/dist/nodes/Linear/CommentDescription.js.map +1 -0
  19. package/dist/nodes/Linear/IssueDescription.js +23 -1
  20. package/dist/nodes/Linear/IssueDescription.js.map +1 -1
  21. package/dist/nodes/Linear/Linear.node.js +37 -0
  22. package/dist/nodes/Linear/Linear.node.js.map +1 -1
  23. package/dist/nodes/Linear/Queries.js +17 -0
  24. package/dist/nodes/Linear/Queries.js.map +1 -1
  25. package/dist/nodes/Linear/test/workflow/apiRequest.js +280 -0
  26. package/dist/nodes/Linear/test/workflow/apiRequest.js.map +1 -0
  27. package/dist/nodes/Linear/test/workflow/apiResponses.js +198 -0
  28. package/dist/nodes/Linear/test/workflow/apiResponses.js.map +1 -0
  29. package/dist/nodes/Postgres/transport/index.js +55 -60
  30. package/dist/nodes/Postgres/transport/index.js.map +1 -1
  31. package/dist/types/nodes.json +4 -4
  32. package/dist/utils/connection-pool-manager.js +42 -30
  33. package/dist/utils/connection-pool-manager.js.map +1 -1
  34. package/package.json +5 -5
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var apiResponses_exports = {};
20
+ __export(apiResponses_exports, {
21
+ attachmentLinkURLResponse: () => attachmentLinkURLResponse,
22
+ commentCreateResponse: () => commentCreateResponse,
23
+ commentCreateWithParentResponse: () => commentCreateWithParentResponse,
24
+ deleteIssueResponse: () => deleteIssueResponse,
25
+ getIssueResponse: () => getIssueResponse,
26
+ getManyIssueResponse: () => getManyIssueResponse,
27
+ issueCreateResponse: () => issueCreateResponse,
28
+ issueUpdateResponse: () => issueUpdateResponse
29
+ });
30
+ module.exports = __toCommonJS(apiResponses_exports);
31
+ const commentCreateResponse = {
32
+ data: {
33
+ commentCreate: {
34
+ success: true,
35
+ comment: {
36
+ id: "ff12069e-fac8-4b18-8455-cc6b29fa1e77"
37
+ }
38
+ }
39
+ }
40
+ };
41
+ const commentCreateWithParentResponse = {
42
+ data: {
43
+ commentCreate: {
44
+ success: true,
45
+ comment: {
46
+ id: "bd0e4d70-7964-4877-aa30-d81534027f44"
47
+ }
48
+ }
49
+ }
50
+ };
51
+ const attachmentLinkURLResponse = {
52
+ data: {
53
+ attachmentLinkURL: {
54
+ success: true
55
+ }
56
+ }
57
+ };
58
+ const issueCreateResponse = {
59
+ data: {
60
+ issueCreate: {
61
+ success: true,
62
+ issue: {
63
+ id: "3c7316e3-4224-424d-8cc8-1dd3b96764b8",
64
+ identifier: "TEST-18",
65
+ title: "This is a test issue",
66
+ priority: 3,
67
+ archivedAt: null,
68
+ assignee: {
69
+ id: "1c51f0c4-c552-4614-a534-8de1752ba7d7",
70
+ displayName: "nathan"
71
+ },
72
+ state: {
73
+ id: "65a87a3a-5729-4d82-96bf-badccbeb49af",
74
+ name: "Backlog"
75
+ },
76
+ createdAt: "2025-06-12T10:38:35.296Z",
77
+ creator: {
78
+ id: "1c51f0c4-c552-4614-a534-8de1752ba7d7",
79
+ displayName: "nathan"
80
+ },
81
+ description: "test description",
82
+ dueDate: null,
83
+ cycle: null
84
+ }
85
+ }
86
+ }
87
+ };
88
+ const getIssueResponse = {
89
+ data: {
90
+ issue: {
91
+ id: "3c7316e3-4224-424d-8cc8-1dd3b96764b8",
92
+ identifier: "TEST-18",
93
+ title: "This is a test issue",
94
+ priority: 3,
95
+ archivedAt: null,
96
+ assignee: {
97
+ id: "1c51f0c4-c552-4614-a534-8de1752ba7d7",
98
+ displayName: "nathan"
99
+ },
100
+ state: {
101
+ id: "65a87a3a-5729-4d82-96bf-badccbeb49af",
102
+ name: "Backlog"
103
+ },
104
+ createdAt: "2025-06-12T10:38:35.296Z",
105
+ creator: {
106
+ id: "1c51f0c4-c552-4614-a534-8de1752ba7d7",
107
+ displayName: "nathan"
108
+ },
109
+ description: "test description",
110
+ dueDate: null,
111
+ cycle: null
112
+ }
113
+ }
114
+ };
115
+ const getManyIssueResponse = {
116
+ data: {
117
+ issues: {
118
+ nodes: [
119
+ {
120
+ id: "3c7316e3-4224-424d-8cc8-1dd3b96764b8",
121
+ identifier: "TEST-18",
122
+ title: "This is a test issue",
123
+ priority: 3,
124
+ archivedAt: null,
125
+ assignee: {
126
+ id: "1c51f0c4-c552-4614-a534-8de1752ba7d7",
127
+ displayName: "nathan"
128
+ },
129
+ state: {
130
+ id: "65a87a3a-5729-4d82-96bf-badccbeb49af",
131
+ name: "Backlog"
132
+ },
133
+ createdAt: "2025-06-12T10:38:35.296Z",
134
+ creator: {
135
+ id: "1c51f0c4-c552-4614-a534-8de1752ba7d7",
136
+ displayName: "nathan"
137
+ },
138
+ description: "test description",
139
+ dueDate: null,
140
+ cycle: null
141
+ }
142
+ ],
143
+ pageInfo: {
144
+ hasNextPage: true,
145
+ endCursor: "3c7316e3-4224-424d-8cc8-1dd3b96764b8"
146
+ }
147
+ }
148
+ }
149
+ };
150
+ const issueUpdateResponse = {
151
+ data: {
152
+ issueUpdate: {
153
+ success: true,
154
+ issue: {
155
+ id: "3c7316e3-4224-424d-8cc8-1dd3b96764b8",
156
+ identifier: "TEST-18",
157
+ title: "New Title",
158
+ priority: 3,
159
+ archivedAt: null,
160
+ assignee: {
161
+ id: "1c51f0c4-c552-4614-a534-8de1752ba7d7",
162
+ displayName: "nathan"
163
+ },
164
+ state: {
165
+ id: "622493c0-f4ee-456d-af65-49a7611ede7a",
166
+ name: "Canceled"
167
+ },
168
+ createdAt: "2025-06-12T10:38:35.296Z",
169
+ creator: {
170
+ id: "1c51f0c4-c552-4614-a534-8de1752ba7d7",
171
+ displayName: "nathan"
172
+ },
173
+ description: "New Description",
174
+ dueDate: null,
175
+ cycle: null
176
+ }
177
+ }
178
+ }
179
+ };
180
+ const deleteIssueResponse = {
181
+ data: {
182
+ issueDelete: {
183
+ success: true
184
+ }
185
+ }
186
+ };
187
+ // Annotate the CommonJS export names for ESM import in node:
188
+ 0 && (module.exports = {
189
+ attachmentLinkURLResponse,
190
+ commentCreateResponse,
191
+ commentCreateWithParentResponse,
192
+ deleteIssueResponse,
193
+ getIssueResponse,
194
+ getManyIssueResponse,
195
+ issueCreateResponse,
196
+ issueUpdateResponse
197
+ });
198
+ //# sourceMappingURL=apiResponses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../nodes/Linear/test/workflow/apiResponses.ts"],"sourcesContent":["export const commentCreateResponse = {\n\tdata: {\n\t\tcommentCreate: {\n\t\t\tsuccess: true,\n\t\t\tcomment: {\n\t\t\t\tid: 'ff12069e-fac8-4b18-8455-cc6b29fa1e77',\n\t\t\t},\n\t\t},\n\t},\n};\n\nexport const commentCreateWithParentResponse = {\n\tdata: {\n\t\tcommentCreate: {\n\t\t\tsuccess: true,\n\t\t\tcomment: {\n\t\t\t\tid: 'bd0e4d70-7964-4877-aa30-d81534027f44',\n\t\t\t},\n\t\t},\n\t},\n};\n\nexport const attachmentLinkURLResponse = {\n\tdata: {\n\t\tattachmentLinkURL: {\n\t\t\tsuccess: true,\n\t\t},\n\t},\n};\n\nexport const issueCreateResponse = {\n\tdata: {\n\t\tissueCreate: {\n\t\t\tsuccess: true,\n\t\t\tissue: {\n\t\t\t\tid: '3c7316e3-4224-424d-8cc8-1dd3b96764b8',\n\t\t\t\tidentifier: 'TEST-18',\n\t\t\t\ttitle: 'This is a test issue',\n\t\t\t\tpriority: 3,\n\t\t\t\tarchivedAt: null,\n\t\t\t\tassignee: {\n\t\t\t\t\tid: '1c51f0c4-c552-4614-a534-8de1752ba7d7',\n\t\t\t\t\tdisplayName: 'nathan',\n\t\t\t\t},\n\t\t\t\tstate: {\n\t\t\t\t\tid: '65a87a3a-5729-4d82-96bf-badccbeb49af',\n\t\t\t\t\tname: 'Backlog',\n\t\t\t\t},\n\t\t\t\tcreatedAt: '2025-06-12T10:38:35.296Z',\n\t\t\t\tcreator: {\n\t\t\t\t\tid: '1c51f0c4-c552-4614-a534-8de1752ba7d7',\n\t\t\t\t\tdisplayName: 'nathan',\n\t\t\t\t},\n\t\t\t\tdescription: 'test description',\n\t\t\t\tdueDate: null,\n\t\t\t\tcycle: null,\n\t\t\t},\n\t\t},\n\t},\n};\n\nexport const getIssueResponse = {\n\tdata: {\n\t\tissue: {\n\t\t\tid: '3c7316e3-4224-424d-8cc8-1dd3b96764b8',\n\t\t\tidentifier: 'TEST-18',\n\t\t\ttitle: 'This is a test issue',\n\t\t\tpriority: 3,\n\t\t\tarchivedAt: null,\n\t\t\tassignee: {\n\t\t\t\tid: '1c51f0c4-c552-4614-a534-8de1752ba7d7',\n\t\t\t\tdisplayName: 'nathan',\n\t\t\t},\n\t\t\tstate: {\n\t\t\t\tid: '65a87a3a-5729-4d82-96bf-badccbeb49af',\n\t\t\t\tname: 'Backlog',\n\t\t\t},\n\t\t\tcreatedAt: '2025-06-12T10:38:35.296Z',\n\t\t\tcreator: {\n\t\t\t\tid: '1c51f0c4-c552-4614-a534-8de1752ba7d7',\n\t\t\t\tdisplayName: 'nathan',\n\t\t\t},\n\t\t\tdescription: 'test description',\n\t\t\tdueDate: null,\n\t\t\tcycle: null,\n\t\t},\n\t},\n};\n\nexport const getManyIssueResponse = {\n\tdata: {\n\t\tissues: {\n\t\t\tnodes: [\n\t\t\t\t{\n\t\t\t\t\tid: '3c7316e3-4224-424d-8cc8-1dd3b96764b8',\n\t\t\t\t\tidentifier: 'TEST-18',\n\t\t\t\t\ttitle: 'This is a test issue',\n\t\t\t\t\tpriority: 3,\n\t\t\t\t\tarchivedAt: null,\n\t\t\t\t\tassignee: {\n\t\t\t\t\t\tid: '1c51f0c4-c552-4614-a534-8de1752ba7d7',\n\t\t\t\t\t\tdisplayName: 'nathan',\n\t\t\t\t\t},\n\t\t\t\t\tstate: {\n\t\t\t\t\t\tid: '65a87a3a-5729-4d82-96bf-badccbeb49af',\n\t\t\t\t\t\tname: 'Backlog',\n\t\t\t\t\t},\n\t\t\t\t\tcreatedAt: '2025-06-12T10:38:35.296Z',\n\t\t\t\t\tcreator: {\n\t\t\t\t\t\tid: '1c51f0c4-c552-4614-a534-8de1752ba7d7',\n\t\t\t\t\t\tdisplayName: 'nathan',\n\t\t\t\t\t},\n\t\t\t\t\tdescription: 'test description',\n\t\t\t\t\tdueDate: null,\n\t\t\t\t\tcycle: null,\n\t\t\t\t},\n\t\t\t],\n\t\t\tpageInfo: {\n\t\t\t\thasNextPage: true,\n\t\t\t\tendCursor: '3c7316e3-4224-424d-8cc8-1dd3b96764b8',\n\t\t\t},\n\t\t},\n\t},\n};\n\nexport const issueUpdateResponse = {\n\tdata: {\n\t\tissueUpdate: {\n\t\t\tsuccess: true,\n\t\t\tissue: {\n\t\t\t\tid: '3c7316e3-4224-424d-8cc8-1dd3b96764b8',\n\t\t\t\tidentifier: 'TEST-18',\n\t\t\t\ttitle: 'New Title',\n\t\t\t\tpriority: 3,\n\t\t\t\tarchivedAt: null,\n\t\t\t\tassignee: {\n\t\t\t\t\tid: '1c51f0c4-c552-4614-a534-8de1752ba7d7',\n\t\t\t\t\tdisplayName: 'nathan',\n\t\t\t\t},\n\t\t\t\tstate: {\n\t\t\t\t\tid: '622493c0-f4ee-456d-af65-49a7611ede7a',\n\t\t\t\t\tname: 'Canceled',\n\t\t\t\t},\n\t\t\t\tcreatedAt: '2025-06-12T10:38:35.296Z',\n\t\t\t\tcreator: {\n\t\t\t\t\tid: '1c51f0c4-c552-4614-a534-8de1752ba7d7',\n\t\t\t\t\tdisplayName: 'nathan',\n\t\t\t\t},\n\t\t\t\tdescription: 'New Description',\n\t\t\t\tdueDate: null,\n\t\t\t\tcycle: null,\n\t\t\t},\n\t\t},\n\t},\n};\n\nexport const deleteIssueResponse = {\n\tdata: {\n\t\tissueDelete: {\n\t\t\tsuccess: true,\n\t\t},\n\t},\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MA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S;AAAA,MACT,OAAO;AAAA,IACR;AAAA,EACD;AACD;AAEO,MAAM,uBAAuB;AAAA,EACnC,MAAM;AAAA,IACL,QAAQ;AAAA,MACP,OAAO;AAAA,QACN;AAAA,UACC,IAAI;AAAA,UACJ,YAAY;AAAA,UACZ,OAAO;AAAA,UACP,UAAU;AAAA,UACV,YAAY;AAAA,UACZ,UAAU;AAAA,YACT,IAAI;AAAA,YACJ,aAAa;AAAA,UACd;AAAA,UACA,OAAO;AAAA,YACN,IAAI;AAAA,YACJ,MAAM;AAAA,UACP;AAAA,UACA,WAAW;AAAA,UACX,SAAS;AAAA,YACR,IAAI;AAAA,YACJ,aAAa;AAAA,UACd;AAAA,UACA,aAAa;AAAA,UACb,SAAS;AAAA,UACT,OAAO;AAAA,QACR;AAAA,MACD;AAAA,MACA,UAAU;AAAA,QACT,aAAa;AAAA,QACb,WAAW;AAAA,MACZ;AAAA,IACD;AAAA,EACD;AACD;AAEO,MAAM,sBAAsB;AAAA,EAClC,MAAM;AAAA,IACL,aAAa;AAAA,MACZ,SAAS;AAAA,MACT,OAAO;AAAA,QACN,IAAI;AAAA,QACJ,YAAY;AAAA,QACZ,OAAO;AAAA,QACP,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,UAAU;AAAA,UACT,IAAI;AAAA,UACJ,aAAa;AAAA,QACd;AAAA,QACA,OAAO;AAAA,UACN,IAAI;AAAA,UACJ,MAAM;AAAA,QACP;AAAA,QACA,WAAW;AAAA,QACX,SAAS;AAAA,UACR,IAAI;AAAA,UACJ,aAAa;AAAA,QACd;AAAA,QACA,aAAa;AAAA,QACb,SAAS;AAAA,QACT,OAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AACD;AAEO,MAAM,sBAAsB;AAAA,EAClC,MAAM;AAAA,IACL,aAAa;AAAA,MACZ,SAAS;AAAA,IACV;AAAA,EACD;AACD;","names":[]}
@@ -62,9 +62,30 @@ const getPostgresConfig = (credentials, options = {}) => {
62
62
  }
63
63
  return dbConfig;
64
64
  };
65
+ function withCleanupHandler(proxy, abortController, logger) {
66
+ proxy.on("error", (error) => {
67
+ logger.error("TCP Proxy: Got error, calling abort controller", { error });
68
+ abortController.abort();
69
+ });
70
+ proxy.on("close", () => {
71
+ logger.error("TCP Proxy: Was closed, calling abort controller");
72
+ abortController.abort();
73
+ });
74
+ proxy.on("drop", (dropArgument) => {
75
+ logger.error("TCP Proxy: Connection was dropped, calling abort controller", {
76
+ dropArgument
77
+ });
78
+ abortController.abort();
79
+ });
80
+ abortController.signal.addEventListener("abort", () => {
81
+ logger.debug("Got abort signal. Closing TCP proxy server.");
82
+ proxy.close();
83
+ });
84
+ return proxy;
85
+ }
65
86
  async function configurePostgres(credentials, options = {}) {
66
- const poolManager = import_connection_pool_manager.ConnectionPoolManager.getInstance();
67
- const fallBackHandler = async () => {
87
+ const poolManager = import_connection_pool_manager.ConnectionPoolManager.getInstance(this.logger);
88
+ const fallBackHandler = async (abortController) => {
68
89
  const pgp = (0, import_pg_promise.default)({
69
90
  // prevent spam in console "WARNING: Creating a duplicate database object for the same connection."
70
91
  // duplicate connections created when auto loading parameters, they are closed immediately after, but several could be open at the same time
@@ -97,75 +118,47 @@ async function configurePostgres(credentials, options = {}) {
97
118
  if (credentials.sshAuthenticateWith === "privateKey" && credentials.privateKey) {
98
119
  credentials.privateKey = (0, import_utilities.formatPrivateKey)(credentials.privateKey);
99
120
  }
100
- const sshClient = await this.helpers.getSSHClient(credentials);
101
- const proxy = (0, import_node_net.createServer)();
121
+ const sshClient = await this.helpers.getSSHClient(credentials, abortController);
122
+ const proxy = withCleanupHandler((0, import_node_net.createServer)(), abortController, this.logger);
102
123
  const proxyPort = await new Promise((resolve) => {
103
124
  proxy.listen(0, import_constants.LOCALHOST, () => {
104
125
  resolve(proxy.address().port);
105
126
  });
106
127
  });
107
- const close = () => {
108
- proxy.close();
109
- sshClient.off("end", close);
110
- sshClient.off("error", close);
111
- };
112
- sshClient.on("end", close);
113
- sshClient.on("error", close);
114
- await new Promise((resolve, reject) => {
115
- proxy.on("error", (err) => reject(err));
116
- proxy.on("connection", (localSocket) => {
117
- sshClient.forwardOut(
118
- import_constants.LOCALHOST,
119
- localSocket.remotePort,
120
- credentials.host,
121
- credentials.port,
122
- (err, clientChannel) => {
123
- if (err) {
124
- proxy.close();
125
- localSocket.destroy();
126
- } else {
127
- localSocket.pipe(clientChannel);
128
- clientChannel.pipe(localSocket);
129
- }
128
+ proxy.on("connection", (localSocket) => {
129
+ sshClient.forwardOut(
130
+ import_constants.LOCALHOST,
131
+ localSocket.remotePort,
132
+ credentials.host,
133
+ credentials.port,
134
+ (error, clientChannel) => {
135
+ if (error) {
136
+ this.logger.error("SSH Client: Port forwarding encountered an error", { error });
137
+ abortController.abort();
138
+ } else {
139
+ localSocket.pipe(clientChannel);
140
+ clientChannel.pipe(localSocket);
130
141
  }
131
- );
132
- });
133
- resolve();
134
- }).catch((err) => {
135
- proxy.close();
136
- let message = err.message;
137
- let description = err.description;
138
- if (err.message.includes("ECONNREFUSED")) {
139
- message = "Connection refused";
140
- try {
141
- description = err.message.split("ECONNREFUSED ")[1].trim();
142
- } catch (e) {
143
- }
144
- }
145
- if (err.message.includes("ENOTFOUND")) {
146
- message = "Host not found";
147
- try {
148
- description = err.message.split("ENOTFOUND ")[1].trim();
149
- } catch (e) {
150
- }
151
- }
152
- if (err.message.includes("ETIMEDOUT")) {
153
- message = "Connection timed out";
154
- try {
155
- description = err.message.split("ETIMEDOUT ")[1].trim();
156
- } catch (e) {
157
142
  }
158
- }
159
- err.message = message;
160
- err.description = description;
161
- throw err;
143
+ );
162
144
  });
163
145
  const db = pgp({
164
146
  ...dbConfig,
165
147
  port: proxyPort,
166
148
  host: import_constants.LOCALHOST
167
149
  });
168
- return { db, pgp };
150
+ abortController.signal.addEventListener("abort", async () => {
151
+ this.logger.debug("configurePostgres: Got abort signal, closing pg connection.");
152
+ try {
153
+ if (!db.$pool.ended) await db.$pool.end();
154
+ } catch (error) {
155
+ this.logger.error("configurePostgres: Encountered error while closing the pool.", {
156
+ error
157
+ });
158
+ throw error;
159
+ }
160
+ });
161
+ return { db, pgp, sshClient };
169
162
  }
170
163
  };
171
164
  return await poolManager.getConnection({
@@ -173,8 +166,10 @@ async function configurePostgres(credentials, options = {}) {
173
166
  nodeType: "postgres",
174
167
  nodeVersion: options.nodeVersion,
175
168
  fallBackHandler,
176
- cleanUpHandler: async ({ db }) => {
177
- if (!db.$pool.ended) await db.$pool.end();
169
+ wasUsed: ({ sshClient }) => {
170
+ if (sshClient) {
171
+ this.helpers.updateLastUsed(sshClient);
172
+ }
178
173
  }
179
174
  });
180
175
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/Postgres/transport/index.ts"],"sourcesContent":["import type {\n\tIExecuteFunctions,\n\tICredentialTestFunctions,\n\tILoadOptionsFunctions,\n\tITriggerFunctions,\n} from 'n8n-workflow';\nimport { createServer, type AddressInfo } from 'node:net';\nimport pgPromise from 'pg-promise';\n\nimport { ConnectionPoolManager } from '@utils/connection-pool-manager';\nimport { LOCALHOST } from '@utils/constants';\nimport { formatPrivateKey } from '@utils/utilities';\n\nimport type {\n\tConnectionsData,\n\tPgpConnectionParameters,\n\tPostgresNodeCredentials,\n\tPostgresNodeOptions,\n} from '../v2/helpers/interfaces';\n\nconst getPostgresConfig = (\n\tcredentials: PostgresNodeCredentials,\n\toptions: PostgresNodeOptions = {},\n) => {\n\tconst dbConfig: PgpConnectionParameters = {\n\t\thost: credentials.host,\n\t\tport: credentials.port,\n\t\tdatabase: credentials.database,\n\t\tuser: credentials.user,\n\t\tpassword: credentials.password,\n\t\tkeepAlive: true,\n\t\tmax: credentials.maxConnections,\n\t};\n\n\tif (options.connectionTimeout) {\n\t\tdbConfig.connectionTimeoutMillis = options.connectionTimeout * 1000;\n\t}\n\n\tif (options.delayClosingIdleConnection) {\n\t\tdbConfig.keepAliveInitialDelayMillis = options.delayClosingIdleConnection * 1000;\n\t}\n\n\tif (credentials.allowUnauthorizedCerts === true) {\n\t\tdbConfig.ssl = {\n\t\t\trejectUnauthorized: false,\n\t\t};\n\t} else {\n\t\tdbConfig.ssl = !['disable', undefined].includes(credentials.ssl as string | undefined);\n\t\t// @ts-ignore these typings need to be updated\n\t\tdbConfig.sslmode = credentials.ssl || 'disable';\n\t}\n\n\treturn dbConfig;\n};\n\nexport async function configurePostgres(\n\tthis: IExecuteFunctions | ICredentialTestFunctions | ILoadOptionsFunctions | ITriggerFunctions,\n\tcredentials: PostgresNodeCredentials,\n\toptions: PostgresNodeOptions = {},\n): Promise<ConnectionsData> {\n\tconst poolManager = ConnectionPoolManager.getInstance();\n\n\tconst fallBackHandler = async () => {\n\t\tconst pgp = pgPromise({\n\t\t\t// prevent spam in console \"WARNING: Creating a duplicate database object for the same connection.\"\n\t\t\t// duplicate connections created when auto loading parameters, they are closed immediately after, but several could be open at the same time\n\t\t\tnoWarnings: true,\n\t\t});\n\n\t\tif (typeof options.nodeVersion === 'number' && options.nodeVersion >= 2.1) {\n\t\t\t// Always return dates as ISO strings\n\t\t\t[pgp.pg.types.builtins.TIMESTAMP, pgp.pg.types.builtins.TIMESTAMPTZ].forEach((type) => {\n\t\t\t\tpgp.pg.types.setTypeParser(type, (value: string) => {\n\t\t\t\t\tconst parsedDate = new Date(value);\n\n\t\t\t\t\tif (isNaN(parsedDate.getTime())) {\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn parsedDate.toISOString();\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tif (options.largeNumbersOutput === 'numbers') {\n\t\t\tpgp.pg.types.setTypeParser(20, (value: string) => {\n\t\t\t\treturn parseInt(value, 10);\n\t\t\t});\n\t\t\tpgp.pg.types.setTypeParser(1700, (value: string) => {\n\t\t\t\treturn parseFloat(value);\n\t\t\t});\n\t\t}\n\n\t\tconst dbConfig = getPostgresConfig(credentials, options);\n\n\t\tif (!credentials.sshTunnel) {\n\t\t\tconst db = pgp(dbConfig);\n\n\t\t\treturn { db, pgp };\n\t\t} else {\n\t\t\tif (credentials.sshAuthenticateWith === 'privateKey' && credentials.privateKey) {\n\t\t\t\tcredentials.privateKey = formatPrivateKey(credentials.privateKey);\n\t\t\t}\n\t\t\tconst sshClient = await this.helpers.getSSHClient(credentials);\n\n\t\t\t// Create a TCP proxy listening on a random available port\n\t\t\tconst proxy = createServer();\n\t\t\tconst proxyPort = await new Promise<number>((resolve) => {\n\t\t\t\tproxy.listen(0, LOCALHOST, () => {\n\t\t\t\t\tresolve((proxy.address() as AddressInfo).port);\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tconst close = () => {\n\t\t\t\tproxy.close();\n\t\t\t\tsshClient.off('end', close);\n\t\t\t\tsshClient.off('error', close);\n\t\t\t};\n\t\t\tsshClient.on('end', close);\n\t\t\tsshClient.on('error', close);\n\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\tproxy.on('error', (err) => reject(err));\n\t\t\t\tproxy.on('connection', (localSocket) => {\n\t\t\t\t\tsshClient.forwardOut(\n\t\t\t\t\t\tLOCALHOST,\n\t\t\t\t\t\tlocalSocket.remotePort!,\n\t\t\t\t\t\tcredentials.host,\n\t\t\t\t\t\tcredentials.port,\n\t\t\t\t\t\t(err, clientChannel) => {\n\t\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\t\tproxy.close();\n\t\t\t\t\t\t\t\tlocalSocket.destroy();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tlocalSocket.pipe(clientChannel);\n\t\t\t\t\t\t\t\tclientChannel.pipe(localSocket);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t\tresolve();\n\t\t\t}).catch((err) => {\n\t\t\t\tproxy.close();\n\n\t\t\t\tlet message = err.message;\n\t\t\t\tlet description = err.description;\n\n\t\t\t\tif (err.message.includes('ECONNREFUSED')) {\n\t\t\t\t\tmessage = 'Connection refused';\n\t\t\t\t\ttry {\n\t\t\t\t\t\tdescription = err.message.split('ECONNREFUSED ')[1].trim();\n\t\t\t\t\t} catch (e) {}\n\t\t\t\t}\n\n\t\t\t\tif (err.message.includes('ENOTFOUND')) {\n\t\t\t\t\tmessage = 'Host not found';\n\t\t\t\t\ttry {\n\t\t\t\t\t\tdescription = err.message.split('ENOTFOUND ')[1].trim();\n\t\t\t\t\t} catch (e) {}\n\t\t\t\t}\n\n\t\t\t\tif (err.message.includes('ETIMEDOUT')) {\n\t\t\t\t\tmessage = 'Connection timed out';\n\t\t\t\t\ttry {\n\t\t\t\t\t\tdescription = err.message.split('ETIMEDOUT ')[1].trim();\n\t\t\t\t\t} catch (e) {}\n\t\t\t\t}\n\n\t\t\t\terr.message = message;\n\t\t\t\terr.description = description;\n\t\t\t\tthrow err;\n\t\t\t});\n\n\t\t\tconst db = pgp({\n\t\t\t\t...dbConfig,\n\t\t\t\tport: proxyPort,\n\t\t\t\thost: LOCALHOST,\n\t\t\t});\n\t\t\treturn { db, pgp };\n\t\t}\n\t};\n\n\treturn await poolManager.getConnection({\n\t\tcredentials,\n\t\tnodeType: 'postgres',\n\t\tnodeVersion: options.nodeVersion as unknown as string,\n\t\tfallBackHandler,\n\t\tcleanUpHandler: async ({ db }) => {\n\t\t\tif (!db.$pool.ended) await db.$pool.end();\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,sBAA+C;AAC/C,wBAAsB;AAEtB,qCAAsC;AACtC,uBAA0B;AAC1B,uBAAiC;AASjC,MAAM,oBAAoB,CACzB,aACA,UAA+B,CAAC,MAC5B;AACJ,QAAM,WAAoC;AAAA,IACzC,MAAM,YAAY;AAAA,IAClB,MAAM,YAAY;AAAA,IAClB,UAAU,YAAY;AAAA,IACtB,MAAM,YAAY;AAAA,IAClB,UAAU,YAAY;AAAA,IACtB,WAAW;AAAA,IACX,KAAK,YAAY;AAAA,EAClB;AAEA,MAAI,QAAQ,mBAAmB;AAC9B,a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,eAAe,EAAE,CAAC,EAAE,KAAK;AAAA,UAC1D,SAAS,GAAG;AAAA,UAAC;AAAA,QACd;AAEA,YAAI,IAAI,QAAQ,SAAS,WAAW,GAAG;AACtC,oBAAU;AACV,cAAI;AACH,0BAAc,IAAI,QAAQ,MAAM,YAAY,EAAE,CAAC,EAAE,KAAK;AAAA,UACvD,SAAS,GAAG;AAAA,UAAC;AAAA,QACd;AAEA,YAAI,IAAI,QAAQ,SAAS,WAAW,GAAG;AACtC,oBAAU;AACV,cAAI;AACH,0BAAc,IAAI,QAAQ,MAAM,YAAY,EAAE,CAAC,EAAE,KAAK;AAAA,UACvD,SAAS,GAAG;AAAA,UAAC;AAAA,QACd;AAEA,YAAI,UAAU;AACd,YAAI,cAAc;AAClB,cAAM;AAAA,MACP,CAAC;AAED,YAAM,KAAK,IAAI;AAAA,QACd,GAAG;AAAA,QACH,MAAM;AAAA,QACN,MAAM;AAAA,MACP,CAAC;AACD,aAAO,EAAE,IAAI,IAAI;AAAA,IAClB;AAAA,EACD;AAEA,SAAO,MAAM,YAAY,cAAc;AAAA,IACtC;AAAA,IACA,UAAU;AAAA,IACV,aAAa,QAAQ;AAAA,IACrB;AAAA,IACA,gBAAgB,OAAO,EAAE,GAAG,MAAM;AACjC,UAAI,CAAC,GAAG,MAAM,MAAO,OAAM,GAAG,MAAM,IAAI;AAAA,IACzC;AAAA,EACD,CAAC;AACF;","names":["pgPromise"]}
1
+ {"version":3,"sources":["../../../../nodes/Postgres/transport/index.ts"],"sourcesContent":["import type {\n\tIExecuteFunctions,\n\tICredentialTestFunctions,\n\tILoadOptionsFunctions,\n\tITriggerFunctions,\n\tLogger,\n} from 'n8n-workflow';\nimport { createServer, type AddressInfo, type Server } from 'node:net';\nimport pgPromise from 'pg-promise';\n\nimport { ConnectionPoolManager } from '@utils/connection-pool-manager';\nimport { LOCALHOST } from '@utils/constants';\nimport { formatPrivateKey } from '@utils/utilities';\n\nimport type {\n\tConnectionsData,\n\tPgpConnectionParameters,\n\tPostgresNodeCredentials,\n\tPostgresNodeOptions,\n} from '../v2/helpers/interfaces';\n\nconst getPostgresConfig = (\n\tcredentials: PostgresNodeCredentials,\n\toptions: PostgresNodeOptions = {},\n) => {\n\tconst dbConfig: PgpConnectionParameters = {\n\t\thost: credentials.host,\n\t\tport: credentials.port,\n\t\tdatabase: credentials.database,\n\t\tuser: credentials.user,\n\t\tpassword: credentials.password,\n\t\tkeepAlive: true,\n\t\tmax: credentials.maxConnections,\n\t};\n\n\tif (options.connectionTimeout) {\n\t\tdbConfig.connectionTimeoutMillis = options.connectionTimeout * 1000;\n\t}\n\n\tif (options.delayClosingIdleConnection) {\n\t\tdbConfig.keepAliveInitialDelayMillis = options.delayClosingIdleConnection * 1000;\n\t}\n\n\tif (credentials.allowUnauthorizedCerts === true) {\n\t\tdbConfig.ssl = {\n\t\t\trejectUnauthorized: false,\n\t\t};\n\t} else {\n\t\tdbConfig.ssl = !['disable', undefined].includes(credentials.ssl as string | undefined);\n\t\t// @ts-ignore these typings need to be updated\n\t\tdbConfig.sslmode = credentials.ssl || 'disable';\n\t}\n\n\treturn dbConfig;\n};\n\nfunction withCleanupHandler(proxy: Server, abortController: AbortController, logger: Logger) {\n\tproxy.on('error', (error) => {\n\t\tlogger.error('TCP Proxy: Got error, calling abort controller', { error });\n\t\tabortController.abort();\n\t});\n\tproxy.on('close', () => {\n\t\tlogger.error('TCP Proxy: Was closed, calling abort controller');\n\t\tabortController.abort();\n\t});\n\tproxy.on('drop', (dropArgument) => {\n\t\tlogger.error('TCP Proxy: Connection was dropped, calling abort controller', {\n\t\t\tdropArgument,\n\t\t});\n\t\tabortController.abort();\n\t});\n\tabortController.signal.addEventListener('abort', () => {\n\t\tlogger.debug('Got abort signal. Closing TCP proxy server.');\n\t\tproxy.close();\n\t});\n\n\treturn proxy;\n}\n\nexport async function configurePostgres(\n\tthis: IExecuteFunctions | ICredentialTestFunctions | ILoadOptionsFunctions | ITriggerFunctions,\n\tcredentials: PostgresNodeCredentials,\n\toptions: PostgresNodeOptions = {},\n): Promise<ConnectionsData> {\n\tconst poolManager = ConnectionPoolManager.getInstance(this.logger);\n\n\tconst fallBackHandler = async (abortController: AbortController) => {\n\t\tconst pgp = pgPromise({\n\t\t\t// prevent spam in console \"WARNING: Creating a duplicate database object for the same connection.\"\n\t\t\t// duplicate connections created when auto loading parameters, they are closed immediately after, but several could be open at the same time\n\t\t\tnoWarnings: true,\n\t\t});\n\n\t\tif (typeof options.nodeVersion === 'number' && options.nodeVersion >= 2.1) {\n\t\t\t// Always return dates as ISO strings\n\t\t\t[pgp.pg.types.builtins.TIMESTAMP, pgp.pg.types.builtins.TIMESTAMPTZ].forEach((type) => {\n\t\t\t\tpgp.pg.types.setTypeParser(type, (value: string) => {\n\t\t\t\t\tconst parsedDate = new Date(value);\n\n\t\t\t\t\tif (isNaN(parsedDate.getTime())) {\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn parsedDate.toISOString();\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tif (options.largeNumbersOutput === 'numbers') {\n\t\t\tpgp.pg.types.setTypeParser(20, (value: string) => {\n\t\t\t\treturn parseInt(value, 10);\n\t\t\t});\n\t\t\tpgp.pg.types.setTypeParser(1700, (value: string) => {\n\t\t\t\treturn parseFloat(value);\n\t\t\t});\n\t\t}\n\n\t\tconst dbConfig = getPostgresConfig(credentials, options);\n\n\t\tif (!credentials.sshTunnel) {\n\t\t\tconst db = pgp(dbConfig);\n\n\t\t\treturn { db, pgp };\n\t\t} else {\n\t\t\tif (credentials.sshAuthenticateWith === 'privateKey' && credentials.privateKey) {\n\t\t\t\tcredentials.privateKey = formatPrivateKey(credentials.privateKey);\n\t\t\t}\n\t\t\tconst sshClient = await this.helpers.getSSHClient(credentials, abortController);\n\n\t\t\t// Create a TCP proxy listening on a random available port\n\t\t\tconst proxy = withCleanupHandler(createServer(), abortController, this.logger);\n\n\t\t\tconst proxyPort = await new Promise<number>((resolve) => {\n\t\t\t\tproxy.listen(0, LOCALHOST, () => {\n\t\t\t\t\tresolve((proxy.address() as AddressInfo).port);\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tproxy.on('connection', (localSocket) => {\n\t\t\t\tsshClient.forwardOut(\n\t\t\t\t\tLOCALHOST,\n\t\t\t\t\tlocalSocket.remotePort!,\n\t\t\t\t\tcredentials.host,\n\t\t\t\t\tcredentials.port,\n\t\t\t\t\t(error, clientChannel) => {\n\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\tthis.logger.error('SSH Client: Port forwarding encountered an error', { error });\n\t\t\t\t\t\t\tabortController.abort();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlocalSocket.pipe(clientChannel);\n\t\t\t\t\t\t\tclientChannel.pipe(localSocket);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t});\n\n\t\t\tconst db = pgp({\n\t\t\t\t...dbConfig,\n\t\t\t\tport: proxyPort,\n\t\t\t\thost: LOCALHOST,\n\t\t\t});\n\n\t\t\tabortController.signal.addEventListener('abort', async () => {\n\t\t\t\tthis.logger.debug('configurePostgres: Got abort signal, closing pg connection.');\n\t\t\t\ttry {\n\t\t\t\t\tif (!db.$pool.ended) await db.$pool.end();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.logger.error('configurePostgres: Encountered error while closing the pool.', {\n\t\t\t\t\t\terror,\n\t\t\t\t\t});\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn { db, pgp, sshClient };\n\t\t}\n\t};\n\n\treturn await poolManager.getConnection({\n\t\tcredentials,\n\t\tnodeType: 'postgres',\n\t\tnodeVersion: options.nodeVersion as unknown as string,\n\t\tfallBackHandler,\n\t\twasUsed: ({ sshClient }) => {\n\t\t\tif (sshClient) {\n\t\t\t\tthis.helpers.updateLastUsed(sshClient);\n\t\t\t}\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;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