@@ -30,73 +30,74 @@ interface StreamingData {
3030
3131const streamSequenceSchema = pipe ( number ( ) , integer ( ) , minValue ( 1 ) ) ;
3232
33+ // Extra fields required for each activity
34+ const activityExtras = {
35+ // "text" is optional. If not set or empty, it presents a contentless activity.
36+ text : optional ( undefinedable ( string ( ) ) ) ,
37+ attachments : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
38+ id : string ( )
39+ } ;
40+
3341const channelDataStreamingActivitySchema = union ( [
3442 // Interim.
3543 object ( {
36- attachments : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
44+ type : literal ( 'typing' ) ,
3745 channelData : object ( {
3846 // "streamId" is optional for the very first activity in the session.
3947 streamId : optional ( undefinedable ( string ( ) ) ) ,
4048 streamSequence : streamSequenceSchema ,
4149 streamType : literal ( 'streaming' )
4250 } ) ,
43- id : string ( ) ,
44- // "text" is optional. If not set or empty, it presents a contentless activity.
45- text : optional ( undefinedable ( string ( ) ) ) ,
46- type : literal ( 'typing' ) ,
47- entities : optional ( array ( any ( ) ) , EMPTY_ARRAY )
51+ entities : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
52+ ...activityExtras
4853 } ) ,
4954 // Informative message.
5055 object ( {
51- attachments : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
56+ // Informative may not have "text", but should have abstract instead (checked later)
57+ type : literal ( 'typing' ) ,
5258 channelData : object ( {
5359 // "streamId" is optional for the very first activity in the session.
5460 streamId : optional ( undefinedable ( string ( ) ) ) ,
5561 streamSequence : streamSequenceSchema ,
5662 streamType : literal ( 'informative' )
5763 } ) ,
58- id : string ( ) ,
59- // Informative may not have "text", but should have abstract instead (checked later)
60- text : optional ( undefinedable ( string ( ) ) ) ,
61- type : literal ( 'typing' ) ,
62- entities : optional ( array ( any ( ) ) , EMPTY_ARRAY )
64+ entities : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
65+ ...activityExtras
6366 } ) ,
6467 // Conclude with a message.
6568 object ( {
66- attachments : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
69+ // If "text" is empty, it represents "regretting" the livestream.
70+ type : literal ( 'message' ) ,
6771 channelData : object ( {
6872 // "streamId" is required for the final activity in the session.
6973 // The final activity must not be the sole activity in the session.
7074 streamId : pipe ( string ( ) , nonEmpty ( ) ) ,
7175 streamType : literal ( 'final' )
7276 } ) ,
73- id : string ( ) ,
74- // If "text" is empty, it represents "regretting" the livestream.
75- text : optional ( undefinedable ( string ( ) ) ) ,
76- type : literal ( 'message' ) ,
77- entities : optional ( array ( any ( ) ) , EMPTY_ARRAY )
77+ entities : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
78+ ...activityExtras
7879 } ) ,
7980 // Conclude without a message.
8081 object ( {
81- attachments : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
82+ // If "text" is not set or empty, it represents "regretting" the livestream.
83+ type : literal ( 'typing' ) ,
8284 channelData : object ( {
8385 // "streamId" is required for the final activity in the session.
8486 // The final activity must not be the sole activity in the session.
8587 streamId : pipe ( string ( ) , nonEmpty ( ) ) ,
8688 streamType : literal ( 'final' )
8789 } ) ,
88- id : string ( ) ,
89- // If "text" is not set or empty, it represents "regretting" the livestream.
90- text : optional ( undefinedable ( literal ( '' ) ) ) ,
91- type : literal ( 'typing' ) ,
92- entities : optional ( array ( any ( ) ) , EMPTY_ARRAY )
90+ entities : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
91+ ...activityExtras
9392 } )
9493] ) ;
9594
95+ // Extra Activity
96+
9697const entitiesStreamingActivitySchema = union ( [
9798 // Same thing but for entities
9899 object ( {
99- attachments : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
100+ type : literal ( 'typing' ) ,
100101 entities : array (
101102 object ( {
102103 // "streamId" is optional for the very first activity in the session.
@@ -106,14 +107,12 @@ const entitiesStreamingActivitySchema = union([
106107 } )
107108 ) ,
108109 channelData : any ( ) ,
109- id : string ( ) ,
110- // "text" is optional. If not set or empty, it presents a contentless activity.
111- text : optional ( undefinedable ( string ( ) ) ) ,
112- type : literal ( 'typing' )
110+ ...activityExtras
113111 } ) ,
114112 // Informative message.
115113 object ( {
116- attachments : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
114+ // Informative may not have "text", but should have abstract instead (checked later)
115+ type : literal ( 'typing' ) ,
117116 entities : array (
118117 object ( {
119118 // "streamId" is optional for the very first activity in the session.
@@ -123,14 +122,12 @@ const entitiesStreamingActivitySchema = union([
123122 } )
124123 ) ,
125124 channelData : any ( ) ,
126- id : string ( ) ,
127- // Informative may not have "text", but should have abstract instead (checked later)
128- text : optional ( undefinedable ( string ( ) ) ) ,
129- type : literal ( 'typing' )
125+ ...activityExtras
130126 } ) ,
131127 // Conclude with a message.
132128 object ( {
133- attachments : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
129+ // If "text" is empty, it represents "regretting" the livestream.
130+ type : literal ( 'message' ) ,
134131 entities : array (
135132 object ( {
136133 // "streamId" is required for the final activity in the session.
@@ -140,14 +137,12 @@ const entitiesStreamingActivitySchema = union([
140137 } )
141138 ) ,
142139 channelData : any ( ) ,
143- id : string ( ) ,
144- // If "text" is empty, it represents "regretting" the livestream.
145- text : optional ( undefinedable ( string ( ) ) ) ,
146- type : literal ( 'message' )
140+ ...activityExtras
147141 } ) ,
148142 // Conclude without a message.
149143 object ( {
150- attachments : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
144+ // If "text" is empty, it represents "regretting" the livestream.
145+ type : literal ( 'typing' ) ,
151146 entities : array (
152147 object ( {
153148 // "streamId" is required for the final activity in the session.
@@ -157,10 +152,7 @@ const entitiesStreamingActivitySchema = union([
157152 } )
158153 ) ,
159154 channelData : any ( ) ,
160- id : string ( ) ,
161- // If "text" is not set or empty, it represents "regretting" the livestream.
162- text : optional ( undefinedable ( literal ( '' ) ) ) ,
163- type : literal ( 'typing' )
155+ ...activityExtras
164156 } )
165157] ) ;
166158
@@ -224,7 +216,7 @@ export default function getActivityLivestreamingMetadata(activity: WebChatActivi
224216 type : ! (
225217 activityData . text ||
226218 activityData . attachments ?. length ||
227- ( 'entities' in activityData && getOrgSchemaMessage ( activity . entities ) )
219+ ( 'entities' in activityData && getOrgSchemaMessage ( activity . entities ) ?. abstract )
228220 )
229221 ? 'contentless'
230222 : streamingData . streamType === 'informative'
0 commit comments