@@ -39,117 +39,72 @@ const activityExtras = {
3939
4040const { text : _text , ...activityExtrasFinal } = activityExtras ;
4141
42+ // Interim or Informative Activities
43+ const activeSchema = object ( {
44+ // "streamId" is optional for the very first activity in the session.
45+ streamId : optional ( undefinedable ( string ( ) ) ) ,
46+ streamSequence : streamSequenceSchema ,
47+ streamType : union ( [ literal ( 'streaming' ) , literal ( 'informative' ) ] )
48+ } ) ;
49+
50+ // Final Activities
51+ const finalActivitySchema = object ( {
52+ // "streamId" is required for the final activity in the session.
53+ // The final activity must not be the sole activity in the session.
54+ streamId : pipe ( string ( ) , nonEmpty ( ) ) ,
55+ streamType : literal ( 'final' )
56+ } ) ;
57+
4258const channelDataStreamingActivitySchema = union ( [
43- // Interim.
44- object ( {
45- type : literal ( 'typing' ) ,
46- channelData : object ( {
47- // "streamId" is optional for the very first activity in the session.
48- streamId : optional ( undefinedable ( string ( ) ) ) ,
49- streamSequence : streamSequenceSchema ,
50- streamType : literal ( 'streaming' )
51- } ) ,
52- entities : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
53- ...activityExtras
54- } ) ,
55- // Informative message.
59+ // Interim or Informative message
60+ // Informative may not have "text", but should have abstract instead (checked later)
5661 object ( {
57- // Informative may not have "text", but should have abstract instead (checked later)
5862 type : literal ( 'typing' ) ,
59- channelData : object ( {
60- // "streamId" is optional for the very first activity in the session.
61- streamId : optional ( undefinedable ( string ( ) ) ) ,
62- streamSequence : streamSequenceSchema ,
63- streamType : literal ( 'informative' )
64- } ) ,
63+ channelData : activeSchema ,
6564 entities : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
6665 ...activityExtras
6766 } ) ,
6867 // Conclude with a message.
6968 object ( {
7069 // If "text" is empty, it represents "regretting" the livestream.
7170 type : literal ( 'message' ) ,
72- channelData : object ( {
73- // "streamId" is required for the final activity in the session.
74- // The final activity must not be the sole activity in the session.
75- streamId : pipe ( string ( ) , nonEmpty ( ) ) ,
76- streamType : literal ( 'final' )
77- } ) ,
71+ channelData : finalActivitySchema ,
7872 entities : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
7973 ...activityExtras
8074 } ) ,
8175 // Conclude without a message.
8276 object ( {
8377 // If "text" is not set or empty, it represents "regretting" the livestream.
8478 type : literal ( 'typing' ) ,
85- channelData : object ( {
86- // "streamId" is required for the final activity in the session.
87- // The final activity must not be the sole activity in the session.
88- streamId : pipe ( string ( ) , nonEmpty ( ) ) ,
89- streamType : literal ( 'final' )
90- } ) ,
79+ channelData : finalActivitySchema ,
9180 entities : optional ( array ( any ( ) ) , EMPTY_ARRAY ) ,
9281 text : optional ( undefinedable ( literal ( '' ) ) ) ,
9382 ...activityExtrasFinal
9483 } )
9584] ) ;
9685
9786const entitiesStreamingActivitySchema = union ( [
87+ // Interim or Informative message
88+ // Informative may not have "text", but should have abstract instead (checked later)
9889 object ( {
9990 type : literal ( 'typing' ) ,
100- entities : array (
101- object ( {
102- // "streamId" is optional for the very first activity in the session.
103- streamId : optional ( undefinedable ( string ( ) ) ) ,
104- streamSequence : streamSequenceSchema ,
105- streamType : literal ( 'streaming' )
106- } )
107- ) ,
108- channelData : any ( ) ,
109- ...activityExtras
110- } ) ,
111- // Informative message.
112- object ( {
113- // Informative may not have "text", but should have abstract instead (checked later)
114- type : literal ( 'typing' ) ,
115- entities : array (
116- object ( {
117- // "streamId" is optional for the very first activity in the session.
118- streamId : optional ( undefinedable ( string ( ) ) ) ,
119- streamSequence : streamSequenceSchema ,
120- streamType : literal ( 'informative' )
121- } )
122- ) ,
91+ entities : array ( activeSchema ) ,
12392 channelData : any ( ) ,
12493 ...activityExtras
12594 } ) ,
12695 // Conclude with a message.
12796 object ( {
12897 // If "text" is empty, it represents "regretting" the livestream.
12998 type : literal ( 'message' ) ,
130- entities : array (
131- object ( {
132- // "streamId" is required for the final activity in the session.
133- // The final activity must not be the sole activity in the session.
134- streamId : pipe ( string ( ) , nonEmpty ( ) ) ,
135- streamType : literal ( 'final' )
136- } )
137- ) ,
99+ entities : array ( finalActivitySchema ) ,
138100 channelData : any ( ) ,
139101 ...activityExtras
140102 } ) ,
141103 // Conclude without a message.
142104 object ( {
143105 // If "text" is empty, it represents "regretting" the livestream.
144106 type : literal ( 'typing' ) ,
145- entities : array (
146- object ( {
147- // "streamId" is required for the final activity in the session.
148- // The final activity must not be the sole activity in the session.
149- streamId : pipe ( string ( ) , nonEmpty ( ) ) ,
150- streamType : literal ( 'final' )
151- } )
152- ) ,
107+ entities : array ( finalActivitySchema ) ,
153108 channelData : any ( ) ,
154109 text : optional ( undefinedable ( literal ( '' ) ) ) ,
155110 ...activityExtrasFinal
0 commit comments