@@ -32,6 +32,22 @@ public abstract class StreamingMonitorController {
3232 ' UriEventStream'
3333 };
3434
35+ private final static List <String > PLATFORM_EVENT_STANDARD_FIELDS = new List <String >{
36+ ' replayid' ,
37+ ' createddate' ,
38+ ' createdbyid' ,
39+ ' eventuuid'
40+ };
41+
42+ @TestVisible
43+ private final static Map <Schema .SOAPType , Object > DEFAULT_FIELD_VALUES = new Map <Schema .SOAPType , Object >{
44+ Schema .SOAPType .STRING = > ' ' ,
45+ Schema .SOAPType .DATE = > ' 2025-01-01' ,
46+ Schema .SOAPType .DATETIME = > ' 2025-01-01T00:00:00Z' ,
47+ Schema .SOAPType .BOOLEAN = > false ,
48+ Schema .SOAPType .DOUBLE = > 0
49+ };
50+
3551 @AuraEnabled
3652 public static void publishStreamingEvent (
3753 String eventType ,
@@ -85,6 +101,31 @@ public abstract class StreamingMonitorController {
85101 ];
86102 }
87103
104+ @AuraEnabled
105+ public static Map <String , Object > getBlankPlatformEvent (String eventName ) {
106+ // Get object fields
107+ Schema .DescribeSobjectResult [] results ;
108+ try {
109+ results = Schema .describeSObjects (new List <String >{ eventName });
110+ } catch (Exception e ) {
111+ throw new StreamingException (
112+ ' Unknown platform event type: ' + eventName
113+ );
114+ }
115+ Map <String , Schema .SObjectField > fields = results [0 ].fields .getMap ();
116+ // Remove standard fields
117+ Set <String > fieldNames = fields .keySet ();
118+ fieldNames .removeAll (PLATFORM_EVENT_STANDARD_FIELDS );
119+ Map <String , Object > event = new Map <String , Object >();
120+ // Add default values for fields
121+ for (String fieldName : fieldNames ) {
122+ Schema .DescribeFieldResult dfr = fields .get (fieldName )
123+ .getDescribe ();
124+ event .put (fieldName , DEFAULT_FIELD_VALUES .get (dfr .getSOAPType ()));
125+ }
126+ return event ;
127+ }
128+
88129 private static void publishPlatformEvent (
89130 String eventName ,
90131 String eventPayload
@@ -307,7 +348,7 @@ public abstract class StreamingMonitorController {
307348 public void execute (QueueableContext context ) {
308349 String restAPIURL =
309350 URL .getOrgDomainUrl ().toExternalForm () +
310- ' /services/data/v64 .0/sobjects/StreamingChannel/' +
351+ ' /services/data/v65 .0/sobjects/StreamingChannel/' +
311352 channelId +
312353 ' /push' ;
313354 HttpRequest httpRequest = new HttpRequest ();
0 commit comments