@bonsae/node-red-salesforce 0.2.0 → 0.4.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/index.d.ts +10 -25
- package/index.html +1 -1
- package/index.mjs +326 -323
- package/index.mjs.map +1 -1
- package/locales/de/index.html +1 -3
- package/locales/de/index.json +90 -34
- package/locales/en-US/index.html +1 -3
- package/locales/en-US/index.json +91 -35
- package/locales/es-ES/index.html +1 -3
- package/locales/es-ES/index.json +90 -34
- package/locales/fr/index.html +1 -3
- package/locales/fr/index.json +90 -34
- package/locales/ja/index.html +1 -3
- package/locales/ja/index.json +90 -34
- package/locales/ko/index.html +1 -3
- package/locales/ko/index.json +90 -34
- package/locales/pt-BR/index.html +1 -3
- package/locales/pt-BR/index.json +90 -34
- package/locales/ru/index.html +1 -3
- package/locales/ru/index.json +90 -34
- package/locales/zh-CN/index.html +1 -3
- package/locales/zh-CN/index.json +90 -34
- package/locales/zh-TW/index.html +1 -3
- package/locales/zh-TW/index.json +90 -34
- package/package.json +2 -2
- package/resources/index.BmVSYWAa.js +1 -0
- package/resources/index.DheUFZEA.js +0 -1
package/index.mjs
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var f = (a, o) =>
|
|
4
|
-
var i = (a, o, n) =>
|
|
5
|
-
import { fileURLToPath as
|
|
1
|
+
var z = Object.defineProperty;
|
|
2
|
+
var q = (a, o, n) => o in a ? z(a, o, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[o] = n;
|
|
3
|
+
var f = (a, o) => z(a, "name", { value: o, configurable: !0 });
|
|
4
|
+
var i = (a, o, n) => q(a, typeof o != "symbol" ? o + "" : o, n);
|
|
5
|
+
import { fileURLToPath as B } from "url";
|
|
6
6
|
import { dirname as J } from "path";
|
|
7
7
|
import { registerTypes as G } from "@bonsae/nrg/server";
|
|
8
|
-
import { defineSchema as h, SchemaType as
|
|
8
|
+
import { defineSchema as h, SchemaType as e, ConfigNode as Q, IONode as k, defineModule as Y } from "@bonsae/nrg/server";
|
|
9
9
|
import K from "jsforce";
|
|
10
10
|
import M from "node:crypto";
|
|
11
|
-
var V =
|
|
11
|
+
var V = B(import.meta.url), ke = J(V);
|
|
12
12
|
const W = h(
|
|
13
13
|
{
|
|
14
|
-
name:
|
|
15
|
-
loginUrl:
|
|
14
|
+
name: e.String({ default: "" }),
|
|
15
|
+
loginUrl: e.String({
|
|
16
16
|
default: "https://login.salesforce.com",
|
|
17
17
|
"x-nrg-form": { icon: "globe" }
|
|
18
18
|
}),
|
|
19
|
-
clientId:
|
|
19
|
+
clientId: e.String({
|
|
20
20
|
default: "",
|
|
21
21
|
"x-nrg-form": { icon: "key" }
|
|
22
22
|
}),
|
|
23
|
-
apiVersion:
|
|
23
|
+
apiVersion: e.Union(
|
|
24
24
|
[
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
e.Literal("62.0"),
|
|
26
|
+
e.Literal("61.0"),
|
|
27
|
+
e.Literal("60.0"),
|
|
28
|
+
e.Literal("59.0"),
|
|
29
|
+
e.Literal("58.0"),
|
|
30
|
+
e.Literal("57.0"),
|
|
31
|
+
e.Literal("56.0"),
|
|
32
|
+
e.Literal("55.0")
|
|
33
33
|
],
|
|
34
34
|
{ default: "62.0", "x-nrg-form": { icon: "code-fork" } }
|
|
35
35
|
),
|
|
36
|
-
callbackUrl:
|
|
37
|
-
|
|
36
|
+
callbackUrl: e.Optional(
|
|
37
|
+
e.String({
|
|
38
38
|
default: "",
|
|
39
39
|
"x-nrg-form": { icon: "exchange" }
|
|
40
40
|
})
|
|
@@ -43,12 +43,12 @@ const W = h(
|
|
|
43
43
|
{ $id: "salesforce-connection:config" }
|
|
44
44
|
), X = h(
|
|
45
45
|
{
|
|
46
|
-
accessToken:
|
|
47
|
-
refreshToken:
|
|
48
|
-
instanceUrl:
|
|
46
|
+
accessToken: e.String({ default: "", format: "password" }),
|
|
47
|
+
refreshToken: e.String({ default: "", format: "password" }),
|
|
48
|
+
instanceUrl: e.String({ default: "" })
|
|
49
49
|
},
|
|
50
50
|
{ $id: "salesforce-connection:credentials" }
|
|
51
|
-
), H = 600 * 1e3,
|
|
51
|
+
), H = 600 * 1e3, E = /* @__PURE__ */ new Map();
|
|
52
52
|
function Z() {
|
|
53
53
|
return M.randomBytes(32).toString("base64url");
|
|
54
54
|
}
|
|
@@ -58,8 +58,8 @@ function D(a) {
|
|
|
58
58
|
}
|
|
59
59
|
f(D, "generateCodeChallenge");
|
|
60
60
|
function _(a) {
|
|
61
|
-
const o = M.randomUUID(), n = Z(),
|
|
62
|
-
|
|
61
|
+
const o = M.randomUUID(), n = Z(), t = D(n);
|
|
62
|
+
E.set(o, {
|
|
63
63
|
codeVerifier: n,
|
|
64
64
|
nodeId: a.nodeId,
|
|
65
65
|
clientId: a.clientId,
|
|
@@ -67,46 +67,46 @@ function _(a) {
|
|
|
67
67
|
callbackUrl: a.callbackUrl,
|
|
68
68
|
timestamp: Date.now()
|
|
69
69
|
});
|
|
70
|
-
for (const [
|
|
71
|
-
Date.now() -
|
|
72
|
-
return { state: o, codeChallenge:
|
|
70
|
+
for (const [r, s] of E)
|
|
71
|
+
Date.now() - s.timestamp > H && E.delete(r);
|
|
72
|
+
return { state: o, codeChallenge: t };
|
|
73
73
|
}
|
|
74
74
|
f(_, "createAuthState");
|
|
75
|
-
function
|
|
76
|
-
const o =
|
|
77
|
-
return !o || (
|
|
75
|
+
function ee(a) {
|
|
76
|
+
const o = E.get(a);
|
|
77
|
+
return !o || (E.delete(a), Date.now() - o.timestamp > H) ? null : o;
|
|
78
78
|
}
|
|
79
|
-
f(
|
|
80
|
-
function
|
|
79
|
+
f(ee, "consumeAuthState");
|
|
80
|
+
function te(a) {
|
|
81
81
|
return a.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
82
82
|
}
|
|
83
|
-
f(
|
|
84
|
-
function
|
|
83
|
+
f(te, "escapeHtml");
|
|
84
|
+
function A(a, o = !0) {
|
|
85
85
|
const n = o ? "<script>setTimeout(function(){window.close()},3000)</script>" : "";
|
|
86
|
-
return `<html><body><h2>Authorization Failed</h2><p>${
|
|
86
|
+
return `<html><body><h2>Authorization Failed</h2><p>${te(a)}</p>${n}</body></html>`;
|
|
87
87
|
}
|
|
88
|
-
f(
|
|
89
|
-
function
|
|
88
|
+
f(A, "errorPage");
|
|
89
|
+
function ne(a) {
|
|
90
90
|
const o = (a.settings.httpAdminRoot || "").replace(
|
|
91
91
|
/\/$/,
|
|
92
92
|
""
|
|
93
93
|
);
|
|
94
|
-
a.httpAdmin.post("/salesforce/auth/start", (n,
|
|
94
|
+
a.httpAdmin.post("/salesforce/auth/start", (n, t) => {
|
|
95
95
|
try {
|
|
96
96
|
const {
|
|
97
|
-
nodeId:
|
|
98
|
-
loginUrl:
|
|
97
|
+
nodeId: r,
|
|
98
|
+
loginUrl: s,
|
|
99
99
|
clientId: l,
|
|
100
100
|
callbackUrl: d
|
|
101
101
|
} = n.body;
|
|
102
|
-
if (!
|
|
103
|
-
|
|
102
|
+
if (!r || !s || !l) {
|
|
103
|
+
t.status(400).json({ error: "nodeId, loginUrl, and clientId are required" });
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
const c = d || `${n.protocol}://${n.get("host")}${o}/salesforce/auth/callback`, { state: g, codeChallenge: u } = _({
|
|
107
|
-
nodeId:
|
|
107
|
+
nodeId: r,
|
|
108
108
|
clientId: l,
|
|
109
|
-
loginUrl:
|
|
109
|
+
loginUrl: s,
|
|
110
110
|
callbackUrl: c
|
|
111
111
|
}), m = new URLSearchParams({
|
|
112
112
|
response_type: "code",
|
|
@@ -116,31 +116,31 @@ function nt(a) {
|
|
|
116
116
|
code_challenge: u,
|
|
117
117
|
code_challenge_method: "S256"
|
|
118
118
|
});
|
|
119
|
-
|
|
120
|
-
authorizationUrl: `${
|
|
119
|
+
t.json({
|
|
120
|
+
authorizationUrl: `${s}/services/oauth2/authorize?${m.toString()}`
|
|
121
121
|
});
|
|
122
|
-
} catch (
|
|
122
|
+
} catch (r) {
|
|
123
123
|
a.log.error(
|
|
124
|
-
`salesforce-connection: auth/start error: ${
|
|
125
|
-
),
|
|
124
|
+
`salesforce-connection: auth/start error: ${r instanceof Error ? r.message : String(r)}`
|
|
125
|
+
), t.status(500).json({ error: "Failed to start authorization" });
|
|
126
126
|
}
|
|
127
|
-
}), a.httpAdmin.get("/salesforce/auth/callback", async (n,
|
|
127
|
+
}), a.httpAdmin.get("/salesforce/auth/callback", async (n, t) => {
|
|
128
128
|
try {
|
|
129
|
-
const { code:
|
|
129
|
+
const { code: r, state: s, error: l, error_description: d } = n.query;
|
|
130
130
|
if (l) {
|
|
131
131
|
a.log.error(
|
|
132
132
|
`salesforce-connection: OAuth error: ${l} - ${d}`
|
|
133
|
-
),
|
|
133
|
+
), t.status(400).send(A(String(d || l)));
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
|
-
if (!
|
|
137
|
-
|
|
136
|
+
if (!r || !s) {
|
|
137
|
+
t.status(400).send(A("Missing code or state parameter"));
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
|
-
const c =
|
|
140
|
+
const c = ee(s);
|
|
141
141
|
if (!c) {
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
t.status(400).send(
|
|
143
|
+
A(
|
|
144
144
|
"Invalid or expired authorization state. Please try again."
|
|
145
145
|
)
|
|
146
146
|
);
|
|
@@ -153,7 +153,7 @@ function nt(a) {
|
|
|
153
153
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
154
154
|
body: new URLSearchParams({
|
|
155
155
|
grant_type: "authorization_code",
|
|
156
|
-
code:
|
|
156
|
+
code: r,
|
|
157
157
|
client_id: c.clientId,
|
|
158
158
|
redirect_uri: c.callbackUrl,
|
|
159
159
|
code_verifier: c.codeVerifier
|
|
@@ -164,8 +164,8 @@ function nt(a) {
|
|
|
164
164
|
const p = await g.text();
|
|
165
165
|
a.log.error(
|
|
166
166
|
`salesforce-connection: Token exchange failed: ${p}`
|
|
167
|
-
),
|
|
168
|
-
|
|
167
|
+
), t.status(500).send(
|
|
168
|
+
A(
|
|
169
169
|
"Token exchange failed. Check the Node-RED logs for details."
|
|
170
170
|
)
|
|
171
171
|
);
|
|
@@ -186,7 +186,7 @@ function nt(a) {
|
|
|
186
186
|
refreshToken: u.refresh_token,
|
|
187
187
|
instanceUrl: u.instance_url
|
|
188
188
|
});
|
|
189
|
-
|
|
189
|
+
t.send(`<!DOCTYPE html>
|
|
190
190
|
<html>
|
|
191
191
|
<body>
|
|
192
192
|
<h2>Authorization Successful</h2>
|
|
@@ -199,35 +199,35 @@ function nt(a) {
|
|
|
199
199
|
</script>
|
|
200
200
|
</body>
|
|
201
201
|
</html>`);
|
|
202
|
-
} catch (
|
|
202
|
+
} catch (r) {
|
|
203
203
|
a.log.error(
|
|
204
|
-
`salesforce-connection: auth/callback error: ${
|
|
205
|
-
),
|
|
204
|
+
`salesforce-connection: auth/callback error: ${r instanceof Error ? r.message : String(r)}`
|
|
205
|
+
), t.status(500).send(A("An unexpected error occurred."));
|
|
206
206
|
}
|
|
207
|
-
}), a.httpAdmin.get("/salesforce/auth/status/:nodeId", (n,
|
|
207
|
+
}), a.httpAdmin.get("/salesforce/auth/status/:nodeId", (n, t) => {
|
|
208
208
|
try {
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
authenticated:
|
|
212
|
-
instanceUrl:
|
|
209
|
+
const r = a.nodes.getCredentials(n.params.nodeId), s = !!(r != null && r.accessToken && (r != null && r.instanceUrl));
|
|
210
|
+
t.json({
|
|
211
|
+
authenticated: s,
|
|
212
|
+
instanceUrl: s ? r.instanceUrl : void 0
|
|
213
213
|
});
|
|
214
214
|
} catch {
|
|
215
|
-
|
|
215
|
+
t.json({ authenticated: !1 });
|
|
216
216
|
}
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
|
-
f(
|
|
220
|
-
function
|
|
221
|
-
|
|
219
|
+
f(ne, "initAuthRoutes");
|
|
220
|
+
function oe(a) {
|
|
221
|
+
ne(a);
|
|
222
222
|
}
|
|
223
|
-
f(
|
|
224
|
-
const
|
|
223
|
+
f(oe, "initRoutes");
|
|
224
|
+
const L = class L extends Q {
|
|
225
225
|
constructor() {
|
|
226
226
|
super(...arguments);
|
|
227
227
|
i(this, "conn", null);
|
|
228
228
|
}
|
|
229
229
|
static async registered(n) {
|
|
230
|
-
|
|
230
|
+
oe(n);
|
|
231
231
|
}
|
|
232
232
|
async getConnection() {
|
|
233
233
|
if (this.conn) return this.conn;
|
|
@@ -245,10 +245,10 @@ const C = class C extends Q {
|
|
|
245
245
|
accessToken: n.accessToken,
|
|
246
246
|
refreshToken: n.refreshToken,
|
|
247
247
|
version: this.config.apiVersion
|
|
248
|
-
}), this.conn.on("refresh", (
|
|
248
|
+
}), this.conn.on("refresh", (t) => {
|
|
249
249
|
this.RED.nodes.addCredentials(this.id, {
|
|
250
250
|
...this.credentials,
|
|
251
|
-
accessToken:
|
|
251
|
+
accessToken: t
|
|
252
252
|
});
|
|
253
253
|
}), this.conn;
|
|
254
254
|
}
|
|
@@ -264,15 +264,15 @@ const C = class C extends Q {
|
|
|
264
264
|
this.conn = null;
|
|
265
265
|
}
|
|
266
266
|
};
|
|
267
|
-
f(
|
|
268
|
-
let
|
|
269
|
-
const
|
|
267
|
+
f(L, "SalesforceConnection"), i(L, "type", "salesforce-connection"), i(L, "configSchema", W), i(L, "credentialsSchema", X);
|
|
268
|
+
let $ = L;
|
|
269
|
+
const ie = h(
|
|
270
270
|
{
|
|
271
|
-
name:
|
|
272
|
-
connection:
|
|
271
|
+
name: e.String({ default: "", "x-nrg-form": { icon: "tag" } }),
|
|
272
|
+
connection: e.NodeRef($, {
|
|
273
273
|
"x-nrg-form": { icon: "cloud" }
|
|
274
274
|
}),
|
|
275
|
-
query:
|
|
275
|
+
query: e.TypedInput({
|
|
276
276
|
"x-nrg-form": {
|
|
277
277
|
icon: "search",
|
|
278
278
|
typedInputTypes: ["str", "msg", "flow", "global"]
|
|
@@ -280,19 +280,19 @@ const it = h(
|
|
|
280
280
|
})
|
|
281
281
|
},
|
|
282
282
|
{ $id: "salesforce-soql:config" }
|
|
283
|
-
),
|
|
283
|
+
), re = h(
|
|
284
284
|
{
|
|
285
|
-
payload:
|
|
285
|
+
payload: e.Any()
|
|
286
286
|
},
|
|
287
287
|
{ $id: "salesforce-soql:input" }
|
|
288
|
-
),
|
|
288
|
+
), se = h(
|
|
289
289
|
{
|
|
290
|
-
payload:
|
|
291
|
-
totalSize:
|
|
292
|
-
done:
|
|
290
|
+
payload: e.Array(e.Any()),
|
|
291
|
+
totalSize: e.Number(),
|
|
292
|
+
done: e.Boolean()
|
|
293
293
|
},
|
|
294
294
|
{ $id: "salesforce-soql:output" }
|
|
295
|
-
), y = class y extends
|
|
295
|
+
), y = class y extends k {
|
|
296
296
|
async input(o) {
|
|
297
297
|
const n = this.config.connection;
|
|
298
298
|
if (!n) {
|
|
@@ -301,76 +301,76 @@ const it = h(
|
|
|
301
301
|
}
|
|
302
302
|
try {
|
|
303
303
|
this.status({ fill: "green", shape: "dot", text: "querying..." });
|
|
304
|
-
const
|
|
304
|
+
const t = await n.getConnection(), r = await this.config.query.resolve(o), s = await t.query(r);
|
|
305
305
|
this.status({
|
|
306
306
|
fill: "green",
|
|
307
307
|
shape: "dot",
|
|
308
|
-
text: `${
|
|
308
|
+
text: `${s.totalSize} records`
|
|
309
309
|
}), this.send({
|
|
310
310
|
...o,
|
|
311
|
-
payload:
|
|
312
|
-
totalSize:
|
|
313
|
-
done:
|
|
311
|
+
payload: s.records,
|
|
312
|
+
totalSize: s.totalSize,
|
|
313
|
+
done: s.done
|
|
314
314
|
});
|
|
315
|
-
} catch (
|
|
315
|
+
} catch (t) {
|
|
316
316
|
this.status({
|
|
317
317
|
fill: "red",
|
|
318
318
|
shape: "dot",
|
|
319
|
-
text:
|
|
319
|
+
text: t instanceof Error ? t.message : String(t)
|
|
320
320
|
}), this.error(
|
|
321
|
-
`SOQL query failed: ${
|
|
321
|
+
`SOQL query failed: ${t instanceof Error ? t.message : String(t)}`,
|
|
322
322
|
o
|
|
323
323
|
);
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
};
|
|
327
|
-
f(y, "SalesforceSoql"), i(y, "type", "salesforce-soql"), i(y, "category", "salesforce"), i(y, "color", "#FFFFFF"), i(y, "
|
|
328
|
-
let
|
|
329
|
-
const
|
|
327
|
+
f(y, "SalesforceSoql"), i(y, "type", "salesforce-soql"), i(y, "category", "salesforce"), i(y, "color", "#FFFFFF"), i(y, "configSchema", ie), i(y, "inputSchema", re), i(y, "outputsSchema", se);
|
|
328
|
+
let C = y;
|
|
329
|
+
const ae = h(
|
|
330
330
|
{
|
|
331
|
-
name:
|
|
332
|
-
connection:
|
|
331
|
+
name: e.String({ default: "", "x-nrg-form": { icon: "tag" } }),
|
|
332
|
+
connection: e.NodeRef($, {
|
|
333
333
|
"x-nrg-form": { icon: "cloud" }
|
|
334
334
|
}),
|
|
335
|
-
operation:
|
|
335
|
+
operation: e.Union(
|
|
336
336
|
[
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
337
|
+
e.Literal("create"),
|
|
338
|
+
e.Literal("read"),
|
|
339
|
+
e.Literal("update"),
|
|
340
|
+
e.Literal("delete"),
|
|
341
|
+
e.Literal("upsert")
|
|
342
342
|
],
|
|
343
343
|
{ default: "create", "x-nrg-form": { icon: "pencil" } }
|
|
344
344
|
),
|
|
345
|
-
sObjectType:
|
|
345
|
+
sObjectType: e.TypedInput({
|
|
346
346
|
"x-nrg-form": {
|
|
347
347
|
icon: "cube",
|
|
348
348
|
typedInputTypes: ["str", "msg"]
|
|
349
349
|
}
|
|
350
350
|
}),
|
|
351
|
-
record:
|
|
351
|
+
record: e.TypedInput({
|
|
352
352
|
"x-nrg-form": {
|
|
353
353
|
icon: "file-code-o",
|
|
354
354
|
typedInputTypes: ["json", "msg"]
|
|
355
355
|
}
|
|
356
356
|
}),
|
|
357
|
-
externalIdField:
|
|
358
|
-
|
|
357
|
+
externalIdField: e.Optional(
|
|
358
|
+
e.String({
|
|
359
359
|
default: "",
|
|
360
360
|
"x-nrg-form": { icon: "key" }
|
|
361
361
|
})
|
|
362
362
|
),
|
|
363
|
-
emitError:
|
|
364
|
-
emitComplete:
|
|
365
|
-
emitStatus:
|
|
363
|
+
emitError: e.Boolean({ default: !1 }),
|
|
364
|
+
emitComplete: e.Boolean({ default: !1 }),
|
|
365
|
+
emitStatus: e.Boolean({ default: !1 })
|
|
366
366
|
},
|
|
367
367
|
{
|
|
368
368
|
$id: "salesforce-dml:config",
|
|
369
|
-
if:
|
|
370
|
-
operation:
|
|
369
|
+
if: e.Object({
|
|
370
|
+
operation: e.Literal("upsert")
|
|
371
371
|
}),
|
|
372
|
-
then:
|
|
373
|
-
externalIdField:
|
|
372
|
+
then: e.Object({
|
|
373
|
+
externalIdField: e.String({ minLength: 1 })
|
|
374
374
|
}),
|
|
375
375
|
errorMessage: {
|
|
376
376
|
properties: {
|
|
@@ -378,17 +378,17 @@ const at = h(
|
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
|
-
),
|
|
381
|
+
), ce = h(
|
|
382
382
|
{
|
|
383
|
-
payload:
|
|
383
|
+
payload: e.Any()
|
|
384
384
|
},
|
|
385
385
|
{ $id: "salesforce-dml:input" }
|
|
386
|
-
),
|
|
386
|
+
), le = h(
|
|
387
387
|
{
|
|
388
|
-
payload:
|
|
388
|
+
payload: e.Any()
|
|
389
389
|
},
|
|
390
390
|
{ $id: "salesforce-dml:output" }
|
|
391
|
-
), x = class x extends
|
|
391
|
+
), x = class x extends k {
|
|
392
392
|
async input(o) {
|
|
393
393
|
const n = this.config.connection;
|
|
394
394
|
if (!n) {
|
|
@@ -396,11 +396,11 @@ const at = h(
|
|
|
396
396
|
return;
|
|
397
397
|
}
|
|
398
398
|
try {
|
|
399
|
-
const
|
|
400
|
-
this.status({ fill: "green", shape: "dot", text: `${
|
|
401
|
-
const
|
|
399
|
+
const t = this.config.operation;
|
|
400
|
+
this.status({ fill: "green", shape: "dot", text: `${t}...` });
|
|
401
|
+
const r = await n.getConnection(), s = await this.config.sObjectType.resolve(o), l = r.sobject(s), d = await this.config.record.resolve(o) ?? o.payload;
|
|
402
402
|
let c;
|
|
403
|
-
switch (
|
|
403
|
+
switch (t) {
|
|
404
404
|
case "create":
|
|
405
405
|
c = await l.create(d);
|
|
406
406
|
break;
|
|
@@ -417,98 +417,93 @@ const at = h(
|
|
|
417
417
|
c = await l.upsert(d, this.config.externalIdField);
|
|
418
418
|
break;
|
|
419
419
|
default:
|
|
420
|
-
throw new Error(`Unknown operation: ${
|
|
420
|
+
throw new Error(`Unknown operation: ${t}`);
|
|
421
421
|
}
|
|
422
|
-
this.status({ fill: "green", shape: "dot", text: `${
|
|
423
|
-
} catch (
|
|
422
|
+
this.status({ fill: "green", shape: "dot", text: `${t} done` }), this.send({ ...o, payload: c });
|
|
423
|
+
} catch (t) {
|
|
424
424
|
this.status({
|
|
425
425
|
fill: "red",
|
|
426
426
|
shape: "dot",
|
|
427
|
-
text:
|
|
427
|
+
text: t instanceof Error ? t.message : String(t)
|
|
428
428
|
}), this.error(
|
|
429
|
-
`DML ${this.config.operation} failed: ${
|
|
429
|
+
`DML ${this.config.operation} failed: ${t instanceof Error ? t.message : String(t)}`,
|
|
430
430
|
o
|
|
431
431
|
);
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
434
|
};
|
|
435
|
-
f(x, "SalesforceDml"), i(x, "type", "salesforce-dml"), i(x, "category", "salesforce"), i(x, "color", "#FFFFFF"), i(x, "
|
|
436
|
-
let
|
|
437
|
-
const
|
|
435
|
+
f(x, "SalesforceDml"), i(x, "type", "salesforce-dml"), i(x, "category", "salesforce"), i(x, "color", "#FFFFFF"), i(x, "configSchema", ae), i(x, "inputSchema", ce), i(x, "outputsSchema", le);
|
|
436
|
+
let R = x;
|
|
437
|
+
const de = h(
|
|
438
438
|
{
|
|
439
|
-
name:
|
|
440
|
-
connection:
|
|
439
|
+
name: e.String({ default: "", "x-nrg-form": { icon: "tag" } }),
|
|
440
|
+
connection: e.NodeRef($, {
|
|
441
441
|
"x-nrg-form": { icon: "cloud" }
|
|
442
442
|
}),
|
|
443
|
-
operation:
|
|
443
|
+
operation: e.Union(
|
|
444
444
|
[
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
445
|
+
e.Literal("insert"),
|
|
446
|
+
e.Literal("update"),
|
|
447
|
+
e.Literal("upsert"),
|
|
448
|
+
e.Literal("delete"),
|
|
449
|
+
e.Literal("query")
|
|
450
450
|
],
|
|
451
451
|
{ default: "insert", "x-nrg-form": { icon: "database" } }
|
|
452
452
|
),
|
|
453
|
-
sObjectType:
|
|
453
|
+
sObjectType: e.TypedInput({
|
|
454
454
|
"x-nrg-form": {
|
|
455
455
|
icon: "cube",
|
|
456
456
|
typedInputTypes: ["str", "msg"]
|
|
457
457
|
}
|
|
458
458
|
}),
|
|
459
|
-
externalIdField:
|
|
460
|
-
|
|
459
|
+
externalIdField: e.Optional(
|
|
460
|
+
e.String({
|
|
461
461
|
default: "",
|
|
462
462
|
"x-nrg-form": { icon: "key" }
|
|
463
463
|
})
|
|
464
464
|
),
|
|
465
|
-
assignmentRuleId:
|
|
466
|
-
|
|
465
|
+
assignmentRuleId: e.Optional(
|
|
466
|
+
e.String({
|
|
467
467
|
default: "",
|
|
468
468
|
"x-nrg-form": { icon: "gavel" }
|
|
469
469
|
})
|
|
470
470
|
),
|
|
471
|
-
columnDelimiter:
|
|
471
|
+
columnDelimiter: e.Union(
|
|
472
472
|
[
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
473
|
+
e.Literal("COMMA"),
|
|
474
|
+
e.Literal("TAB"),
|
|
475
|
+
e.Literal("PIPE"),
|
|
476
|
+
e.Literal("SEMICOLON"),
|
|
477
|
+
e.Literal("CARET"),
|
|
478
|
+
e.Literal("BACKQUOTE")
|
|
479
479
|
],
|
|
480
480
|
{ default: "COMMA", "x-nrg-form": { icon: "columns" } }
|
|
481
481
|
),
|
|
482
|
-
lineEnding:
|
|
483
|
-
[
|
|
482
|
+
lineEnding: e.Union(
|
|
483
|
+
[e.Literal("LF"), e.Literal("CRLF")],
|
|
484
484
|
{ default: "LF", "x-nrg-form": { icon: "level-down" } }
|
|
485
485
|
),
|
|
486
|
-
pollInterval:
|
|
486
|
+
pollInterval: e.Number({
|
|
487
487
|
default: 5e3,
|
|
488
488
|
minimum: 1e3,
|
|
489
489
|
"x-nrg-form": { icon: "clock-o" }
|
|
490
490
|
}),
|
|
491
|
-
pollTimeout:
|
|
491
|
+
pollTimeout: e.Number({
|
|
492
492
|
default: 6e4,
|
|
493
493
|
minimum: 5e3,
|
|
494
494
|
"x-nrg-form": { icon: "hourglass" }
|
|
495
495
|
}),
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
}),
|
|
500
|
-
outputs: t.Number({ default: 2 }),
|
|
501
|
-
emitError: t.Boolean({ default: !1 }),
|
|
502
|
-
emitComplete: t.Boolean({ default: !1 }),
|
|
503
|
-
emitStatus: t.Boolean({ default: !1 })
|
|
496
|
+
emitError: e.Boolean({ default: !1 }),
|
|
497
|
+
emitComplete: e.Boolean({ default: !0 }),
|
|
498
|
+
emitStatus: e.Boolean({ default: !1 })
|
|
504
499
|
},
|
|
505
500
|
{
|
|
506
501
|
$id: "salesforce-bulk:config",
|
|
507
|
-
if:
|
|
508
|
-
operation:
|
|
502
|
+
if: e.Object({
|
|
503
|
+
operation: e.Literal("upsert")
|
|
509
504
|
}),
|
|
510
|
-
then:
|
|
511
|
-
externalIdField:
|
|
505
|
+
then: e.Object({
|
|
506
|
+
externalIdField: e.String({ minLength: 1 })
|
|
512
507
|
}),
|
|
513
508
|
errorMessage: {
|
|
514
509
|
properties: {
|
|
@@ -516,29 +511,30 @@ const dt = h(
|
|
|
516
511
|
}
|
|
517
512
|
}
|
|
518
513
|
}
|
|
519
|
-
),
|
|
514
|
+
), ue = h(
|
|
520
515
|
{
|
|
521
|
-
payload:
|
|
516
|
+
payload: e.Any()
|
|
522
517
|
},
|
|
523
518
|
{ $id: "salesforce-bulk:input" }
|
|
524
519
|
);
|
|
525
520
|
h(
|
|
526
521
|
{
|
|
527
|
-
payload:
|
|
522
|
+
payload: e.Array(e.Any())
|
|
528
523
|
},
|
|
529
524
|
{ $id: "salesforce-bulk:output" }
|
|
530
525
|
);
|
|
531
|
-
const
|
|
526
|
+
const he = h(
|
|
527
|
+
{},
|
|
528
|
+
{ $id: "salesforce-bulk:record-output" }
|
|
529
|
+
), pe = h(
|
|
530
|
+
{},
|
|
531
|
+
{ $id: "salesforce-bulk:job-created-output" }
|
|
532
|
+
), b = class b extends k {
|
|
532
533
|
sendRecord(o, n) {
|
|
533
|
-
|
|
534
|
-
s[0] = { ...o, payload: n }, this.send(s);
|
|
534
|
+
this.sendToPort(0, { ...o, payload: n });
|
|
535
535
|
}
|
|
536
536
|
sendJobCreated(o, n) {
|
|
537
|
-
this.
|
|
538
|
-
}
|
|
539
|
-
sendComplete(o, n) {
|
|
540
|
-
const e = this.config.emitJobCreated ? 3 : 2, s = Array(e).fill(null);
|
|
541
|
-
s[1] = { ...o, payload: n }, this.send(s);
|
|
537
|
+
this.sendToPort(1, { ...o, payload: n });
|
|
542
538
|
}
|
|
543
539
|
async input(o) {
|
|
544
540
|
const n = this.config.connection;
|
|
@@ -547,16 +543,16 @@ const I = class I extends A {
|
|
|
547
543
|
return;
|
|
548
544
|
}
|
|
549
545
|
try {
|
|
550
|
-
const
|
|
546
|
+
const t = this.config.operation;
|
|
551
547
|
this.status({
|
|
552
548
|
fill: "green",
|
|
553
549
|
shape: "dot",
|
|
554
|
-
text: `bulk ${
|
|
550
|
+
text: `bulk ${t}...`
|
|
555
551
|
});
|
|
556
|
-
const
|
|
552
|
+
const r = await n.getConnection(), s = await this.config.sObjectType.resolve(o);
|
|
557
553
|
let l = 0;
|
|
558
|
-
if (
|
|
559
|
-
const d = await
|
|
554
|
+
if (t === "query") {
|
|
555
|
+
const d = await r.bulk2.query(o.payload, {
|
|
560
556
|
pollTimeout: this.config.pollTimeout,
|
|
561
557
|
pollInterval: this.config.pollInterval,
|
|
562
558
|
columnDelimiter: this.config.columnDelimiter,
|
|
@@ -569,21 +565,24 @@ const I = class I extends A {
|
|
|
569
565
|
}), this.status({
|
|
570
566
|
fill: "green",
|
|
571
567
|
shape: "dot",
|
|
572
|
-
text: `bulk ${
|
|
573
|
-
}), this.
|
|
568
|
+
text: `bulk ${t}: ${l} records`
|
|
569
|
+
}), this.sendToPort("complete", {
|
|
570
|
+
...o,
|
|
571
|
+
payload: { operation: t, sObjectType: s, totalRecords: l }
|
|
572
|
+
});
|
|
574
573
|
} else {
|
|
575
|
-
const d = o.payload, c =
|
|
576
|
-
operation:
|
|
577
|
-
object:
|
|
574
|
+
const d = o.payload, c = r.bulk2.createJob({
|
|
575
|
+
operation: t,
|
|
576
|
+
object: s,
|
|
578
577
|
columnDelimiter: this.config.columnDelimiter,
|
|
579
578
|
lineEnding: this.config.lineEnding,
|
|
580
|
-
...
|
|
579
|
+
...t === "upsert" && this.config.externalIdField ? { externalIdFieldName: this.config.externalIdField } : {},
|
|
581
580
|
...this.config.assignmentRuleId ? { assignmentRuleId: this.config.assignmentRuleId } : {}
|
|
582
581
|
});
|
|
583
582
|
await c.open(), this.sendJobCreated(o, {
|
|
584
583
|
jobId: c.id,
|
|
585
|
-
operation:
|
|
586
|
-
sObjectType:
|
|
584
|
+
operation: t,
|
|
585
|
+
sObjectType: s,
|
|
587
586
|
state: "Open"
|
|
588
587
|
}), await c.uploadData(d), await c.close(), await c.poll(this.config.pollInterval, this.config.pollTimeout);
|
|
589
588
|
const g = await c.getAllResults(), u = g.successfulResults ?? [], m = g.failedResults ?? [], p = g.unprocessedRecords ?? [];
|
|
@@ -592,62 +591,68 @@ const I = class I extends A {
|
|
|
592
591
|
this.sendRecord(o, U);
|
|
593
592
|
for (const U of m)
|
|
594
593
|
this.sendRecord(o, U);
|
|
595
|
-
const
|
|
594
|
+
const S = u.length, P = m.length;
|
|
596
595
|
this.status({
|
|
597
|
-
fill:
|
|
596
|
+
fill: P > 0 ? "red" : "green",
|
|
598
597
|
shape: "dot",
|
|
599
|
-
text: `bulk ${
|
|
600
|
-
}), this.
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
598
|
+
text: `bulk ${t}: ${l} records`
|
|
599
|
+
}), this.sendToPort("complete", {
|
|
600
|
+
...o,
|
|
601
|
+
payload: {
|
|
602
|
+
jobId: c.id,
|
|
603
|
+
operation: t,
|
|
604
|
+
sObjectType: s,
|
|
605
|
+
totalRecords: l,
|
|
606
|
+
successCount: S,
|
|
607
|
+
failureCount: P,
|
|
608
|
+
unprocessedCount: p.length
|
|
609
|
+
}
|
|
608
610
|
});
|
|
609
611
|
}
|
|
610
|
-
} catch (
|
|
611
|
-
const
|
|
612
|
-
this.status({ fill: "red", shape: "dot", text:
|
|
612
|
+
} catch (t) {
|
|
613
|
+
const r = t instanceof Error ? t.message : String(t);
|
|
614
|
+
this.status({ fill: "red", shape: "dot", text: r }), this.error(`Bulk ${this.config.operation} failed: ${r}`, o);
|
|
613
615
|
}
|
|
614
616
|
}
|
|
615
617
|
};
|
|
616
|
-
f(
|
|
617
|
-
|
|
618
|
-
|
|
618
|
+
f(b, "SalesforceBulk"), i(b, "type", "salesforce-bulk"), i(b, "category", "salesforce"), i(b, "color", "#FFFFFF"), i(b, "configSchema", de), i(b, "inputSchema", ue), i(b, "outputsSchema", [
|
|
619
|
+
he,
|
|
620
|
+
pe
|
|
621
|
+
]);
|
|
622
|
+
let O = b;
|
|
623
|
+
const fe = h(
|
|
619
624
|
{
|
|
620
|
-
name:
|
|
621
|
-
connection:
|
|
625
|
+
name: e.String({ default: "", "x-nrg-form": { icon: "tag" } }),
|
|
626
|
+
connection: e.NodeRef($, {
|
|
622
627
|
"x-nrg-form": { icon: "cloud" }
|
|
623
628
|
}),
|
|
624
|
-
sObjectType:
|
|
629
|
+
sObjectType: e.TypedInput({
|
|
625
630
|
"x-nrg-form": {
|
|
626
631
|
icon: "cube",
|
|
627
632
|
typedInputTypes: ["str", "msg"]
|
|
628
633
|
}
|
|
629
634
|
}),
|
|
630
|
-
emitError:
|
|
631
|
-
emitComplete:
|
|
632
|
-
emitStatus:
|
|
635
|
+
emitError: e.Boolean({ default: !1 }),
|
|
636
|
+
emitComplete: e.Boolean({ default: !1 }),
|
|
637
|
+
emitStatus: e.Boolean({ default: !1 })
|
|
633
638
|
},
|
|
634
639
|
{ $id: "salesforce-describe:config" }
|
|
635
|
-
),
|
|
640
|
+
), ge = h(
|
|
636
641
|
{
|
|
637
|
-
payload:
|
|
642
|
+
payload: e.Any()
|
|
638
643
|
},
|
|
639
644
|
{ $id: "salesforce-describe:input" }
|
|
640
|
-
),
|
|
645
|
+
), me = h(
|
|
641
646
|
{
|
|
642
|
-
payload:
|
|
643
|
-
name:
|
|
644
|
-
fields:
|
|
645
|
-
childRelationships:
|
|
646
|
-
recordTypeInfos:
|
|
647
|
+
payload: e.Object({
|
|
648
|
+
name: e.String(),
|
|
649
|
+
fields: e.Array(e.Any()),
|
|
650
|
+
childRelationships: e.Array(e.Any()),
|
|
651
|
+
recordTypeInfos: e.Array(e.Any())
|
|
647
652
|
})
|
|
648
653
|
},
|
|
649
654
|
{ $id: "salesforce-describe:output" }
|
|
650
|
-
),
|
|
655
|
+
), T = class T extends k {
|
|
651
656
|
async input(o) {
|
|
652
657
|
const n = this.config.connection;
|
|
653
658
|
if (!n) {
|
|
@@ -656,74 +661,74 @@ const ht = h(
|
|
|
656
661
|
}
|
|
657
662
|
try {
|
|
658
663
|
this.status({ fill: "green", shape: "dot", text: "describing..." });
|
|
659
|
-
const
|
|
664
|
+
const t = await n.getConnection(), r = await this.config.sObjectType.resolve(o), s = await t.sobject(r).describe();
|
|
660
665
|
this.status({
|
|
661
666
|
fill: "green",
|
|
662
667
|
shape: "dot",
|
|
663
|
-
text: `${
|
|
668
|
+
text: `${s.name}: ${s.fields.length} fields`
|
|
664
669
|
}), this.send({
|
|
665
670
|
...o,
|
|
666
671
|
payload: {
|
|
667
|
-
name:
|
|
668
|
-
fields:
|
|
669
|
-
childRelationships:
|
|
670
|
-
recordTypeInfos:
|
|
672
|
+
name: s.name,
|
|
673
|
+
fields: s.fields,
|
|
674
|
+
childRelationships: s.childRelationships,
|
|
675
|
+
recordTypeInfos: s.recordTypeInfos
|
|
671
676
|
}
|
|
672
677
|
});
|
|
673
|
-
} catch (
|
|
678
|
+
} catch (t) {
|
|
674
679
|
this.status({
|
|
675
680
|
fill: "red",
|
|
676
681
|
shape: "dot",
|
|
677
|
-
text:
|
|
682
|
+
text: t instanceof Error ? t.message : String(t)
|
|
678
683
|
}), this.error(
|
|
679
|
-
`Describe failed: ${
|
|
684
|
+
`Describe failed: ${t instanceof Error ? t.message : String(t)}`,
|
|
680
685
|
o
|
|
681
686
|
);
|
|
682
687
|
}
|
|
683
688
|
}
|
|
684
689
|
};
|
|
685
|
-
f(
|
|
686
|
-
let j =
|
|
687
|
-
const
|
|
690
|
+
f(T, "SalesforceDescribe"), i(T, "type", "salesforce-describe"), i(T, "category", "salesforce"), i(T, "color", "#FFFFFF"), i(T, "configSchema", fe), i(T, "inputSchema", ge), i(T, "outputsSchema", me);
|
|
691
|
+
let j = T;
|
|
692
|
+
const ye = h(
|
|
688
693
|
{
|
|
689
|
-
name:
|
|
690
|
-
connection:
|
|
694
|
+
name: e.String({ default: "", "x-nrg-form": { icon: "tag" } }),
|
|
695
|
+
connection: e.NodeRef($, {
|
|
691
696
|
"x-nrg-form": { icon: "cloud" }
|
|
692
697
|
}),
|
|
693
|
-
channelName:
|
|
698
|
+
channelName: e.String({
|
|
694
699
|
default: "",
|
|
695
700
|
"x-nrg-form": { icon: "rss" }
|
|
696
701
|
}),
|
|
697
|
-
subscribeType:
|
|
702
|
+
subscribeType: e.Union(
|
|
698
703
|
[
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
704
|
+
e.Literal("LATEST"),
|
|
705
|
+
e.Literal("EARLIEST"),
|
|
706
|
+
e.Literal("CUSTOM")
|
|
702
707
|
],
|
|
703
708
|
{ default: "LATEST", "x-nrg-form": { icon: "history" } }
|
|
704
709
|
),
|
|
705
|
-
replayId:
|
|
706
|
-
|
|
710
|
+
replayId: e.Optional(
|
|
711
|
+
e.String({
|
|
707
712
|
default: "",
|
|
708
713
|
"x-nrg-form": { icon: "bookmark" }
|
|
709
714
|
})
|
|
710
715
|
),
|
|
711
|
-
numRequested:
|
|
716
|
+
numRequested: e.Number({
|
|
712
717
|
default: 100,
|
|
713
718
|
minimum: 1,
|
|
714
719
|
maximum: 100,
|
|
715
720
|
"x-nrg-form": { icon: "sort-numeric-asc" }
|
|
716
721
|
}),
|
|
717
|
-
emitError:
|
|
718
|
-
emitStatus:
|
|
722
|
+
emitError: e.Boolean({ default: !1 }),
|
|
723
|
+
emitStatus: e.Boolean({ default: !1 })
|
|
719
724
|
},
|
|
720
725
|
{
|
|
721
726
|
$id: "salesforce-streaming:config",
|
|
722
|
-
if:
|
|
723
|
-
subscribeType:
|
|
727
|
+
if: e.Object({
|
|
728
|
+
subscribeType: e.Literal("CUSTOM")
|
|
724
729
|
}),
|
|
725
|
-
then:
|
|
726
|
-
replayId:
|
|
730
|
+
then: e.Object({
|
|
731
|
+
replayId: e.String({ minLength: 1 })
|
|
727
732
|
}),
|
|
728
733
|
errorMessage: {
|
|
729
734
|
properties: {
|
|
@@ -731,15 +736,15 @@ const gt = h(
|
|
|
731
736
|
}
|
|
732
737
|
}
|
|
733
738
|
}
|
|
734
|
-
),
|
|
739
|
+
), xe = h(
|
|
735
740
|
{
|
|
736
|
-
payload:
|
|
737
|
-
replayId:
|
|
738
|
-
channel:
|
|
739
|
-
topic:
|
|
741
|
+
payload: e.Any(),
|
|
742
|
+
replayId: e.Any(),
|
|
743
|
+
channel: e.String(),
|
|
744
|
+
topic: e.String()
|
|
740
745
|
},
|
|
741
746
|
{ $id: "salesforce-streaming:output" }
|
|
742
|
-
),
|
|
747
|
+
), w = class w extends k {
|
|
743
748
|
constructor() {
|
|
744
749
|
super(...arguments);
|
|
745
750
|
i(this, "client", null);
|
|
@@ -761,23 +766,23 @@ const gt = h(
|
|
|
761
766
|
if (!this.stopped)
|
|
762
767
|
try {
|
|
763
768
|
this.status({ fill: "green", shape: "dot", text: "connecting..." });
|
|
764
|
-
let
|
|
769
|
+
let t;
|
|
765
770
|
try {
|
|
766
|
-
|
|
771
|
+
t = await n.getConnection(), await t.identity();
|
|
767
772
|
} catch {
|
|
768
773
|
this.status({ fill: "red", shape: "dot", text: "auth expired" }), this.error("Salesforce token expired. Re-authorize the connection.");
|
|
769
774
|
return;
|
|
770
775
|
}
|
|
771
|
-
const
|
|
772
|
-
if (!
|
|
776
|
+
const r = n.getAccessToken(), s = n.getInstanceUrl();
|
|
777
|
+
if (!r || !s) {
|
|
773
778
|
this.status({ fill: "red", shape: "dot", text: "not authorized" }), this.error("Salesforce connection not authorized");
|
|
774
779
|
return;
|
|
775
780
|
}
|
|
776
781
|
const l = (await import("salesforce-pubsub-api-client")).default;
|
|
777
782
|
this.client = new l({
|
|
778
783
|
authType: "user-supplied",
|
|
779
|
-
accessToken:
|
|
780
|
-
instanceUrl:
|
|
784
|
+
accessToken: r,
|
|
785
|
+
instanceUrl: s
|
|
781
786
|
}), await this.client.connect();
|
|
782
787
|
const d = this.config.numRequested || null, c = this.config.channelName, g = /* @__PURE__ */ f((u, m, p) => {
|
|
783
788
|
if (m === "event" || m === "lastevent")
|
|
@@ -788,8 +793,8 @@ const gt = h(
|
|
|
788
793
|
topic: c
|
|
789
794
|
});
|
|
790
795
|
else if (m === "error") {
|
|
791
|
-
const
|
|
792
|
-
if (this.warn(`Streaming error: ${
|
|
796
|
+
const S = p instanceof Error ? p.message : String(p ?? "stream error");
|
|
797
|
+
if (this.warn(`Streaming error: ${S}`), S.includes("UNAUTHENTICATED") || S.includes("authentication")) {
|
|
793
798
|
this.stopped = !0, this.status({
|
|
794
799
|
fill: "red",
|
|
795
800
|
shape: "dot",
|
|
@@ -799,7 +804,7 @@ const gt = h(
|
|
|
799
804
|
), this.cleanup();
|
|
800
805
|
return;
|
|
801
806
|
}
|
|
802
|
-
this.status({ fill: "red", shape: "dot", text:
|
|
807
|
+
this.status({ fill: "red", shape: "dot", text: S }), this.scheduleReconnect(n);
|
|
803
808
|
} else if (m === "end") {
|
|
804
809
|
if (this.stopped) return;
|
|
805
810
|
this.log("Streaming subscription ended"), this.status({ fill: "red", shape: "dot", text: "disconnected" }), this.scheduleReconnect(n);
|
|
@@ -833,13 +838,13 @@ const gt = h(
|
|
|
833
838
|
shape: "dot",
|
|
834
839
|
text: `subscribed: ${c}`
|
|
835
840
|
}), this.reconnectAttempt = 0;
|
|
836
|
-
} catch (
|
|
841
|
+
} catch (t) {
|
|
837
842
|
this.status({
|
|
838
843
|
fill: "red",
|
|
839
844
|
shape: "dot",
|
|
840
|
-
text:
|
|
845
|
+
text: t instanceof Error ? t.message : String(t)
|
|
841
846
|
}), this.error(
|
|
842
|
-
`Streaming subscription failed: ${
|
|
847
|
+
`Streaming subscription failed: ${t instanceof Error ? t.message : String(t)}`
|
|
843
848
|
), this.scheduleReconnect(n);
|
|
844
849
|
}
|
|
845
850
|
}
|
|
@@ -855,73 +860,71 @@ const gt = h(
|
|
|
855
860
|
});
|
|
856
861
|
return;
|
|
857
862
|
}
|
|
858
|
-
const
|
|
863
|
+
const t = Math.min(
|
|
859
864
|
1e3 * Math.pow(2, this.reconnectAttempt),
|
|
860
865
|
this.maxReconnectDelay
|
|
861
866
|
);
|
|
862
867
|
this.log(
|
|
863
|
-
`Scheduling reconnect in ${
|
|
868
|
+
`Scheduling reconnect in ${t}ms (attempt ${this.reconnectAttempt}/${this.maxReconnectAttempts})`
|
|
864
869
|
), this.status({
|
|
865
870
|
fill: "green",
|
|
866
871
|
shape: "dot",
|
|
867
|
-
text: `reconnecting in ${Math.round(
|
|
872
|
+
text: `reconnecting in ${Math.round(t / 1e3)}s`
|
|
868
873
|
}), this.setTimeout(async () => {
|
|
869
874
|
await this.cleanup(), await this.subscribe(n);
|
|
870
|
-
},
|
|
875
|
+
}, t);
|
|
871
876
|
}
|
|
872
877
|
async cleanup() {
|
|
873
|
-
var n,
|
|
878
|
+
var n, t;
|
|
874
879
|
try {
|
|
875
|
-
this.grpcErrorHandler && (process.removeListener("uncaughtException", this.grpcErrorHandler), this.grpcErrorHandler = null), this.client && (await ((
|
|
880
|
+
this.grpcErrorHandler && (process.removeListener("uncaughtException", this.grpcErrorHandler), this.grpcErrorHandler = null), this.client && (await ((t = (n = this.client).close) == null ? void 0 : t.call(n)), this.client = null);
|
|
876
881
|
} catch {
|
|
877
882
|
}
|
|
878
883
|
}
|
|
879
|
-
async input() {
|
|
880
|
-
}
|
|
881
884
|
async closed() {
|
|
882
885
|
await this.cleanup();
|
|
883
886
|
}
|
|
884
887
|
};
|
|
885
|
-
f(
|
|
886
|
-
let v =
|
|
887
|
-
const
|
|
888
|
+
f(w, "SalesforceStreaming"), i(w, "type", "salesforce-streaming"), i(w, "category", "salesforce"), i(w, "color", "#FFFFFF"), i(w, "configSchema", ye), i(w, "outputsSchema", xe);
|
|
889
|
+
let v = w;
|
|
890
|
+
const be = h(
|
|
888
891
|
{
|
|
889
|
-
name:
|
|
890
|
-
connection:
|
|
892
|
+
name: e.String({ default: "", "x-nrg-form": { icon: "tag" } }),
|
|
893
|
+
connection: e.NodeRef($, {
|
|
891
894
|
"x-nrg-form": { icon: "cloud" }
|
|
892
895
|
}),
|
|
893
|
-
method:
|
|
896
|
+
method: e.Union(
|
|
894
897
|
[
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
898
|
+
e.Literal("GET"),
|
|
899
|
+
e.Literal("POST"),
|
|
900
|
+
e.Literal("PUT"),
|
|
901
|
+
e.Literal("PATCH"),
|
|
902
|
+
e.Literal("DELETE")
|
|
900
903
|
],
|
|
901
904
|
{ default: "POST", "x-nrg-form": { icon: "random" } }
|
|
902
905
|
),
|
|
903
|
-
path:
|
|
906
|
+
path: e.TypedInput({
|
|
904
907
|
"x-nrg-form": {
|
|
905
908
|
icon: "link",
|
|
906
909
|
typedInputTypes: ["str", "msg"]
|
|
907
910
|
}
|
|
908
911
|
}),
|
|
909
|
-
emitError:
|
|
910
|
-
emitComplete:
|
|
911
|
-
emitStatus:
|
|
912
|
+
emitError: e.Boolean({ default: !1 }),
|
|
913
|
+
emitComplete: e.Boolean({ default: !1 }),
|
|
914
|
+
emitStatus: e.Boolean({ default: !1 })
|
|
912
915
|
},
|
|
913
916
|
{ $id: "salesforce-apex:config" }
|
|
914
|
-
),
|
|
917
|
+
), Te = h(
|
|
915
918
|
{
|
|
916
|
-
payload:
|
|
919
|
+
payload: e.Any()
|
|
917
920
|
},
|
|
918
921
|
{ $id: "salesforce-apex:input" }
|
|
919
|
-
),
|
|
922
|
+
), Ie = h(
|
|
920
923
|
{
|
|
921
|
-
payload:
|
|
924
|
+
payload: e.Any()
|
|
922
925
|
},
|
|
923
926
|
{ $id: "salesforce-apex:output" }
|
|
924
|
-
),
|
|
927
|
+
), I = class I extends k {
|
|
925
928
|
async input(o) {
|
|
926
929
|
const n = this.config.connection;
|
|
927
930
|
if (!n) {
|
|
@@ -929,40 +932,40 @@ const yt = h(
|
|
|
929
932
|
return;
|
|
930
933
|
}
|
|
931
934
|
try {
|
|
932
|
-
const
|
|
933
|
-
this.status({ fill: "green", shape: "dot", text: `${
|
|
934
|
-
const
|
|
935
|
+
const t = this.config.method;
|
|
936
|
+
this.status({ fill: "green", shape: "dot", text: `${t}...` });
|
|
937
|
+
const r = await n.getConnection(), s = await this.config.path.resolve(o);
|
|
935
938
|
let l;
|
|
936
|
-
const d =
|
|
937
|
-
d === "get" || d === "delete" ? l = await
|
|
938
|
-
} catch (
|
|
939
|
+
const d = t.toLowerCase();
|
|
940
|
+
d === "get" || d === "delete" ? l = await r.apex[d](s) : l = await r.apex[d](s, o.payload), this.status({ fill: "green", shape: "dot", text: `${t} done` }), this.send({ ...o, payload: l });
|
|
941
|
+
} catch (t) {
|
|
939
942
|
this.status({
|
|
940
943
|
fill: "red",
|
|
941
944
|
shape: "dot",
|
|
942
|
-
text:
|
|
945
|
+
text: t instanceof Error ? t.message : String(t)
|
|
943
946
|
}), this.error(
|
|
944
|
-
`Apex ${this.config.method} failed: ${
|
|
947
|
+
`Apex ${this.config.method} failed: ${t instanceof Error ? t.message : String(t)}`,
|
|
945
948
|
o
|
|
946
949
|
);
|
|
947
950
|
}
|
|
948
951
|
}
|
|
949
952
|
};
|
|
950
|
-
f(
|
|
951
|
-
let N =
|
|
952
|
-
const
|
|
953
|
+
f(I, "SalesforceApex"), i(I, "type", "salesforce-apex"), i(I, "category", "salesforce"), i(I, "color", "#FFFFFF"), i(I, "configSchema", be), i(I, "inputSchema", Te), i(I, "outputsSchema", Ie);
|
|
954
|
+
let N = I;
|
|
955
|
+
const $e = Y({
|
|
953
956
|
nodes: [
|
|
954
|
-
|
|
957
|
+
$,
|
|
958
|
+
C,
|
|
955
959
|
R,
|
|
956
|
-
S,
|
|
957
960
|
O,
|
|
958
961
|
j,
|
|
959
962
|
v,
|
|
960
963
|
N
|
|
961
964
|
]
|
|
962
965
|
});
|
|
963
|
-
var
|
|
964
|
-
|
|
966
|
+
var F = $e;
|
|
967
|
+
F && typeof F == "object" && Array.isArray(F.nodes) && (F = G(F.nodes));
|
|
965
968
|
export {
|
|
966
|
-
|
|
969
|
+
F as default
|
|
967
970
|
};
|
|
968
971
|
//# sourceMappingURL=index.mjs.map
|