@@ -32,6 +32,21 @@ 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+ private final static Map <Schema .SOAPType , Object > DEFAULT_FIELD_VALUES = new Map <Schema .SOAPType , Object >{
43+ Schema .SOAPType .STRING = > ' ' ,
44+ Schema .SOAPType .DATE = > ' 2025-01-01' ,
45+ Schema .SOAPType .DATETIME = > ' 2025-01-01T00:00:00Z' ,
46+ Schema .SOAPType .BOOLEAN = > false ,
47+ Schema .SOAPType .DOUBLE = > 0
48+ };
49+
3550 @AuraEnabled
3651 public static void publishStreamingEvent (
3752 String eventType ,
@@ -85,6 +100,31 @@ public abstract class StreamingMonitorController {
85100 ];
86101 }
87102
103+ @AuraEnabled
104+ public static Map <String , Object > getBlankPlatformEvent (String eventName ) {
105+ // Get object fields
106+ Schema .DescribeSobjectResult [] results ;
107+ try {
108+ results = Schema .describeSObjects (new List <String >{ eventName });
109+ } catch (Exception e ) {
110+ throw new StreamingException (
111+ ' Unknown platform event type: ' + eventName
112+ );
113+ }
114+ Map <String , Schema .SObjectField > fields = results [0 ].fields .getMap ();
115+ // Remove standard fields
116+ Set <String > fieldNames = fields .keySet ();
117+ fieldNames .removeAll (PLATFORM_EVENT_STANDARD_FIELDS );
118+ Map <String , Object > event = new Map <String , Object >();
119+ // Add default values for fields
120+ for (String fieldName : fieldNames ) {
121+ Schema .DescribeFieldResult dfr = fields .get (fieldName )
122+ .getDescribe ();
123+ event .put (fieldName , DEFAULT_FIELD_VALUES .get (dfr .getSOAPType ()));
124+ }
125+ return event ;
126+ }
127+
88128 private static void publishPlatformEvent (
89129 String eventName ,
90130 String eventPayload
0 commit comments