@bonsae/node-red-salesforce 0.2.0 → 0.3.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 +1 -13
- package/index.html +1 -1
- package/index.mjs +306 -299
- package/index.mjs.map +1 -1
- package/package.json +2 -2
- package/resources/index.e3npw131.js +1 -0
- package/resources/index.DheUFZEA.js +0 -1
package/index.mjs
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
var P = Object.defineProperty;
|
|
2
2
|
var B = (a, o, n) => o in a ? P(a, o, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[o] = n;
|
|
3
3
|
var f = (a, o) => P(a, "name", { value: o, configurable: !0 });
|
|
4
|
-
var
|
|
4
|
+
var s = (a, o, n) => B(a, typeof o != "symbol" ? o + "" : o, n);
|
|
5
5
|
import { fileURLToPath as q } 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 A, defineModule as Y } from "@bonsae/nrg/server";
|
|
9
9
|
import K from "jsforce";
|
|
10
10
|
import M from "node:crypto";
|
|
11
|
-
var V = q(import.meta.url),
|
|
11
|
+
var V = q(import.meta.url), Ae = 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, F = /* @__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
|
+
F.set(o, {
|
|
63
63
|
codeVerifier: n,
|
|
64
64
|
nodeId: a.nodeId,
|
|
65
65
|
clientId: a.clientId,
|
|
@@ -67,44 +67,44 @@ function _(a) {
|
|
|
67
67
|
callbackUrl: a.callbackUrl,
|
|
68
68
|
timestamp: Date.now()
|
|
69
69
|
});
|
|
70
|
-
for (const [
|
|
71
|
-
Date.now() - r.timestamp > H &&
|
|
72
|
-
return { state: o, codeChallenge:
|
|
70
|
+
for (const [i, r] of F)
|
|
71
|
+
Date.now() - r.timestamp > H && F.delete(i);
|
|
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 = F.get(a);
|
|
77
|
+
return !o || (F.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 k(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(k, "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:
|
|
97
|
+
nodeId: i,
|
|
98
98
|
loginUrl: r,
|
|
99
99
|
clientId: l,
|
|
100
100
|
callbackUrl: d
|
|
101
101
|
} = n.body;
|
|
102
|
-
if (!
|
|
103
|
-
|
|
102
|
+
if (!i || !r || !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: i,
|
|
108
108
|
clientId: l,
|
|
109
109
|
loginUrl: r,
|
|
110
110
|
callbackUrl: c
|
|
@@ -116,31 +116,31 @@ function nt(a) {
|
|
|
116
116
|
code_challenge: u,
|
|
117
117
|
code_challenge_method: "S256"
|
|
118
118
|
});
|
|
119
|
-
|
|
119
|
+
t.json({
|
|
120
120
|
authorizationUrl: `${r}/services/oauth2/authorize?${m.toString()}`
|
|
121
121
|
});
|
|
122
|
-
} catch (
|
|
122
|
+
} catch (i) {
|
|
123
123
|
a.log.error(
|
|
124
|
-
`salesforce-connection: auth/start error: ${
|
|
125
|
-
),
|
|
124
|
+
`salesforce-connection: auth/start error: ${i instanceof Error ? i.message : String(i)}`
|
|
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: i, state: r, 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(k(String(d || l)));
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
|
-
if (!
|
|
137
|
-
|
|
136
|
+
if (!i || !r) {
|
|
137
|
+
t.status(400).send(k("Missing code or state parameter"));
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
|
-
const c =
|
|
140
|
+
const c = ee(r);
|
|
141
141
|
if (!c) {
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
t.status(400).send(
|
|
143
|
+
k(
|
|
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: i,
|
|
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
|
+
k(
|
|
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 (i) {
|
|
203
203
|
a.log.error(
|
|
204
|
-
`salesforce-connection: auth/callback error: ${
|
|
205
|
-
),
|
|
204
|
+
`salesforce-connection: auth/callback error: ${i instanceof Error ? i.message : String(i)}`
|
|
205
|
+
), t.status(500).send(k("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
|
-
|
|
209
|
+
const i = a.nodes.getCredentials(n.params.nodeId), r = !!(i != null && i.accessToken && (i != null && i.instanceUrl));
|
|
210
|
+
t.json({
|
|
211
211
|
authenticated: r,
|
|
212
|
-
instanceUrl: r ?
|
|
212
|
+
instanceUrl: r ? i.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
|
+
s(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"), s(L, "type", "salesforce-connection"), s(L, "configSchema", W), s(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,16 +280,16 @@ const it = h(
|
|
|
280
280
|
})
|
|
281
281
|
},
|
|
282
282
|
{ $id: "salesforce-soql:config" }
|
|
283
|
-
),
|
|
283
|
+
), se = h(
|
|
284
284
|
{
|
|
285
|
-
payload:
|
|
285
|
+
payload: e.Any()
|
|
286
286
|
},
|
|
287
287
|
{ $id: "salesforce-soql:input" }
|
|
288
|
-
),
|
|
288
|
+
), re = 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
295
|
), y = class y extends A {
|
|
@@ -301,7 +301,7 @@ 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(), i = await this.config.query.resolve(o), r = await t.query(i);
|
|
305
305
|
this.status({
|
|
306
306
|
fill: "green",
|
|
307
307
|
shape: "dot",
|
|
@@ -312,65 +312,65 @@ const it = h(
|
|
|
312
312
|
totalSize: r.totalSize,
|
|
313
313
|
done: r.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"),
|
|
328
|
-
let
|
|
329
|
-
const
|
|
327
|
+
f(y, "SalesforceSoql"), s(y, "type", "salesforce-soql"), s(y, "category", "salesforce"), s(y, "color", "#FFFFFF"), s(y, "configSchema", ie), s(y, "inputSchema", se), s(y, "outputsSchema", re);
|
|
328
|
+
let U = 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,14 +378,14 @@ 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
391
|
), x = class x extends A {
|
|
@@ -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 i = await n.getConnection(), r = await this.config.sObjectType.resolve(o), l = i.sobject(r), 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,98 @@ 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"),
|
|
436
|
-
let
|
|
437
|
-
const
|
|
435
|
+
f(x, "SalesforceDml"), s(x, "type", "salesforce-dml"), s(x, "category", "salesforce"), s(x, "color", "#FFFFFF"), s(x, "configSchema", ae), s(x, "inputSchema", ce), s(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
|
-
emitJobCreated:
|
|
496
|
+
emitJobCreated: e.Boolean({
|
|
497
497
|
default: !1,
|
|
498
498
|
"x-nrg-form": { icon: "flag", toggle: !0 }
|
|
499
499
|
}),
|
|
500
|
-
outputs:
|
|
501
|
-
emitError:
|
|
502
|
-
emitComplete:
|
|
503
|
-
emitStatus:
|
|
500
|
+
outputs: e.Number({ default: 2 }),
|
|
501
|
+
emitError: e.Boolean({ default: !1 }),
|
|
502
|
+
emitComplete: e.Boolean({ default: !1 }),
|
|
503
|
+
emitStatus: e.Boolean({ default: !1 })
|
|
504
504
|
},
|
|
505
505
|
{
|
|
506
506
|
$id: "salesforce-bulk:config",
|
|
507
|
-
if:
|
|
508
|
-
operation:
|
|
507
|
+
if: e.Object({
|
|
508
|
+
operation: e.Literal("upsert")
|
|
509
509
|
}),
|
|
510
|
-
then:
|
|
511
|
-
externalIdField:
|
|
510
|
+
then: e.Object({
|
|
511
|
+
externalIdField: e.String({ minLength: 1 })
|
|
512
512
|
}),
|
|
513
513
|
errorMessage: {
|
|
514
514
|
properties: {
|
|
@@ -516,29 +516,35 @@ const dt = h(
|
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
|
-
),
|
|
519
|
+
), ue = h(
|
|
520
520
|
{
|
|
521
|
-
payload:
|
|
521
|
+
payload: e.Any()
|
|
522
522
|
},
|
|
523
523
|
{ $id: "salesforce-bulk:input" }
|
|
524
524
|
);
|
|
525
525
|
h(
|
|
526
526
|
{
|
|
527
|
-
payload:
|
|
527
|
+
payload: e.Array(e.Any())
|
|
528
528
|
},
|
|
529
529
|
{ $id: "salesforce-bulk:output" }
|
|
530
530
|
);
|
|
531
|
-
const
|
|
531
|
+
const he = h(
|
|
532
|
+
{},
|
|
533
|
+
{ $id: "salesforce-bulk:output-port-1" }
|
|
534
|
+
), pe = h(
|
|
535
|
+
{},
|
|
536
|
+
{ $id: "salesforce-bulk:output-port-2" }
|
|
537
|
+
), b = class b extends A {
|
|
532
538
|
sendRecord(o, n) {
|
|
533
|
-
const
|
|
534
|
-
|
|
539
|
+
const t = this.config.emitJobCreated ? 3 : 2, i = Array(t).fill(null);
|
|
540
|
+
i[0] = { ...o, payload: n }, this.send(i);
|
|
535
541
|
}
|
|
536
542
|
sendJobCreated(o, n) {
|
|
537
543
|
this.config.emitJobCreated && this.send([null, null, { ...o, payload: n }]);
|
|
538
544
|
}
|
|
539
545
|
sendComplete(o, n) {
|
|
540
|
-
const
|
|
541
|
-
|
|
546
|
+
const t = this.config.emitJobCreated ? 3 : 2, i = Array(t).fill(null);
|
|
547
|
+
i[1] = { ...o, payload: n }, this.send(i);
|
|
542
548
|
}
|
|
543
549
|
async input(o) {
|
|
544
550
|
const n = this.config.connection;
|
|
@@ -547,16 +553,16 @@ const I = class I extends A {
|
|
|
547
553
|
return;
|
|
548
554
|
}
|
|
549
555
|
try {
|
|
550
|
-
const
|
|
556
|
+
const t = this.config.operation;
|
|
551
557
|
this.status({
|
|
552
558
|
fill: "green",
|
|
553
559
|
shape: "dot",
|
|
554
|
-
text: `bulk ${
|
|
560
|
+
text: `bulk ${t}...`
|
|
555
561
|
});
|
|
556
|
-
const
|
|
562
|
+
const i = await n.getConnection(), r = await this.config.sObjectType.resolve(o);
|
|
557
563
|
let l = 0;
|
|
558
|
-
if (
|
|
559
|
-
const d = await
|
|
564
|
+
if (t === "query") {
|
|
565
|
+
const d = await i.bulk2.query(o.payload, {
|
|
560
566
|
pollTimeout: this.config.pollTimeout,
|
|
561
567
|
pollInterval: this.config.pollInterval,
|
|
562
568
|
columnDelimiter: this.config.columnDelimiter,
|
|
@@ -569,85 +575,88 @@ const I = class I extends A {
|
|
|
569
575
|
}), this.status({
|
|
570
576
|
fill: "green",
|
|
571
577
|
shape: "dot",
|
|
572
|
-
text: `bulk ${
|
|
573
|
-
}), this.sendComplete(o, { operation:
|
|
578
|
+
text: `bulk ${t}: ${l} records`
|
|
579
|
+
}), this.sendComplete(o, { operation: t, sObjectType: r, totalRecords: l });
|
|
574
580
|
} else {
|
|
575
|
-
const d = o.payload, c =
|
|
576
|
-
operation:
|
|
581
|
+
const d = o.payload, c = i.bulk2.createJob({
|
|
582
|
+
operation: t,
|
|
577
583
|
object: r,
|
|
578
584
|
columnDelimiter: this.config.columnDelimiter,
|
|
579
585
|
lineEnding: this.config.lineEnding,
|
|
580
|
-
...
|
|
586
|
+
...t === "upsert" && this.config.externalIdField ? { externalIdFieldName: this.config.externalIdField } : {},
|
|
581
587
|
...this.config.assignmentRuleId ? { assignmentRuleId: this.config.assignmentRuleId } : {}
|
|
582
588
|
});
|
|
583
589
|
await c.open(), this.sendJobCreated(o, {
|
|
584
590
|
jobId: c.id,
|
|
585
|
-
operation:
|
|
591
|
+
operation: t,
|
|
586
592
|
sObjectType: r,
|
|
587
593
|
state: "Open"
|
|
588
594
|
}), await c.uploadData(d), await c.close(), await c.poll(this.config.pollInterval, this.config.pollTimeout);
|
|
589
595
|
const g = await c.getAllResults(), u = g.successfulResults ?? [], m = g.failedResults ?? [], p = g.unprocessedRecords ?? [];
|
|
590
596
|
l = u.length + m.length + p.length;
|
|
591
|
-
for (const
|
|
592
|
-
this.sendRecord(o,
|
|
593
|
-
for (const
|
|
594
|
-
this.sendRecord(o,
|
|
595
|
-
const
|
|
597
|
+
for (const E of u)
|
|
598
|
+
this.sendRecord(o, E);
|
|
599
|
+
for (const E of m)
|
|
600
|
+
this.sendRecord(o, E);
|
|
601
|
+
const S = u.length, z = m.length;
|
|
596
602
|
this.status({
|
|
597
603
|
fill: z > 0 ? "red" : "green",
|
|
598
604
|
shape: "dot",
|
|
599
|
-
text: `bulk ${
|
|
605
|
+
text: `bulk ${t}: ${l} records`
|
|
600
606
|
}), this.sendComplete(o, {
|
|
601
607
|
jobId: c.id,
|
|
602
|
-
operation:
|
|
608
|
+
operation: t,
|
|
603
609
|
sObjectType: r,
|
|
604
610
|
totalRecords: l,
|
|
605
|
-
successCount:
|
|
611
|
+
successCount: S,
|
|
606
612
|
failureCount: z,
|
|
607
613
|
unprocessedCount: p.length
|
|
608
614
|
});
|
|
609
615
|
}
|
|
610
|
-
} catch (
|
|
611
|
-
const
|
|
612
|
-
this.status({ fill: "red", shape: "dot", text:
|
|
616
|
+
} catch (t) {
|
|
617
|
+
const i = t instanceof Error ? t.message : String(t);
|
|
618
|
+
this.status({ fill: "red", shape: "dot", text: i }), this.error(`Bulk ${this.config.operation} failed: ${i}`, o);
|
|
613
619
|
}
|
|
614
620
|
}
|
|
615
621
|
};
|
|
616
|
-
f(
|
|
617
|
-
|
|
618
|
-
|
|
622
|
+
f(b, "SalesforceBulk"), s(b, "type", "salesforce-bulk"), s(b, "category", "salesforce"), s(b, "color", "#FFFFFF"), s(b, "configSchema", de), s(b, "inputSchema", ue), s(b, "outputsSchema", [
|
|
623
|
+
he,
|
|
624
|
+
pe
|
|
625
|
+
]);
|
|
626
|
+
let O = b;
|
|
627
|
+
const fe = h(
|
|
619
628
|
{
|
|
620
|
-
name:
|
|
621
|
-
connection:
|
|
629
|
+
name: e.String({ default: "", "x-nrg-form": { icon: "tag" } }),
|
|
630
|
+
connection: e.NodeRef($, {
|
|
622
631
|
"x-nrg-form": { icon: "cloud" }
|
|
623
632
|
}),
|
|
624
|
-
sObjectType:
|
|
633
|
+
sObjectType: e.TypedInput({
|
|
625
634
|
"x-nrg-form": {
|
|
626
635
|
icon: "cube",
|
|
627
636
|
typedInputTypes: ["str", "msg"]
|
|
628
637
|
}
|
|
629
638
|
}),
|
|
630
|
-
emitError:
|
|
631
|
-
emitComplete:
|
|
632
|
-
emitStatus:
|
|
639
|
+
emitError: e.Boolean({ default: !1 }),
|
|
640
|
+
emitComplete: e.Boolean({ default: !1 }),
|
|
641
|
+
emitStatus: e.Boolean({ default: !1 })
|
|
633
642
|
},
|
|
634
643
|
{ $id: "salesforce-describe:config" }
|
|
635
|
-
),
|
|
644
|
+
), ge = h(
|
|
636
645
|
{
|
|
637
|
-
payload:
|
|
646
|
+
payload: e.Any()
|
|
638
647
|
},
|
|
639
648
|
{ $id: "salesforce-describe:input" }
|
|
640
|
-
),
|
|
649
|
+
), me = h(
|
|
641
650
|
{
|
|
642
|
-
payload:
|
|
643
|
-
name:
|
|
644
|
-
fields:
|
|
645
|
-
childRelationships:
|
|
646
|
-
recordTypeInfos:
|
|
651
|
+
payload: e.Object({
|
|
652
|
+
name: e.String(),
|
|
653
|
+
fields: e.Array(e.Any()),
|
|
654
|
+
childRelationships: e.Array(e.Any()),
|
|
655
|
+
recordTypeInfos: e.Array(e.Any())
|
|
647
656
|
})
|
|
648
657
|
},
|
|
649
658
|
{ $id: "salesforce-describe:output" }
|
|
650
|
-
),
|
|
659
|
+
), T = class T extends A {
|
|
651
660
|
async input(o) {
|
|
652
661
|
const n = this.config.connection;
|
|
653
662
|
if (!n) {
|
|
@@ -656,7 +665,7 @@ const ht = h(
|
|
|
656
665
|
}
|
|
657
666
|
try {
|
|
658
667
|
this.status({ fill: "green", shape: "dot", text: "describing..." });
|
|
659
|
-
const
|
|
668
|
+
const t = await n.getConnection(), i = await this.config.sObjectType.resolve(o), r = await t.sobject(i).describe();
|
|
660
669
|
this.status({
|
|
661
670
|
fill: "green",
|
|
662
671
|
shape: "dot",
|
|
@@ -670,60 +679,60 @@ const ht = h(
|
|
|
670
679
|
recordTypeInfos: r.recordTypeInfos
|
|
671
680
|
}
|
|
672
681
|
});
|
|
673
|
-
} catch (
|
|
682
|
+
} catch (t) {
|
|
674
683
|
this.status({
|
|
675
684
|
fill: "red",
|
|
676
685
|
shape: "dot",
|
|
677
|
-
text:
|
|
686
|
+
text: t instanceof Error ? t.message : String(t)
|
|
678
687
|
}), this.error(
|
|
679
|
-
`Describe failed: ${
|
|
688
|
+
`Describe failed: ${t instanceof Error ? t.message : String(t)}`,
|
|
680
689
|
o
|
|
681
690
|
);
|
|
682
691
|
}
|
|
683
692
|
}
|
|
684
693
|
};
|
|
685
|
-
f(
|
|
686
|
-
let j =
|
|
687
|
-
const
|
|
694
|
+
f(T, "SalesforceDescribe"), s(T, "type", "salesforce-describe"), s(T, "category", "salesforce"), s(T, "color", "#FFFFFF"), s(T, "configSchema", fe), s(T, "inputSchema", ge), s(T, "outputsSchema", me);
|
|
695
|
+
let j = T;
|
|
696
|
+
const ye = h(
|
|
688
697
|
{
|
|
689
|
-
name:
|
|
690
|
-
connection:
|
|
698
|
+
name: e.String({ default: "", "x-nrg-form": { icon: "tag" } }),
|
|
699
|
+
connection: e.NodeRef($, {
|
|
691
700
|
"x-nrg-form": { icon: "cloud" }
|
|
692
701
|
}),
|
|
693
|
-
channelName:
|
|
702
|
+
channelName: e.String({
|
|
694
703
|
default: "",
|
|
695
704
|
"x-nrg-form": { icon: "rss" }
|
|
696
705
|
}),
|
|
697
|
-
subscribeType:
|
|
706
|
+
subscribeType: e.Union(
|
|
698
707
|
[
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
708
|
+
e.Literal("LATEST"),
|
|
709
|
+
e.Literal("EARLIEST"),
|
|
710
|
+
e.Literal("CUSTOM")
|
|
702
711
|
],
|
|
703
712
|
{ default: "LATEST", "x-nrg-form": { icon: "history" } }
|
|
704
713
|
),
|
|
705
|
-
replayId:
|
|
706
|
-
|
|
714
|
+
replayId: e.Optional(
|
|
715
|
+
e.String({
|
|
707
716
|
default: "",
|
|
708
717
|
"x-nrg-form": { icon: "bookmark" }
|
|
709
718
|
})
|
|
710
719
|
),
|
|
711
|
-
numRequested:
|
|
720
|
+
numRequested: e.Number({
|
|
712
721
|
default: 100,
|
|
713
722
|
minimum: 1,
|
|
714
723
|
maximum: 100,
|
|
715
724
|
"x-nrg-form": { icon: "sort-numeric-asc" }
|
|
716
725
|
}),
|
|
717
|
-
emitError:
|
|
718
|
-
emitStatus:
|
|
726
|
+
emitError: e.Boolean({ default: !1 }),
|
|
727
|
+
emitStatus: e.Boolean({ default: !1 })
|
|
719
728
|
},
|
|
720
729
|
{
|
|
721
730
|
$id: "salesforce-streaming:config",
|
|
722
|
-
if:
|
|
723
|
-
subscribeType:
|
|
731
|
+
if: e.Object({
|
|
732
|
+
subscribeType: e.Literal("CUSTOM")
|
|
724
733
|
}),
|
|
725
|
-
then:
|
|
726
|
-
replayId:
|
|
734
|
+
then: e.Object({
|
|
735
|
+
replayId: e.String({ minLength: 1 })
|
|
727
736
|
}),
|
|
728
737
|
errorMessage: {
|
|
729
738
|
properties: {
|
|
@@ -731,23 +740,23 @@ const gt = h(
|
|
|
731
740
|
}
|
|
732
741
|
}
|
|
733
742
|
}
|
|
734
|
-
),
|
|
743
|
+
), xe = h(
|
|
735
744
|
{
|
|
736
|
-
payload:
|
|
737
|
-
replayId:
|
|
738
|
-
channel:
|
|
739
|
-
topic:
|
|
745
|
+
payload: e.Any(),
|
|
746
|
+
replayId: e.Any(),
|
|
747
|
+
channel: e.String(),
|
|
748
|
+
topic: e.String()
|
|
740
749
|
},
|
|
741
750
|
{ $id: "salesforce-streaming:output" }
|
|
742
|
-
),
|
|
751
|
+
), w = class w extends A {
|
|
743
752
|
constructor() {
|
|
744
753
|
super(...arguments);
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
754
|
+
s(this, "client", null);
|
|
755
|
+
s(this, "reconnectAttempt", 0);
|
|
756
|
+
s(this, "maxReconnectDelay", 6e4);
|
|
757
|
+
s(this, "maxReconnectAttempts", 10);
|
|
758
|
+
s(this, "grpcErrorHandler", null);
|
|
759
|
+
s(this, "stopped", !1);
|
|
751
760
|
}
|
|
752
761
|
async created() {
|
|
753
762
|
const n = this.config.connection;
|
|
@@ -761,22 +770,22 @@ const gt = h(
|
|
|
761
770
|
if (!this.stopped)
|
|
762
771
|
try {
|
|
763
772
|
this.status({ fill: "green", shape: "dot", text: "connecting..." });
|
|
764
|
-
let
|
|
773
|
+
let t;
|
|
765
774
|
try {
|
|
766
|
-
|
|
775
|
+
t = await n.getConnection(), await t.identity();
|
|
767
776
|
} catch {
|
|
768
777
|
this.status({ fill: "red", shape: "dot", text: "auth expired" }), this.error("Salesforce token expired. Re-authorize the connection.");
|
|
769
778
|
return;
|
|
770
779
|
}
|
|
771
|
-
const
|
|
772
|
-
if (!
|
|
780
|
+
const i = n.getAccessToken(), r = n.getInstanceUrl();
|
|
781
|
+
if (!i || !r) {
|
|
773
782
|
this.status({ fill: "red", shape: "dot", text: "not authorized" }), this.error("Salesforce connection not authorized");
|
|
774
783
|
return;
|
|
775
784
|
}
|
|
776
785
|
const l = (await import("salesforce-pubsub-api-client")).default;
|
|
777
786
|
this.client = new l({
|
|
778
787
|
authType: "user-supplied",
|
|
779
|
-
accessToken:
|
|
788
|
+
accessToken: i,
|
|
780
789
|
instanceUrl: r
|
|
781
790
|
}), await this.client.connect();
|
|
782
791
|
const d = this.config.numRequested || null, c = this.config.channelName, g = /* @__PURE__ */ f((u, m, p) => {
|
|
@@ -788,8 +797,8 @@ const gt = h(
|
|
|
788
797
|
topic: c
|
|
789
798
|
});
|
|
790
799
|
else if (m === "error") {
|
|
791
|
-
const
|
|
792
|
-
if (this.warn(`Streaming error: ${
|
|
800
|
+
const S = p instanceof Error ? p.message : String(p ?? "stream error");
|
|
801
|
+
if (this.warn(`Streaming error: ${S}`), S.includes("UNAUTHENTICATED") || S.includes("authentication")) {
|
|
793
802
|
this.stopped = !0, this.status({
|
|
794
803
|
fill: "red",
|
|
795
804
|
shape: "dot",
|
|
@@ -799,7 +808,7 @@ const gt = h(
|
|
|
799
808
|
), this.cleanup();
|
|
800
809
|
return;
|
|
801
810
|
}
|
|
802
|
-
this.status({ fill: "red", shape: "dot", text:
|
|
811
|
+
this.status({ fill: "red", shape: "dot", text: S }), this.scheduleReconnect(n);
|
|
803
812
|
} else if (m === "end") {
|
|
804
813
|
if (this.stopped) return;
|
|
805
814
|
this.log("Streaming subscription ended"), this.status({ fill: "red", shape: "dot", text: "disconnected" }), this.scheduleReconnect(n);
|
|
@@ -833,13 +842,13 @@ const gt = h(
|
|
|
833
842
|
shape: "dot",
|
|
834
843
|
text: `subscribed: ${c}`
|
|
835
844
|
}), this.reconnectAttempt = 0;
|
|
836
|
-
} catch (
|
|
845
|
+
} catch (t) {
|
|
837
846
|
this.status({
|
|
838
847
|
fill: "red",
|
|
839
848
|
shape: "dot",
|
|
840
|
-
text:
|
|
849
|
+
text: t instanceof Error ? t.message : String(t)
|
|
841
850
|
}), this.error(
|
|
842
|
-
`Streaming subscription failed: ${
|
|
851
|
+
`Streaming subscription failed: ${t instanceof Error ? t.message : String(t)}`
|
|
843
852
|
), this.scheduleReconnect(n);
|
|
844
853
|
}
|
|
845
854
|
}
|
|
@@ -855,73 +864,71 @@ const gt = h(
|
|
|
855
864
|
});
|
|
856
865
|
return;
|
|
857
866
|
}
|
|
858
|
-
const
|
|
867
|
+
const t = Math.min(
|
|
859
868
|
1e3 * Math.pow(2, this.reconnectAttempt),
|
|
860
869
|
this.maxReconnectDelay
|
|
861
870
|
);
|
|
862
871
|
this.log(
|
|
863
|
-
`Scheduling reconnect in ${
|
|
872
|
+
`Scheduling reconnect in ${t}ms (attempt ${this.reconnectAttempt}/${this.maxReconnectAttempts})`
|
|
864
873
|
), this.status({
|
|
865
874
|
fill: "green",
|
|
866
875
|
shape: "dot",
|
|
867
|
-
text: `reconnecting in ${Math.round(
|
|
876
|
+
text: `reconnecting in ${Math.round(t / 1e3)}s`
|
|
868
877
|
}), this.setTimeout(async () => {
|
|
869
878
|
await this.cleanup(), await this.subscribe(n);
|
|
870
|
-
},
|
|
879
|
+
}, t);
|
|
871
880
|
}
|
|
872
881
|
async cleanup() {
|
|
873
|
-
var n,
|
|
882
|
+
var n, t;
|
|
874
883
|
try {
|
|
875
|
-
this.grpcErrorHandler && (process.removeListener("uncaughtException", this.grpcErrorHandler), this.grpcErrorHandler = null), this.client && (await ((
|
|
884
|
+
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
885
|
} catch {
|
|
877
886
|
}
|
|
878
887
|
}
|
|
879
|
-
async input() {
|
|
880
|
-
}
|
|
881
888
|
async closed() {
|
|
882
889
|
await this.cleanup();
|
|
883
890
|
}
|
|
884
891
|
};
|
|
885
|
-
f(
|
|
886
|
-
let v =
|
|
887
|
-
const
|
|
892
|
+
f(w, "SalesforceStreaming"), s(w, "type", "salesforce-streaming"), s(w, "category", "salesforce"), s(w, "color", "#FFFFFF"), s(w, "configSchema", ye), s(w, "outputsSchema", xe);
|
|
893
|
+
let v = w;
|
|
894
|
+
const be = h(
|
|
888
895
|
{
|
|
889
|
-
name:
|
|
890
|
-
connection:
|
|
896
|
+
name: e.String({ default: "", "x-nrg-form": { icon: "tag" } }),
|
|
897
|
+
connection: e.NodeRef($, {
|
|
891
898
|
"x-nrg-form": { icon: "cloud" }
|
|
892
899
|
}),
|
|
893
|
-
method:
|
|
900
|
+
method: e.Union(
|
|
894
901
|
[
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
902
|
+
e.Literal("GET"),
|
|
903
|
+
e.Literal("POST"),
|
|
904
|
+
e.Literal("PUT"),
|
|
905
|
+
e.Literal("PATCH"),
|
|
906
|
+
e.Literal("DELETE")
|
|
900
907
|
],
|
|
901
908
|
{ default: "POST", "x-nrg-form": { icon: "random" } }
|
|
902
909
|
),
|
|
903
|
-
path:
|
|
910
|
+
path: e.TypedInput({
|
|
904
911
|
"x-nrg-form": {
|
|
905
912
|
icon: "link",
|
|
906
913
|
typedInputTypes: ["str", "msg"]
|
|
907
914
|
}
|
|
908
915
|
}),
|
|
909
|
-
emitError:
|
|
910
|
-
emitComplete:
|
|
911
|
-
emitStatus:
|
|
916
|
+
emitError: e.Boolean({ default: !1 }),
|
|
917
|
+
emitComplete: e.Boolean({ default: !1 }),
|
|
918
|
+
emitStatus: e.Boolean({ default: !1 })
|
|
912
919
|
},
|
|
913
920
|
{ $id: "salesforce-apex:config" }
|
|
914
|
-
),
|
|
921
|
+
), Te = h(
|
|
915
922
|
{
|
|
916
|
-
payload:
|
|
923
|
+
payload: e.Any()
|
|
917
924
|
},
|
|
918
925
|
{ $id: "salesforce-apex:input" }
|
|
919
|
-
),
|
|
926
|
+
), Ie = h(
|
|
920
927
|
{
|
|
921
|
-
payload:
|
|
928
|
+
payload: e.Any()
|
|
922
929
|
},
|
|
923
930
|
{ $id: "salesforce-apex:output" }
|
|
924
|
-
),
|
|
931
|
+
), I = class I extends A {
|
|
925
932
|
async input(o) {
|
|
926
933
|
const n = this.config.connection;
|
|
927
934
|
if (!n) {
|
|
@@ -929,40 +936,40 @@ const yt = h(
|
|
|
929
936
|
return;
|
|
930
937
|
}
|
|
931
938
|
try {
|
|
932
|
-
const
|
|
933
|
-
this.status({ fill: "green", shape: "dot", text: `${
|
|
934
|
-
const
|
|
939
|
+
const t = this.config.method;
|
|
940
|
+
this.status({ fill: "green", shape: "dot", text: `${t}...` });
|
|
941
|
+
const i = await n.getConnection(), r = await this.config.path.resolve(o);
|
|
935
942
|
let l;
|
|
936
|
-
const d =
|
|
937
|
-
d === "get" || d === "delete" ? l = await
|
|
938
|
-
} catch (
|
|
943
|
+
const d = t.toLowerCase();
|
|
944
|
+
d === "get" || d === "delete" ? l = await i.apex[d](r) : l = await i.apex[d](r, o.payload), this.status({ fill: "green", shape: "dot", text: `${t} done` }), this.send({ ...o, payload: l });
|
|
945
|
+
} catch (t) {
|
|
939
946
|
this.status({
|
|
940
947
|
fill: "red",
|
|
941
948
|
shape: "dot",
|
|
942
|
-
text:
|
|
949
|
+
text: t instanceof Error ? t.message : String(t)
|
|
943
950
|
}), this.error(
|
|
944
|
-
`Apex ${this.config.method} failed: ${
|
|
951
|
+
`Apex ${this.config.method} failed: ${t instanceof Error ? t.message : String(t)}`,
|
|
945
952
|
o
|
|
946
953
|
);
|
|
947
954
|
}
|
|
948
955
|
}
|
|
949
956
|
};
|
|
950
|
-
f(
|
|
951
|
-
let N =
|
|
952
|
-
const
|
|
957
|
+
f(I, "SalesforceApex"), s(I, "type", "salesforce-apex"), s(I, "category", "salesforce"), s(I, "color", "#FFFFFF"), s(I, "configSchema", be), s(I, "inputSchema", Te), s(I, "outputsSchema", Ie);
|
|
958
|
+
let N = I;
|
|
959
|
+
const $e = Y({
|
|
953
960
|
nodes: [
|
|
954
|
-
|
|
961
|
+
$,
|
|
962
|
+
U,
|
|
955
963
|
R,
|
|
956
|
-
S,
|
|
957
964
|
O,
|
|
958
965
|
j,
|
|
959
966
|
v,
|
|
960
967
|
N
|
|
961
968
|
]
|
|
962
969
|
});
|
|
963
|
-
var
|
|
964
|
-
|
|
970
|
+
var C = $e;
|
|
971
|
+
C && typeof C == "object" && Array.isArray(C.nodes) && (C = G(C.nodes));
|
|
965
972
|
export {
|
|
966
|
-
|
|
973
|
+
C as default
|
|
967
974
|
};
|
|
968
975
|
//# sourceMappingURL=index.mjs.map
|