Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Dev tools
.cursor
.sf
.sfdx
.vscode
Expand Down
2 changes: 1 addition & 1 deletion sfdx-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
],
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "64.0"
"sourceApiVersion": "65.0"
}
43 changes: 42 additions & 1 deletion src/main/default/classes/StreamingMonitorController.cls
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ public abstract class StreamingMonitorController {
'UriEventStream'
};

private final static List<String> PLATFORM_EVENT_STANDARD_FIELDS = new List<String>{
'replayid',
'createddate',
'createdbyid',
'eventuuid'
};

@TestVisible
private final static Map<Schema.SOAPType, Object> DEFAULT_FIELD_VALUES = new Map<Schema.SOAPType, Object>{
Schema.SOAPType.STRING => '',
Schema.SOAPType.DATE => '2025-01-01',
Schema.SOAPType.DATETIME => '2025-01-01T00:00:00Z',
Schema.SOAPType.BOOLEAN => false,
Schema.SOAPType.DOUBLE => 0
};

@AuraEnabled
public static void publishStreamingEvent(
String eventType,
Expand Down Expand Up @@ -85,6 +101,31 @@ public abstract class StreamingMonitorController {
];
}

@AuraEnabled
public static Map<String, Object> getBlankPlatformEvent(String eventName) {
// Get object fields
Schema.DescribeSobjectResult[] results;
try {
results = Schema.describeSObjects(new List<String>{ eventName });
} catch (Exception e) {
throw new StreamingException(
'Unknown platform event type: ' + eventName
);
}
Map<String, Schema.SObjectField> fields = results[0].fields.getMap();
// Remove standard fields
Set<String> fieldNames = fields.keySet();
fieldNames.removeAll(PLATFORM_EVENT_STANDARD_FIELDS);
Map<String, Object> event = new Map<String, Object>();
// Add default values for fields
for (String fieldName : fieldNames) {
Schema.DescribeFieldResult dfr = fields.get(fieldName)
.getDescribe();
event.put(fieldName, DEFAULT_FIELD_VALUES.get(dfr.getSOAPType()));
}
return event;
}

