@bonsae/node-red-salesforce 0.3.0 → 0.4.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.
package/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
- var P = Object.defineProperty;
2
- var B = (a, o, n) => o in a ? P(a, o, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[o] = n;
3
- var f = (a, o) => P(a, "name", { value: o, configurable: !0 });
4
- var s = (a, o, n) => B(a, typeof o != "symbol" ? o + "" : o, n);
1
+ var z = Object.defineProperty;
2
+ var H = (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 r = (a, o, n) => H(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 e, ConfigNode as Q, IONode as A, defineModule as Y } from "@bonsae/nrg/server";
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
- import M from "node:crypto";
10
+ import N from "node:crypto";
11
11
  var V = q(import.meta.url), Ae = J(V);
12
12
  const W = h(
13
13
  {
@@ -48,18 +48,18 @@ const W = h(
48
48
  instanceUrl: e.String({ default: "" })
49
49
  },
50
50
  { $id: "salesforce-connection:credentials" }
51
- ), H = 600 * 1e3, F = /* @__PURE__ */ new Map();
51
+ ), B = 600 * 1e3, U = /* @__PURE__ */ new Map();
52
52
  function Z() {
53
- return M.randomBytes(32).toString("base64url");
53
+ return N.randomBytes(32).toString("base64url");
54
54
  }
55
55
  f(Z, "generateCodeVerifier");
56
56
  function D(a) {
57
- return M.createHash("sha256").update(a).digest("base64url");
57
+ return N.createHash("sha256").update(a).digest("base64url");
58
58
  }
59
59
  f(D, "generateCodeChallenge");
60
60
  function _(a) {
61
- const o = M.randomUUID(), n = Z(), t = D(n);
62
- F.set(o, {
61
+ const o = N.randomUUID(), n = Z(), t = D(n);
62
+ U.set(o, {
63
63
  codeVerifier: n,
64
64
  nodeId: a.nodeId,
65
65
  clientId: a.clientId,
@@ -67,25 +67,25 @@ function _(a) {
67
67
  callbackUrl: a.callbackUrl,
68
68
  timestamp: Date.now()
69
69
  });
70
- for (const [i, r] of F)
71
- Date.now() - r.timestamp > H && F.delete(i);
70
+ for (const [s, i] of U)
71
+ Date.now() - i.timestamp > B && U.delete(s);
72
72
  return { state: o, codeChallenge: t };
73
73
  }
74
74
  f(_, "createAuthState");
75
75
  function ee(a) {
76
- const o = F.get(a);
77
- return !o || (F.delete(a), Date.now() - o.timestamp > H) ? null : o;
76
+ const o = U.get(a);
77
+ return !o || (U.delete(a), Date.now() - o.timestamp > B) ? null : o;
78
78
  }
79
79
  f(ee, "consumeAuthState");
80
80
  function te(a) {
81
81
  return a.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
82
82
  }
83
83
  f(te, "escapeHtml");
84
- function k(a, o = !0) {
84
+ function A(a, o = !0) {
85
85
  const n = o ? "<script>setTimeout(function(){window.close()},3000)</script>" : "";
86
86
  return `<html><body><h2>Authorization Failed</h2><p>${te(a)}</p>${n}</body></html>`;
87
87
  }
88
- f(k, "errorPage");
88
+ f(A, "errorPage");
89
89
  function ne(a) {
90
90
  const o = (a.settings.httpAdminRoot || "").replace(
91
91
  /\/$/,
@@ -94,19 +94,19 @@ function ne(a) {
94
94
  a.httpAdmin.post("/salesforce/auth/start", (n, t) => {
95
95
  try {
96
96
  const {
97
- nodeId: i,
98
- loginUrl: r,
97
+ nodeId: s,
98
+ loginUrl: i,
99
99
  clientId: l,
100
100
  callbackUrl: d
101
101
  } = n.body;
102
- if (!i || !r || !l) {
102
+ if (!s || !i || !l) {
103
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: i,
107
+ nodeId: s,
108
108
  clientId: l,
109
- loginUrl: r,
109
+ loginUrl: i,
110
110
  callbackUrl: c
111
111
  }), m = new URLSearchParams({
112
112
  response_type: "code",
@@ -117,30 +117,30 @@ function ne(a) {
117
117
  code_challenge_method: "S256"
118
118
  });
119
119
  t.json({
120
- authorizationUrl: `${r}/services/oauth2/authorize?${m.toString()}`
120
+ authorizationUrl: `${i}/services/oauth2/authorize?${m.toString()}`
121
121
  });
122
- } catch (i) {
122
+ } catch (s) {
123
123
  a.log.error(
124
- `salesforce-connection: auth/start error: ${i instanceof Error ? i.message : String(i)}`
124
+ `salesforce-connection: auth/start error: ${s instanceof Error ? s.message : String(s)}`
125
125
  ), t.status(500).json({ error: "Failed to start authorization" });
126
126
  }
127
127
  }), a.httpAdmin.get("/salesforce/auth/callback", async (n, t) => {
128
128
  try {
129
- const { code: i, state: r, error: l, error_description: d } = n.query;
129
+ const { code: s, state: i, 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
- ), t.status(400).send(k(String(d || l)));
133
+ ), t.status(400).send(A(String(d || l)));
134
134
  return;
135
135
  }
136
- if (!i || !r) {
137
- t.status(400).send(k("Missing code or state parameter"));
136
+ if (!s || !i) {
137
+ t.status(400).send(A("Missing code or state parameter"));
138
138
  return;
139
139
  }
140
- const c = ee(r);
140
+ const c = ee(i);
141
141
  if (!c) {
142
142
  t.status(400).send(
143
- k(
143
+ A(
144
144
  "Invalid or expired authorization state. Please try again."
145
145
  )
146
146
  );
@@ -153,7 +153,7 @@ function ne(a) {
153
153
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
154
154
  body: new URLSearchParams({
155
155
  grant_type: "authorization_code",
156
- code: i,
156
+ code: s,
157
157
  client_id: c.clientId,
158
158
  redirect_uri: c.callbackUrl,
159
159
  code_verifier: c.codeVerifier
@@ -165,7 +165,7 @@ function ne(a) {
165
165
  a.log.error(
166
166
  `salesforce-connection: Token exchange failed: ${p}`
167
167
  ), t.status(500).send(
168
- k(
168
+ A(
169
169
  "Token exchange failed. Check the Node-RED logs for details."
170
170
  )
171
171
  );
@@ -199,17 +199,17 @@ function ne(a) {
199
199
  </script>
200
200
  </body>
201
201
  </html>`);
202
- } catch (i) {
202
+ } catch (s) {
203
203
  a.log.error(
204
- `salesforce-connection: auth/callback error: ${i instanceof Error ? i.message : String(i)}`
205
- ), t.status(500).send(k("An unexpected error occurred."));
204
+ `salesforce-connection: auth/callback error: ${s instanceof Error ? s.message : String(s)}`
205
+ ), t.status(500).send(A("An unexpected error occurred."));
206
206
  }
207
207
  }), a.httpAdmin.get("/salesforce/auth/status/:nodeId", (n, t) => {
208
208
  try {
209
- const i = a.nodes.getCredentials(n.params.nodeId), r = !!(i != null && i.accessToken && (i != null && i.instanceUrl));
209
+ const s = a.nodes.getCredentials(n.params.nodeId), i = !!(s != null && s.accessToken && (s != null && s.instanceUrl));
210
210
  t.json({
211
- authenticated: r,
212
- instanceUrl: r ? i.instanceUrl : void 0
211
+ authenticated: i,
212
+ instanceUrl: i ? s.instanceUrl : void 0
213
213
  });
214
214
  } catch {
215
215
  t.json({ authenticated: !1 });
@@ -224,7 +224,7 @@ f(oe, "initRoutes");
224
224
  const L = class L extends Q {
225
225
  constructor() {
226
226
  super(...arguments);
227
- s(this, "conn", null);
227
+ r(this, "conn", null);
228
228
  }
229
229
  static async registered(n) {
230
230
  oe(n);
@@ -264,9 +264,9 @@ const L = class L extends Q {
264
264
  this.conn = null;
265
265
  }
266
266
  };
267
- f(L, "SalesforceConnection"), s(L, "type", "salesforce-connection"), s(L, "configSchema", W), s(L, "credentialsSchema", X);
267
+ f(L, "SalesforceConnection"), r(L, "type", "salesforce-connection"), r(L, "configSchema", W), r(L, "credentialsSchema", X);
268
268
  let $ = L;
269
- const ie = h(
269
+ const re = h(
270
270
  {
271
271
  name: e.String({ default: "", "x-nrg-form": { icon: "tag" } }),
272
272
  connection: e.NodeRef($, {
@@ -277,7 +277,10 @@ const ie = h(
277
277
  icon: "search",
278
278
  typedInputTypes: ["str", "msg", "flow", "global"]
279
279
  }
280
- })
280
+ }),
281
+ errorPort: e.Boolean({ default: !1 }),
282
+ completePort: e.Boolean({ default: !1 }),
283
+ statusPort: e.Boolean({ default: !1 })
281
284
  },
282
285
  { $id: "salesforce-soql:config" }
283
286
  ), se = h(
@@ -285,14 +288,14 @@ const ie = h(
285
288
  payload: e.Any()
286
289
  },
287
290
  { $id: "salesforce-soql:input" }
288
- ), re = h(
291
+ ), ie = h(
289
292
  {
290
293
  payload: e.Array(e.Any()),
291
294
  totalSize: e.Number(),
292
295
  done: e.Boolean()
293
296
  },
294
297
  { $id: "salesforce-soql:output" }
295
- ), y = class y extends A {
298
+ ), y = class y extends k {
296
299
  async input(o) {
297
300
  const n = this.config.connection;
298
301
  if (!n) {
@@ -301,16 +304,16 @@ const ie = h(
301
304
  }
302
305
  try {
303
306
  this.status({ fill: "green", shape: "dot", text: "querying..." });
304
- const t = await n.getConnection(), i = await this.config.query.resolve(o), r = await t.query(i);
307
+ const t = await n.getConnection(), s = await this.config.query.resolve(o), i = await t.query(s);
305
308
  this.status({
306
309
  fill: "green",
307
310
  shape: "dot",
308
- text: `${r.totalSize} records`
311
+ text: `${i.totalSize} records`
309
312
  }), this.send({
310
313
  ...o,
311
- payload: r.records,
312
- totalSize: r.totalSize,
313
- done: r.done
314
+ payload: i.records,
315
+ totalSize: i.totalSize,
316
+ done: i.done
314
317
  });
315
318
  } catch (t) {
316
319
  this.status({
@@ -324,8 +327,8 @@ const ie = h(
324
327
  }
325
328
  }
326
329
  };
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;
330
+ f(y, "SalesforceSoql"), r(y, "type", "salesforce-soql"), r(y, "category", "salesforce"), r(y, "color", "#FFFFFF"), r(y, "configSchema", re), r(y, "inputSchema", se), r(y, "outputsSchema", ie);
331
+ let E = y;
329
332
  const ae = h(
330
333
  {
331
334
  name: e.String({ default: "", "x-nrg-form": { icon: "tag" } }),
@@ -360,9 +363,9 @@ const ae = h(
360
363
  "x-nrg-form": { icon: "key" }
361
364
  })
362
365
  ),
363
- emitError: e.Boolean({ default: !1 }),
364
- emitComplete: e.Boolean({ default: !1 }),
365
- emitStatus: e.Boolean({ default: !1 })
366
+ errorPort: e.Boolean({ default: !1 }),
367
+ completePort: e.Boolean({ default: !1 }),
368
+ statusPort: e.Boolean({ default: !1 })
366
369
  },
367
370
  {
368
371
  $id: "salesforce-dml:config",
@@ -388,7 +391,7 @@ const ae = h(
388
391
  payload: e.Any()
389
392
  },
390
393
  { $id: "salesforce-dml:output" }
391
- ), x = class x extends A {
394
+ ), x = class x extends k {
392
395
  async input(o) {
393
396
  const n = this.config.connection;
394
397
  if (!n) {
@@ -398,7 +401,7 @@ const ae = h(
398
401
  try {
399
402
  const t = this.config.operation;
400
403
  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;
404
+ const s = await n.getConnection(), i = await this.config.sObjectType.resolve(o), l = s.sobject(i), d = await this.config.record.resolve(o) ?? o.payload;
402
405
  let c;
403
406
  switch (t) {
404
407
  case "create":
@@ -432,8 +435,8 @@ const ae = h(
432
435
  }
433
436
  }
434
437
  };
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;
438
+ f(x, "SalesforceDml"), r(x, "type", "salesforce-dml"), r(x, "category", "salesforce"), r(x, "color", "#FFFFFF"), r(x, "configSchema", ae), r(x, "inputSchema", ce), r(x, "outputsSchema", le);
439
+ let C = x;
437
440
  const de = h(
438
441
  {
439
442
  name: e.String({ default: "", "x-nrg-form": { icon: "tag" } }),
@@ -493,14 +496,9 @@ const de = h(
493
496
  minimum: 5e3,
494
497
  "x-nrg-form": { icon: "hourglass" }
495
498
  }),
496
- emitJobCreated: e.Boolean({
497
- default: !1,
498
- "x-nrg-form": { icon: "flag", toggle: !0 }
499
- }),
500
- outputs: e.Number({ default: 2 }),
501
- emitError: e.Boolean({ default: !1 }),
502
- emitComplete: e.Boolean({ default: !1 }),
503
- emitStatus: e.Boolean({ default: !1 })
499
+ errorPort: e.Boolean({ default: !1 }),
500
+ completePort: e.Boolean({ default: !0 }),
501
+ statusPort: e.Boolean({ default: !1 })
504
502
  },
505
503
  {
506
504
  $id: "salesforce-bulk:config",
@@ -530,21 +528,19 @@ h(
530
528
  );
531
529
  const he = h(
532
530
  {},
533
- { $id: "salesforce-bulk:output-port-1" }
531
+ { $id: "salesforce-bulk:record-output" }
534
532
  ), pe = h(
535
533
  {},
536
- { $id: "salesforce-bulk:output-port-2" }
537
- ), b = class b extends A {
534
+ { $id: "salesforce-bulk:job-created-output" }
535
+ ), fe = {
536
+ record: he,
537
+ jobCreated: pe
538
+ }, b = class b extends k {
538
539
  sendRecord(o, n) {
539
- const t = this.config.emitJobCreated ? 3 : 2, i = Array(t).fill(null);
540
- i[0] = { ...o, payload: n }, this.send(i);
540
+ this.sendToPort("record", { ...o, payload: n });
541
541
  }
542
542
  sendJobCreated(o, n) {
543
- this.config.emitJobCreated && this.send([null, null, { ...o, payload: n }]);
544
- }
545
- sendComplete(o, n) {
546
- const t = this.config.emitJobCreated ? 3 : 2, i = Array(t).fill(null);
547
- i[1] = { ...o, payload: n }, this.send(i);
543
+ this.sendToPort("jobCreated", { ...o, payload: n });
548
544
  }
549
545
  async input(o) {
550
546
  const n = this.config.connection;
@@ -559,10 +555,10 @@ const he = h(
559
555
  shape: "dot",
560
556
  text: `bulk ${t}...`
561
557
  });
562
- const i = await n.getConnection(), r = await this.config.sObjectType.resolve(o);
558
+ const s = await n.getConnection(), i = await this.config.sObjectType.resolve(o);
563
559
  let l = 0;
564
560
  if (t === "query") {
565
- const d = await i.bulk2.query(o.payload, {
561
+ const d = await s.bulk2.query(o.payload, {
566
562
  pollTimeout: this.config.pollTimeout,
567
563
  pollInterval: this.config.pollInterval,
568
564
  columnDelimiter: this.config.columnDelimiter,
@@ -576,11 +572,14 @@ const he = h(
576
572
  fill: "green",
577
573
  shape: "dot",
578
574
  text: `bulk ${t}: ${l} records`
579
- }), this.sendComplete(o, { operation: t, sObjectType: r, totalRecords: l });
575
+ }), this.sendToPort("complete", {
576
+ ...o,
577
+ payload: { operation: t, sObjectType: i, totalRecords: l }
578
+ });
580
579
  } else {
581
- const d = o.payload, c = i.bulk2.createJob({
580
+ const d = o.payload, c = s.bulk2.createJob({
582
581
  operation: t,
583
- object: r,
582
+ object: i,
584
583
  columnDelimiter: this.config.columnDelimiter,
585
584
  lineEnding: this.config.lineEnding,
586
585
  ...t === "upsert" && this.config.externalIdField ? { externalIdFieldName: this.config.externalIdField } : {},
@@ -589,42 +588,42 @@ const he = h(
589
588
  await c.open(), this.sendJobCreated(o, {
590
589
  jobId: c.id,
591
590
  operation: t,
592
- sObjectType: r,
591
+ sObjectType: i,
593
592
  state: "Open"
594
593
  }), await c.uploadData(d), await c.close(), await c.poll(this.config.pollInterval, this.config.pollTimeout);
595
594
  const g = await c.getAllResults(), u = g.successfulResults ?? [], m = g.failedResults ?? [], p = g.unprocessedRecords ?? [];
596
595
  l = u.length + m.length + p.length;
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
+ for (const R of u)
597
+ this.sendRecord(o, R);
598
+ for (const R of m)
599
+ this.sendRecord(o, R);
600
+ const S = u.length, M = m.length;
602
601
  this.status({
603
- fill: z > 0 ? "red" : "green",
602
+ fill: M > 0 ? "red" : "green",
604
603
  shape: "dot",
605
604
  text: `bulk ${t}: ${l} records`
606
- }), this.sendComplete(o, {
607
- jobId: c.id,
608
- operation: t,
609
- sObjectType: r,
610
- totalRecords: l,
611
- successCount: S,
612
- failureCount: z,
613
- unprocessedCount: p.length
605
+ }), this.sendToPort("complete", {
606
+ ...o,
607
+ payload: {
608
+ jobId: c.id,
609
+ operation: t,
610
+ sObjectType: i,
611
+ totalRecords: l,
612
+ successCount: S,
613
+ failureCount: M,
614
+ unprocessedCount: p.length
615
+ }
614
616
  });
615
617
  }
616
618
  } 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);
619
+ const s = t instanceof Error ? t.message : String(t);
620
+ this.status({ fill: "red", shape: "dot", text: s }), this.error(`Bulk ${this.config.operation} failed: ${s}`, o);
619
621
  }
620
622
  }
621
623
  };
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
- ]);
624
+ f(b, "SalesforceBulk"), r(b, "type", "salesforce-bulk"), r(b, "category", "salesforce"), r(b, "color", "#FFFFFF"), r(b, "configSchema", de), r(b, "inputSchema", ue), r(b, "outputsSchema", fe);
626
625
  let O = b;
627
- const fe = h(
626
+ const ge = h(
628
627
  {
629
628
  name: e.String({ default: "", "x-nrg-form": { icon: "tag" } }),
630
629
  connection: e.NodeRef($, {
@@ -636,17 +635,17 @@ const fe = h(
636
635
  typedInputTypes: ["str", "msg"]
637
636
  }
638
637
  }),
639
- emitError: e.Boolean({ default: !1 }),
640
- emitComplete: e.Boolean({ default: !1 }),
641
- emitStatus: e.Boolean({ default: !1 })
638
+ errorPort: e.Boolean({ default: !1 }),
639
+ completePort: e.Boolean({ default: !1 }),
640
+ statusPort: e.Boolean({ default: !1 })
642
641
  },
643
642
  { $id: "salesforce-describe:config" }
644
- ), ge = h(
643
+ ), me = h(
645
644
  {
646
645
  payload: e.Any()
647
646
  },
648
647
  { $id: "salesforce-describe:input" }
649
- ), me = h(
648
+ ), ye = h(
650
649
  {
651
650
  payload: e.Object({
652
651
  name: e.String(),
@@ -656,7 +655,7 @@ const fe = h(
656
655
  })
657
656
  },
658
657
  { $id: "salesforce-describe:output" }
659
- ), T = class T extends A {
658
+ ), T = class T extends k {
660
659
  async input(o) {
661
660
  const n = this.config.connection;
662
661
  if (!n) {
@@ -665,18 +664,18 @@ const fe = h(
665
664
  }
666
665
  try {
667
666
  this.status({ fill: "green", shape: "dot", text: "describing..." });
668
- const t = await n.getConnection(), i = await this.config.sObjectType.resolve(o), r = await t.sobject(i).describe();
667
+ const t = await n.getConnection(), s = await this.config.sObjectType.resolve(o), i = await t.sobject(s).describe();
669
668
  this.status({
670
669
  fill: "green",
671
670
  shape: "dot",
672
- text: `${r.name}: ${r.fields.length} fields`
671
+ text: `${i.name}: ${i.fields.length} fields`
673
672
  }), this.send({
674
673
  ...o,
675
674
  payload: {
676
- name: r.name,
677
- fields: r.fields,
678
- childRelationships: r.childRelationships,
679
- recordTypeInfos: r.recordTypeInfos
675
+ name: i.name,
676
+ fields: i.fields,
677
+ childRelationships: i.childRelationships,
678
+ recordTypeInfos: i.recordTypeInfos
680
679
  }
681
680
  });
682
681
  } catch (t) {
@@ -691,9 +690,9 @@ const fe = h(
691
690
  }
692
691
  }
693
692
  };
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(
693
+ f(T, "SalesforceDescribe"), r(T, "type", "salesforce-describe"), r(T, "category", "salesforce"), r(T, "color", "#FFFFFF"), r(T, "configSchema", ge), r(T, "inputSchema", me), r(T, "outputsSchema", ye);
694
+ let P = T;
695
+ const xe = h(
697
696
  {
698
697
  name: e.String({ default: "", "x-nrg-form": { icon: "tag" } }),
699
698
  connection: e.NodeRef($, {
@@ -723,8 +722,9 @@ const ye = h(
723
722
  maximum: 100,
724
723
  "x-nrg-form": { icon: "sort-numeric-asc" }
725
724
  }),
726
- emitError: e.Boolean({ default: !1 }),
727
- emitStatus: e.Boolean({ default: !1 })
725
+ errorPort: e.Boolean({ default: !1 }),
726
+ completePort: e.Boolean({ default: !1 }),
727
+ statusPort: e.Boolean({ default: !1 })
728
728
  },
729
729
  {
730
730
  $id: "salesforce-streaming:config",
@@ -740,7 +740,7 @@ const ye = h(
740
740
  }
741
741
  }
742
742
  }
743
- ), xe = h(
743
+ ), be = h(
744
744
  {
745
745
  payload: e.Any(),
746
746
  replayId: e.Any(),
@@ -748,15 +748,15 @@ const ye = h(
748
748
  topic: e.String()
749
749
  },
750
750
  { $id: "salesforce-streaming:output" }
751
- ), w = class w extends A {
751
+ ), w = class w extends k {
752
752
  constructor() {
753
753
  super(...arguments);
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);
754
+ r(this, "client", null);
755
+ r(this, "reconnectAttempt", 0);
756
+ r(this, "maxReconnectDelay", 6e4);
757
+ r(this, "maxReconnectAttempts", 10);
758
+ r(this, "grpcErrorHandler", null);
759
+ r(this, "stopped", !1);
760
760
  }
761
761
  async created() {
762
762
  const n = this.config.connection;
@@ -777,16 +777,16 @@ const ye = h(
777
777
  this.status({ fill: "red", shape: "dot", text: "auth expired" }), this.error("Salesforce token expired. Re-authorize the connection.");
778
778
  return;
779
779
  }
780
- const i = n.getAccessToken(), r = n.getInstanceUrl();
781
- if (!i || !r) {
780
+ const s = n.getAccessToken(), i = n.getInstanceUrl();
781
+ if (!s || !i) {
782
782
  this.status({ fill: "red", shape: "dot", text: "not authorized" }), this.error("Salesforce connection not authorized");
783
783
  return;
784
784
  }
785
785
  const l = (await import("salesforce-pubsub-api-client")).default;
786
786
  this.client = new l({
787
787
  authType: "user-supplied",
788
- accessToken: i,
789
- instanceUrl: r
788
+ accessToken: s,
789
+ instanceUrl: i
790
790
  }), await this.client.connect();
791
791
  const d = this.config.numRequested || null, c = this.config.channelName, g = /* @__PURE__ */ f((u, m, p) => {
792
792
  if (m === "event" || m === "lastevent")
@@ -889,9 +889,9 @@ const ye = h(
889
889
  await this.cleanup();
890
890
  }
891
891
  };
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(
892
+ f(w, "SalesforceStreaming"), r(w, "type", "salesforce-streaming"), r(w, "category", "salesforce"), r(w, "color", "#FFFFFF"), r(w, "configSchema", xe), r(w, "outputsSchema", be);
893
+ let j = w;
894
+ const Te = h(
895
895
  {
896
896
  name: e.String({ default: "", "x-nrg-form": { icon: "tag" } }),
897
897
  connection: e.NodeRef($, {
@@ -913,22 +913,22 @@ const be = h(
913
913
  typedInputTypes: ["str", "msg"]
914
914
  }
915
915
  }),
916
- emitError: e.Boolean({ default: !1 }),
917
- emitComplete: e.Boolean({ default: !1 }),
918
- emitStatus: e.Boolean({ default: !1 })
916
+ errorPort: e.Boolean({ default: !1 }),
917
+ completePort: e.Boolean({ default: !1 }),
918
+ statusPort: e.Boolean({ default: !1 })
919
919
  },
920
920
  { $id: "salesforce-apex:config" }
921
- ), Te = h(
921
+ ), Ie = h(
922
922
  {
923
923
  payload: e.Any()
924
924
  },
925
925
  { $id: "salesforce-apex:input" }
926
- ), Ie = h(
926
+ ), $e = h(
927
927
  {
928
928
  payload: e.Any()
929
929
  },
930
930
  { $id: "salesforce-apex:output" }
931
- ), I = class I extends A {
931
+ ), I = class I extends k {
932
932
  async input(o) {
933
933
  const n = this.config.connection;
934
934
  if (!n) {
@@ -938,10 +938,10 @@ const be = h(
938
938
  try {
939
939
  const t = this.config.method;
940
940
  this.status({ fill: "green", shape: "dot", text: `${t}...` });
941
- const i = await n.getConnection(), r = await this.config.path.resolve(o);
941
+ const s = await n.getConnection(), i = await this.config.path.resolve(o);
942
942
  let l;
943
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 });
944
+ d === "get" || d === "delete" ? l = await s.apex[d](i) : l = await s.apex[d](i, o.payload), this.status({ fill: "green", shape: "dot", text: `${t} done` }), this.send({ ...o, payload: l });
945
945
  } catch (t) {
946
946
  this.status({
947
947
  fill: "red",
@@ -954,22 +954,22 @@ const be = h(
954
954
  }
955
955
  }
956
956
  };
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({
957
+ f(I, "SalesforceApex"), r(I, "type", "salesforce-apex"), r(I, "category", "salesforce"), r(I, "color", "#FFFFFF"), r(I, "configSchema", Te), r(I, "inputSchema", Ie), r(I, "outputsSchema", $e);
958
+ let v = I;
959
+ const we = Y({
960
960
  nodes: [
961
961
  $,
962
- U,
963
- R,
962
+ E,
963
+ C,
964
964
  O,
965
+ P,
965
966
  j,
966
- v,
967
- N
967
+ v
968
968
  ]
969
969
  });
970
- var C = $e;
971
- C && typeof C == "object" && Array.isArray(C.nodes) && (C = G(C.nodes));
970
+ var F = we;
971
+ F && typeof F == "object" && Array.isArray(F.nodes) && (F = G(F.nodes));
972
972
  export {
973
- C as default
973
+ F as default
974
974
  };
975
975
  //# sourceMappingURL=index.mjs.map