@@ -46,44 +46,43 @@ const activityFieldsSchema = {
4646// Final Activities have different requirements for "text" fields
4747const { text : _text , ...activityFieldsFinalSchema } = activityFieldsSchema ;
4848
49- // Interim or Informative Activities
50- const ongoingStreamSchema = object ( {
51- // "streamId" is optional for the very first activity in the session.
52- streamId : optional ( undefinedable ( string ( ) ) ) ,
53- streamSequence : streamSequenceSchema ,
54- streamType : union ( [ literal ( 'streaming' ) , literal ( 'informative' ) ] )
55- } ) ;
56-
57- // Final Activities
58- const finalStreamSchema = object ( {
59- // "streamId" is required for the final activity in the session.
60- // The final activity must not be the sole activity in the session.
61- streamId : pipe ( string ( ) , nonEmpty ( ) ) ,
62- streamType : literal ( 'final' )
63- } ) ;
64-
6549const channelDataStreamingActivitySchema = union ( [
6650 // Interim or Informative message
6751 // Informative may not have "text", but should have abstract instead (checked later)
6852 object ( {
6953 type : literal ( 'typing' ) ,
70- channelData : ongoingStreamSchema ,
54+ channelData : object ( {
55+ // "streamId" is optional for the very first activity in the session.
56+ streamId : optional ( undefinedable ( string ( ) ) ) ,
57+ streamSequence : streamSequenceSchema ,
58+ streamType : union ( [ literal ( 'streaming' ) , literal ( 'informative' ) ] )
59+ } ) ,
7160 entities : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
7261 ...activityFieldsSchema
7362 } ) ,
7463 // Conclude with a message.
7564 object ( {
7665 // If "text" is empty, it represents "regretting" the livestream.
7766 type : literal ( 'message' ) ,
78- channelData : finalStreamSchema ,
67+ channelData : object ( {
68+ // "streamId" is required for the final activity in the session.
69+ // The final activity must not be the sole activity in the session.
70+ streamId : pipe ( string ( ) , nonEmpty ( ) ) ,
71+ streamType : literal ( 'final' )
72+ } ) ,
7973 entities : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
8074 ...activityFieldsSchema
8175 } ) ,
8276 // Conclude without a message.
8377 object ( {
8478 // If "text" is not set or empty, it represents "regretting" the livestream.
8579 type : literal ( 'typing' ) ,
86- channelData : finalStreamSchema ,
80+ channelData : object ( {
81+ // "streamId" is required for the final activity in the session.
82+ // The final activity must not be the sole activity in the session.
83+ streamId : pipe ( string ( ) , nonEmpty ( ) ) ,
84+ streamType : literal ( 'final' )
85+ } ) ,
8786 entities : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
8887 text : optional ( undefinedable ( literal ( '' ) ) ) ,
8988 ...activityFieldsFinalSchema
@@ -95,23 +94,47 @@ const entitiesStreamingActivitySchema = union([
9594 // Informative may not have "text", but should have abstract instead (checked later)
9695 object ( {
9796 type : literal ( 'typing' ) ,
98- entities : array ( ongoingStreamSchema ) ,
97+ entities : array (
98+ object ( {
99+ // "streamId" is optional for the very first activity in the session.
100+ streamId : optional ( undefinedable ( string ( ) ) ) ,
101+ streamSequence : streamSequenceSchema ,
102+ streamType : union ( [ literal ( 'streaming' ) , literal ( 'informative' ) ] ) ,
103+ type : literal ( 'streaminfo' )
104+ } )
105+ ) ,
99106 channelData : optional ( any ( ) ) ,
100107 ...activityFieldsSchema
101108 } ) ,
102109 // Conclude with a message.
103110 object ( {
104111 // If "text" is empty, it represents "regretting" the livestream.
105112 type : literal ( 'message' ) ,
106- entities : array ( finalStreamSchema ) ,
113+ entities : array (
114+ object ( {
115+ // "streamId" is required for the final activity in the session.
116+ // The final activity must not be the sole activity in the session.
117+ streamId : pipe ( string ( ) , nonEmpty ( ) ) ,
118+ streamType : literal ( 'final' ) ,
119+ type : literal ( 'streaminfo' )
120+ } )
121+ ) ,
107122 channelData : optional ( any ( ) ) ,
108123 ...activityFieldsSchema
109124 } ) ,
110125 // Conclude without a message.
111126 object ( {
112127 // If "text" is empty, it represents "regretting" the livestream.
113128 type : literal ( 'typing' ) ,
114- entities : array ( finalStreamSchema ) ,
129+ entities : array (
130+ object ( {
131+ // "streamId" is required for the final activity in the session.
132+ // The final activity must not be the sole activity in the session.
133+ streamId : pipe ( string ( ) , nonEmpty ( ) ) ,
134+ streamType : literal ( 'final' ) ,
135+ type : literal ( 'streaminfo' )
136+ } )
137+ ) ,
115138 channelData : optional ( any ( ) ) ,
116139 text : optional ( undefinedable ( literal ( '' ) ) ) ,
117140 ...activityFieldsFinalSchema
0 commit comments