private static void publishPlatformEvent(
String eventName,
String eventPayload
Expand Down Expand Up @@ -307,7 +348,7 @@ public abstract class StreamingMonitorController {
public void execute(QueueableContext context) {
String restAPIURL =
URL.getOrgDomainUrl().toExternalForm() +
'/services/data/v64.0/sobjects/StreamingChannel/' +
'/services/data/v65.0/sobjects/StreamingChannel/' +
channelId +
'/push';
HttpRequest httpRequest = new HttpRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
xmlns="urn:metadata.tooling.soap.sforce.com"
fqn="StreamingMonitorController"
>
<apiVersion>64.0</apiVersion>
<apiVersion>65.0</apiVersion>
<status>Active</status>
</ApexClass>
15 changes: 14 additions & 1 deletion src/main/default/lwc/actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
getChannelPrefix
} from 'c/streamingUtility';

import getBlankPlatformEvent from '@salesforce/apex/StreamingMonitorController.getBlankPlatformEvent';

import subscribeAll from './subscribeAll.html';
import subscribe from './subscribe.html';
import publish from './publish.html';
Expand Down Expand Up @@ -130,10 +132,21 @@ export default class Actions extends LightningElement {
this.pubPayload = undefined;
}

handlePubEventNameChange(event) {
async handlePubEventNameChange(event) {
this.pubEventName = event.detail.value;
this.pubChannel =
getChannelPrefix(this.pubEventType) + this.pubEventName;
// Load blank event for platform event
if (this.pubEventType === EVT_PLATFORM_EVENT) {
try {
const blankEvent = await getBlankPlatformEvent({
eventName: this.pubEventName
});
this.pubPayload = JSON.stringify(blankEvent, null, 2);
} catch (error) {
console.error(error);
}
}
}

handlePubPayloadChange(event) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/default/lwc/actions/actions.js-meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
xmlns="http://soap.sforce.com/2006/04/metadata"
fqn="actions"
>
<apiVersion>64.0</apiVersion>
<apiVersion>65.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
6 changes: 4 additions & 2 deletions src/main/default/lwc/actions/publish.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<lightning-card title="Publish a streaming event">
<div class="slds-p-horizontal_large">
<div class="slds-var-p-horizontal_large">
<lightning-combobox
label="Event type"
value={pubEventType}
Expand Down Expand Up @@ -31,7 +31,9 @@
disabled={isPublishDisabled}
field-level-help={pubPayloadHelp}
></lightning-textarea>
<div class="slds-align_absolute-center slds-m-top_medium">
<div
class="slds-align_absolute-center slds-var-m-top_medium"
>
<lightning-button
variant="brand"
label="Publish"
Expand Down
8 changes: 4 additions & 4 deletions src/main/default/lwc/actions/register.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<template>
<lightning-card title="Register a streaming event source">
<div class="slds-p-horizontal_large">
<div class="slds-var-p-horizontal_large">
<lightning-combobox
label="Event type"
name="regEventType"
value={regEventType}
options={regEventTypes}
onchange={handleValueChange}
placeholder="Select type"
class="slds-m-bottom_medium"
class="slds-var-m-bottom_medium"
></lightning-combobox>

<template if:true={isPushTopicReg}>
<p class="slds-m-bottom_small">
<p class="slds-var-m-bottom_small">
Customize and execute the following code in Apex to register
a new PushTopic:
</p>
Expand All @@ -21,7 +21,7 @@
pushTopic.Name = 'ClosedCaseUpdates';<br />
pushTopic.Query = 'SELECT Id, Subject FROM Case WHERE
Status=\'Closed\'';<br />
pushTopic.ApiVersion = 64.0;<br />
pushTopic.ApiVersion = 65.0;<br />
pushTopic.NotifyForOperationCreate = true;<br />
pushTopic.NotifyForOperationUpdate = true;<br />
pushTopic.NotifyForOperationUndelete = true;<br />
Expand Down
4 changes: 2 additions & 2 deletions src/main/default/lwc/actions/subscribe.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<lightning-card title="Subscribe to a channel">
<div class="slds-p-horizontal_large">
<div class="slds-var-p-horizontal_large">
<form onsubmit={handleSubscribe}>
<lightning-combobox
label="Event type"
Expand Down Expand Up @@ -41,7 +41,7 @@
onchange={handleValueChange}
required
></lightning-input>
<div class="slds-align_absolute-center slds-m-top_medium">
<div class="slds-align_absolute-center slds-var-m-top_medium">
<lightning-button
variant="brand"
label="Subscribe"
Expand Down
6 changes: 3 additions & 3 deletions src/main/default/lwc/actions/subscribeAll.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<lightning-card title="Subscribe to multiple streaming channels">
<div class="slds-p-horizontal_large">
<p class="slds-m-vertical_small">
<div class="slds-var-p-horizontal_large">
<p class="slds-var-m-vertical_small">
Custom Change Data Capture channels cannot be automatically
discovered. Supported channels: PushTopic, Generic, Platform
events, Change Data Capture events and Monitoring events.
Expand All @@ -21,7 +21,7 @@
onchange={handleValueChange}
options={replayOptions}
></lightning-combobox>
<div class="slds-align_absolute-center slds-m-top_medium">
<div class="slds-align_absolute-center slds-var-m-top_medium">
<lightning-button
variant="brand"
label="Subscribe"
Expand Down
2 changes: 1 addition & 1 deletion src/main/default/lwc/eventFilters/eventFilters.js-meta.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>64.0</apiVersion>
<apiVersion>65.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>64.0</apiVersion>
<apiVersion>65.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>64.0</apiVersion>
<apiVersion>65.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>64.0</apiVersion>
<apiVersion>65.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
2 changes: 1 addition & 1 deletion src/main/default/lwc/events/events.js-meta.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>64.0</apiVersion>
<apiVersion>65.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>64.0</apiVersion>
<apiVersion>65.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
6 changes: 3 additions & 3 deletions src/main/default/lwc/modal/modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
></lightning-button-icon>
</template>
<h2
class="slds-text-heading--medium slds-hyphenate"
class="slds-text-heading_medium slds-hyphenate"
id="modalTitle"
>
{title}
</h2>
<p class="slds-m-top--x-small slds-hide">
<p class="slds-var-m-top_x-small slds-hide">
<slot
name="tagline"
onslotchange={handleSlotTaglineChange}
Expand All @@ -36,7 +36,7 @@

<!-- Body -->
<div
class="slds-modal__content slds-p-around--medium"
class="slds-modal__content slds-var-p-around_medium"
id="modalContent"
>
<slot></slot>
Expand Down
2 changes: 1 addition & 1 deletion src/main/default/lwc/modal/modal.js-meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
xmlns="http://soap.sforce.com/2006/04/metadata"
fqn="modal"
>
<apiVersion>64.0</apiVersion>
<apiVersion>65.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
2 changes: 1 addition & 1 deletion src/main/default/lwc/notice/notice.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="slds-media slds-media_center slds-m-vertical_small">
<div class="slds-media slds-media_center slds-var-m-vertical_small">
<div class="slds-media__figure">
<lightning-icon
icon-name="utility:info"
Expand Down
2 changes: 1 addition & 1 deletion src/main/default/lwc/notice/notice.js-meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
xmlns="http://soap.sforce.com/2006/04/metadata"
fqn="notice"
>
<apiVersion>64.0</apiVersion>
<apiVersion>65.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
2 changes: 1 addition & 1 deletion src/main/default/lwc/orgLimits/orgLimits.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<lightning-card title="Org limits">
<div class="slds-p-horizontal_large">
<div class="slds-var-p-horizontal_large">
<c-notice
>The use of the Streaming Monitor counts against
limits.</c-notice
Expand Down
2 changes: 1 addition & 1 deletion src/main/default/lwc/orgLimits/orgLimits.js-meta.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>64.0</apiVersion>
<apiVersion>65.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
2 changes: 1 addition & 1 deletion src/main/default/lwc/sidebar/sidebar.js-meta.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>64.0</apiVersion>
<apiVersion>65.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>64.0</apiVersion>
<apiVersion>65.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Streaming Monitor</masterLabel>
<targets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"entityName": "Account",
"changeType": "UPDATE",
"changedFields": ["Description", "LastModifiedDate"],
"changeOrigin": "com/salesforce/api/soap/64.0;client=SfdcInternalAPI/",
"changeOrigin": "com/salesforce/api/soap/65.0;client=SfdcInternalAPI/",
"transactionKey": "0006b519-cb7b-7418-abd5-e47fe932ae26",
"commitTimestamp": 1615367339000,
"recordIds": ["0011X00000mzMB4QAM"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
xmlns="http://soap.sforce.com/2006/04/metadata"
fqn="streamingUtility"
>
<apiVersion>64.0</apiVersion>
<apiVersion>65.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
10 changes: 5 additions & 5 deletions src/main/default/lwc/subscriptions/subscriptions.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<template>
<div
class="slds-m-top_medium slds-grid slds-grid_align-spread slds-grid_vertical-align-center"
class="slds-var-m-top_medium slds-grid slds-grid_align-spread slds-grid_vertical-align-center"
>
<div class="slds-col">
<h2 class="slds-nav-vertical__title">Subscriptions</h2>
</div>
<div class="slds-col slds-m-right_medium">
<div class="slds-col slds-var-m-right_medium">
<lightning-badge label={subscriptionCount}></lightning-badge>
<lightning-button-icon
icon-name="utility:delete"
variant="bare"
alternative-text="Unsubscribe all"
class="slds-m-left_x-small"
class="slds-var-m-left_x-small"
onclick={handleUnsubscribeAll}
></lightning-button-icon>
</div>
</div>

<div class="slds-p-horizontal_x-small slds-m-bottom_large">
<div class="slds-var-p-horizontal_x-small slds-var-m-bottom_large">
<template for:each={subscriptions} for:item="subscription">
<div
key={subscription.channel}
class="slds-grid slds-p-vertical_x-small slds-p-horizontal_xx-small subscription"
class="slds-grid slds-var-p-vertical_x-small slds-var-p-horizontal_xx-small subscription"
>
<div class="slds-has-flexi-truncate">
<div class="slds-truncate">{subscription.channel}</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>64.0</apiVersion>
<apiVersion>65.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
2 changes: 1 addition & 1 deletion src/test/default/classes/GenericEventPostMock.cls-meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
xmlns="urn:metadata.tooling.soap.sforce.com"
fqn="GenericEventPostMock"
>
<apiVersion>64.0</apiVersion>
<apiVersion>65.0</apiVersion>
<status>Active</status>
</ApexClass>
Loading