Skip to content

Commit 4b69274

Browse files
committed
Revert back to original
1 parent ff4d888 commit 4b69274

1 file changed

Lines changed: 31 additions & 22 deletions

File tree

packages/core/src/utils/getActivityLivestreamingMetadata.ts

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@ const EMPTY_ARRAY = Object.freeze([]);
2929

3030
const streamSequenceSchema = pipe(number(), integer(), minValue(1));
3131

32-
// Fields required for every activity
33-
const activityFieldsSchema = {
34-
// "text" is optional. If not set or empty, it presents a contentless activity.
35-
text: optional(undefinedable(string())),
36-
attachments: optional(array(any()), EMPTY_ARRAY),
37-
id: string()
38-
};
39-
40-
// Final Activities have different requirements for "text" fields
41-
const { text: _text, ...activityFieldsFinalSchema } = activityFieldsSchema;
42-
4332
function eitherChannelDataOrEntities<
4433
TActivityEntries extends ObjectEntries,
4534
TActivityMessage extends ErrorMessage<ObjectIssue> | undefined,
@@ -78,27 +67,47 @@ function eitherChannelDataOrEntities<
7867
}
7968

8069
const livestreamingActivitySchema = union([
81-
// Interim or Informative message
82-
// Informative may not have "text", but should have abstract instead (checked later)
70+
// Interim.
8371
eitherChannelDataOrEntities(
8472
object({
73+
attachments: optional(array(any()), EMPTY_ARRAY),
74+
id: string(),
75+
// "text" is optional. If not set or empty, it presents a contentless activity.
76+
text: optional(undefinedable(string())),
77+
type: literal('typing')
78+
}),
79+
object({
80+
// "streamId" is optional for the very first activity in the session.
81+
streamId: optional(undefinedable(string())),
82+
streamSequence: streamSequenceSchema,
83+
streamType: literal('streaming')
84+
})
85+
),
86+
// Informative message.
87+
eitherChannelDataOrEntities(
88+
object({
89+
attachments: optional(array(any()), EMPTY_ARRAY),
90+
id: string(),
91+
// Informative may not have "text", but should have abstract instead (checked later)
92+
text: optional(undefinedable(string())),
8593
type: literal('typing'),
86-
...activityFieldsSchema
94+
entities: optional(array(any()), EMPTY_ARRAY)
8795
}),
88-
// "streamId" is optional for the very first activity in the session.
8996
object({
97+
// "streamId" is optional for the very first activity in the session.
9098
streamId: optional(undefinedable(string())),
9199
streamSequence: streamSequenceSchema,
92-
streamType: union([literal('streaming'), literal('informative')])
100+
streamType: literal('informative')
93101
})
94102
),
95-
96103
// Conclude with a message.
97104
eitherChannelDataOrEntities(
98105
object({
106+
attachments: optional(array(any()), EMPTY_ARRAY),
107+
id: string(),
99108
// If "text" is empty, it represents "regretting" the livestream.
100-
type: literal('message'),
101-
...activityFieldsSchema
109+
text: optional(undefinedable(string())),
110+
type: literal('message')
102111
}),
103112
object({
104113
// "streamId" is required for the final activity in the session.
@@ -107,14 +116,14 @@ const livestreamingActivitySchema = union([
107116
streamType: literal('final')
108117
})
109118
),
110-
111119
// Conclude without a message.
112120
eitherChannelDataOrEntities(
113121
object({
122+
attachments: optional(array(any()), EMPTY_ARRAY),
123+
id: string(),
114124
// If "text" is not set or empty, it represents "regretting" the livestream.
115-
type: literal('typing'),
116125
text: optional(undefinedable(literal(''))),
117-
...activityFieldsFinalSchema
126+
type: literal('typing')
118127
}),
119128
object({
120129
// "streamId" is required for the final activity in the session.

0 commit comments

Comments
 (0)