forked from jeffdonthemic/node-red-contrib-salesforce
-
Notifications
You must be signed in to change notification settings - Fork 17
/
streaming.html
113 lines (110 loc) · 5.44 KB
/
streaming.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<script type="text/javascript">
RED.nodes.registerType('streaming', {
category: 'Salesforce',
color: '#C0DEED',
defaults: {
name: {
value: ''
},
pushTopic: {
value: '',
required: true
},
replayId: {
value: '-1',
required: true
},
resubScribeOnDoubeSubscription: {
value: false
},
connection: {
value: '',
type: 'connection-config',
required: true
}
},
inputs: 1,
outputs: 1,
icon: 'salesforce.png',
label: function() {
return this.name || 'streaming';
},
oneditsave: function() {
this.topicType = $('#node-config-input-topicType').val();
}
});
</script>
<script type="text/x-red" data-template-name="streaming">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-connection"><i class="fa fa-plug"></i> Connection</label>
<input type="text" id="node-input-connection">
</div>
<div class="form-row">
<label for="node-input-pushTopic"><i class="fa fa-bullhorn"></i>Topic</label>
<input type="text" id="node-input-pushTopic">
</div>
<div class="form-row">
<label for="node-input-replayId"><i class="fa fa-repeat"></i>replayId</label>
<input type="text" id="node-input-replayId"><br />
-2 for all available, -1 for new ones, number for a specific one
</div>
<div class="form-row">
<input type="checkbox" id="node-config-input-resubScribeOnDoubeSubscription" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-config-input-resubScribeOnDoubeSubscription" style="width: auto; white-space:nowrap;">Disconnect and reconnect on second subscription</label>
(otherwise: ignore and stay subscribed)
</div>
</script>
<script type="text/x-red" data-help-name="streaming">
<p>Creates a client that subscribes to a PushTopic for all things streaming API including CDC</p>
<p>You need to provide the full topic starting with <code>/</code>. Samples:</p>
<ul>
<li>Platform events:<code>/event/DataChange__e</code><br /> Listen to the Platform event API</li>
<li>Push Topic: <code>/topic/MyPushTopic</code> <br />
Listen to changes in sObjects</li>
<li>Streaming (Generic): <code>/u/notifications/TestChannel</code><br />
Listen to generic Push Topics (deprecated)</li>
<li>Change Data Capture:
<ul>
<li>All configured changes: <code>/data/ChangeEvents</code></li>
<li>Opportunity: <code>/data/OpportunityChangeEvent</code></li>
<li>Custom object: <code>Custom__ChangeEvent</code> (replacing <code>__c</code> with <code>__ChangeEvent</code>)</li>
</ul>
Check the <a href="https://developer.salesforce.com/docs/atlas.en-us.218.0.change_data_capture.meta/change_data_capture/cdc_subscribe_channels.htm">Developer guide for more details</a>
</li>
</ul>
<p><b>replayId</b> (<a href="https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/using_streaming_api_durability.htm">Read this</a>):</p>
<ul>
<li><code> -2 </code>: all available events (up to 24h or more back)</li>
<li><code> -1 </code>: new events only </li>
<li><code> number </code>: replay starting from that number</li>
</ul>
<p>Subscription starts only when an incoming message is received once. The following `msg` properties are supported:</p>
<ul>
<li><code>action</code> with the value <code>subscribe</code> or <code>unsubscribe</code> (default: <code>subscribe</code>): start or stop a subscription</li>
<li><code>topic</code> the topic to subscribe to. Default is to use the topic from the config</li>
<li><code>replayId</code> replays available events from this Id. Set to <code>-2</code> to get all current objects</li>
<li><code>sf</code> object containing: <code>username</code>, <code>password</code>, <code>consumerKey</code> and <code>consumerSecret</code>. When the configuration allows it (checkbox "allow message credentials"), these values take priority over
the configuration values). They don't have to be present together, they are applied individually</li>
</ul>
<p>When the client receives a message it sends <code>msg.payload</code> with the following:
<ul>
<li>msg.payload.event - the information on the event that was received.</li>
<li>msg.payload.sobject - the sobject information received.</li>
</ul>
</p>
<p>Assuming the PushTopic was created with the query <code>SELECT Id, Name FROM Contact</code>, then a resulting message would look like:</p>
<pre>{
"event": {
"type": "updated", "createdDate": "2015-07-31T18:38:21.000+0000"
},
"sobject": {
"Name": "Nikola Tesla", "Id": "a0037000001pplrZZZ"
}
}</pre>
<p>See the <a href="https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/quick_start_workbench.htm">Quick Start Using Workbench</a> to get started or the <a href="https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/"
target="_blank">Streaming API documentation</a> for complete details.</p>
</script>