@alexsun-top/opencode-chat-room 0.8.4 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/README.md +4 -4
- package/README.zh-CN.md +4 -4
- package/cli.ts +1 -1
- package/dist/cli.js +35 -16
- package/package.json +14 -11
- package/packages/chat-room-channeld/README.md +3 -2
- package/packages/chat-room-channeld/src/inbound.ts +3 -6
- package/packages/chat-room-channeld/src/pg/sql.mjs +157 -142
- package/packages/chat-room-channeld/src/pg/sql.mts +175 -0
- package/packages/chat-room-channeld/src/pg/worker.mjs +107 -99
- package/packages/chat-room-channeld/src/pg/worker.mts +166 -0
- package/plugin.ts +1 -1
- package/server/assets/chat/admin.js +4 -1
- package/server/assets/chat/announcements.js +3 -0
- package/server/assets/chat/attachments.js +3 -3
- package/server/assets/chat/clipboard.js +1 -1
- package/server/assets/chat/copy-action.js +1 -1
- package/server/assets/chat/doc-preview.js +1 -1
- package/server/assets/chat/editor.js +11 -7
- package/server/assets/chat/events.js +7 -5
- package/server/assets/chat/files.js +5 -1
- package/server/assets/chat/integration-editor.js +2 -0
- package/server/assets/chat/integrations.js +1 -1
- package/server/assets/chat/join-requests.js +1 -1
- package/server/assets/chat/markdown-footnotes.js +8 -7
- package/server/assets/chat/markdown.js +6 -5
- package/server/assets/chat/members.js +3 -3
- package/server/assets/chat/mentions.js +8 -5
- package/server/assets/chat/message-cache.js +1 -1
- package/server/assets/chat/message-polling.js +2 -2
- package/server/assets/chat/message-window.js +1 -1
- package/server/assets/chat/messages.js +17 -3
- package/server/assets/chat/office-preview.js +3 -3
- package/server/assets/chat/palette.js +5 -3
- package/server/assets/chat/panels.js +19 -0
- package/server/assets/chat/questions.js +3 -2
- package/server/assets/chat/reminders.js +3 -0
- package/server/assets/chat/replies.js +6 -3
- package/server/assets/chat/resource-format.js +2 -2
- package/server/assets/chat/rooms.js +7 -4
- package/server/assets/chat/settings.js +4 -3
- package/server/assets/chat/shortcuts.js +3 -1
- package/server/assets/chat/side-pane.js +1 -1
- package/server/assets/chat/state.js +30 -11
- package/server/assets/chat/system-events.js +3 -2
- package/server/assets/chat/system-messages.js +15 -15
- package/server/assets/chat/tasks.js +4 -3
- package/server/assets/chat/window-controls.js +3 -2
- package/server/assets/conversation.css +14 -2
- package/server/assets/doc-preview.css +6 -0
- package/server/assets/office/THIRD-PARTY-NOTICES.txt +23 -1
- package/server/assets/office/licenses/docx-preview-HEADER.txt +6 -0
- package/server/assets/office/licenses/echarts-LICENSE-d3.txt +27 -0
- package/server/assets/office/licenses/echarts-NOTICE.txt +5 -0
- package/server/assets/office/licenses/immediate-LICENSE.txt +20 -0
- package/server/assets/office/licenses/lie-LICENSE.txt +7 -0
- package/server/assets/office/licenses/pako-LICENSE.txt +21 -0
- package/server/assets/office/licenses/pako-ZLIB.txt +18 -0
- package/server/assets/office/licenses/setimmediate-LICENSE.txt +20 -0
- package/server/sw.js +3 -1
- package/skills/chatroom/SKILL.md +9 -0
- package/src/README.md +1 -1
- package/src/agent/agent-receipts.ts +12 -4
- package/src/center/center-client.ts +1 -1
- package/src/state/pg-sql.mjs +157 -142
- package/src/state/pg-sql.mts +175 -0
- package/src/state/pg-worker.mjs +107 -99
- package/src/state/pg-worker.mts +166 -0
- package/src/state/store.ts +21 -7
- package/src/tui/app-types.mjs +1 -0
- package/src/tui/app-types.mts +175 -0
- package/src/tui/app.mjs +426 -423
- package/src/tui/app.mts +500 -0
- package/src/tui/config.mjs +166 -158
- package/src/tui/config.mts +247 -0
- package/src/tui/http.mjs +239 -206
- package/src/tui/http.mts +412 -0
- package/src/tui/i18n.mjs +17 -20
- package/src/tui/i18n.mts +42 -0
- package/src/tui/info-app.mjs +431 -427
- package/src/tui/info-app.mts +500 -0
- package/src/tui/info-content.mjs +205 -199
- package/src/tui/info-content.mts +341 -0
- package/src/tui/join-app.mjs +75 -64
- package/src/tui/join-app.mts +99 -0
- package/src/tui/locales/en.mjs +302 -320
- package/src/tui/locales/en.mts +349 -0
- package/src/tui/locales/zh-CN.mjs +302 -320
- package/src/tui/locales/zh-CN.mts +349 -0
- package/src/tui/main.mjs +219 -213
- package/src/tui/main.mts +255 -0
- package/src/tui/markdown.mjs +128 -272
- package/src/tui/markdown.mts +152 -0
- package/src/tui/mentions.mjs +181 -184
- package/src/tui/mentions.mts +251 -0
- package/src/tui/message-app.mjs +181 -173
- package/src/tui/message-app.mts +213 -0
- package/src/tui/message-view.mjs +90 -111
- package/src/tui/message-view.mts +151 -0
- package/src/tui/messages.mjs +55 -49
- package/src/tui/messages.mts +106 -0
- package/src/tui/palette-app.mjs +364 -344
- package/src/tui/palette-app.mts +388 -0
- package/src/tui/palette.mjs +100 -98
- package/src/tui/palette.mts +176 -0
- package/src/tui/prefs.mjs +56 -63
- package/src/tui/prefs.mts +126 -0
- package/src/tui/reminder-app.mjs +191 -181
- package/src/tui/reminder-app.mts +228 -0
- package/src/tui/room-settings-app.mjs +257 -242
- package/src/tui/room-settings-app.mts +301 -0
- package/src/tui/session.mjs +30 -29
- package/src/tui/session.mts +51 -0
- package/src/tui/settings-app.mjs +151 -138
- package/src/tui/settings-app.mts +179 -0
- package/src/tui/ui-content.mjs +426 -421
- package/src/tui/ui-content.mts +499 -0
- package/src/tui/ui-help.mjs +58 -67
- package/src/tui/ui-help.mts +87 -0
- package/src/tui/ui-mentions.mjs +34 -36
- package/src/tui/ui-mentions.mts +60 -0
- package/src/tui/ui-overlay-view.mjs +259 -267
- package/src/tui/ui-overlay-view.mts +322 -0
- package/src/tui/ui-suggest-view.mjs +54 -57
- package/src/tui/ui-suggest-view.mts +78 -0
- package/src/tui/ui-suggest.mjs +164 -167
- package/src/tui/ui-suggest.mts +248 -0
- package/src/tui/ui-theme.mjs +52 -57
- package/src/tui/ui-theme.mts +98 -0
- package/src/tui/ui-view.mjs +267 -275
- package/src/tui/ui-view.mts +308 -0
- package/src/tui/ui.mjs +372 -359
- package/src/tui/ui.mts +440 -0
- package/src/tui/wire.mjs +215 -0
- package/src/tui/wire.mts +383 -0
package/src/tui/wire.mts
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
// Server wire shapes shared by the TUI HTTP client and its views. Guarded
|
|
2
|
+
// constructors check the fields a client indexes by, so malformed payloads
|
|
3
|
+
// degrade to null or an empty list instead of reaching a typed caller.
|
|
4
|
+
import type { ChatMessage, Participant } from "./messages.mjs";
|
|
5
|
+
|
|
6
|
+
export interface Member {
|
|
7
|
+
sessionID?: string;
|
|
8
|
+
membershipID?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
type?: string;
|
|
11
|
+
protocol?: string;
|
|
12
|
+
host?: string;
|
|
13
|
+
activity?: { state?: string; observedAt?: number | null };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface Announcement {
|
|
17
|
+
name?: string;
|
|
18
|
+
content?: unknown;
|
|
19
|
+
updatedAt?: unknown;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface Question {
|
|
23
|
+
id?: unknown;
|
|
24
|
+
senderId?: string;
|
|
25
|
+
text?: unknown;
|
|
26
|
+
answeredByMessageID?: unknown;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Resource {
|
|
30
|
+
id?: unknown;
|
|
31
|
+
name?: string;
|
|
32
|
+
size?: unknown;
|
|
33
|
+
uploaderName?: string;
|
|
34
|
+
uploaderSessionID?: string;
|
|
35
|
+
createdAt?: unknown;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface JoinRequest {
|
|
39
|
+
sessionID?: unknown;
|
|
40
|
+
name?: string;
|
|
41
|
+
participantId?: string;
|
|
42
|
+
isAgent?: unknown;
|
|
43
|
+
createdAt?: unknown;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ReminderScheduleInput {
|
|
47
|
+
type?: string;
|
|
48
|
+
expression?: string;
|
|
49
|
+
timezone?: string;
|
|
50
|
+
at?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface Reminder {
|
|
54
|
+
id?: unknown;
|
|
55
|
+
paused?: unknown;
|
|
56
|
+
text?: unknown;
|
|
57
|
+
schedule?: ReminderScheduleInput;
|
|
58
|
+
nextRunAt?: unknown;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface RoomWire {
|
|
62
|
+
id: string;
|
|
63
|
+
name?: string;
|
|
64
|
+
participants?: Participant[];
|
|
65
|
+
messages?: ChatMessage[];
|
|
66
|
+
hasMore?: boolean;
|
|
67
|
+
nextBeforeSeq?: number | null;
|
|
68
|
+
recallVersion?: number;
|
|
69
|
+
joined?: boolean;
|
|
70
|
+
ownerId?: string;
|
|
71
|
+
adminIds?: string[];
|
|
72
|
+
successorId?: string | null;
|
|
73
|
+
joinPolicy?: string;
|
|
74
|
+
kind?: string;
|
|
75
|
+
adminSessionID?: string | null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface HistoryPage {
|
|
79
|
+
messages: ChatMessage[];
|
|
80
|
+
hasMore?: boolean;
|
|
81
|
+
nextBeforeSeq?: number | null;
|
|
82
|
+
recallVersion?: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface InboxItem extends ChatMessage {
|
|
86
|
+
roomName?: string;
|
|
87
|
+
roomKind?: "group" | "direct";
|
|
88
|
+
answerQuestionExcerpt?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface InboxPage {
|
|
92
|
+
member: boolean;
|
|
93
|
+
items: InboxItem[];
|
|
94
|
+
hasMore?: boolean;
|
|
95
|
+
recallVersion?: number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface MessageView {
|
|
99
|
+
id: string;
|
|
100
|
+
roomId?: string;
|
|
101
|
+
seq?: number;
|
|
102
|
+
senderId?: string;
|
|
103
|
+
senderName?: string;
|
|
104
|
+
text?: string | null;
|
|
105
|
+
createdAt?: number | string;
|
|
106
|
+
isQuestion?: boolean;
|
|
107
|
+
parentMessageId?: string | null;
|
|
108
|
+
answeredByMessageId?: string | null;
|
|
109
|
+
recalled?: boolean;
|
|
110
|
+
recalledAt?: number;
|
|
111
|
+
recalledBy?: string | null;
|
|
112
|
+
unavailable?: string;
|
|
113
|
+
resourceIDs?: string[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface RevealedMessage {
|
|
117
|
+
messageID?: string;
|
|
118
|
+
text?: string | null;
|
|
119
|
+
senderId?: string;
|
|
120
|
+
createdAt?: number;
|
|
121
|
+
recalledAt?: number;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface RecallResult {
|
|
125
|
+
ok?: boolean;
|
|
126
|
+
messageID?: string;
|
|
127
|
+
text?: string | null;
|
|
128
|
+
senderId?: string;
|
|
129
|
+
createdAt?: number;
|
|
130
|
+
recalledAt?: number;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface CatchUpPage {
|
|
134
|
+
messages: MessageView[];
|
|
135
|
+
nextCursor?: number;
|
|
136
|
+
hasMore?: boolean;
|
|
137
|
+
unreadMentions?: Array<{ id: string; seq?: number }>;
|
|
138
|
+
unreadMentionCount?: number;
|
|
139
|
+
unansweredQuestions?: Array<{ id: string; seq?: number }>;
|
|
140
|
+
unansweredQuestionCount?: number;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface ResourcesPage {
|
|
144
|
+
resources: Resource[];
|
|
145
|
+
total?: number;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface QuestionAnswer {
|
|
149
|
+
questionID?: string;
|
|
150
|
+
answer?: unknown;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface OkResult {
|
|
154
|
+
ok?: boolean;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function record(value: unknown): Record<string, unknown> | null {
|
|
158
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
159
|
+
? value as Record<string, unknown>
|
|
160
|
+
: null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const isString = (value: unknown): boolean => typeof value === "string";
|
|
164
|
+
const isNumber = (value: unknown): boolean => typeof value === "number";
|
|
165
|
+
const isBoolean = (value: unknown): boolean => typeof value === "boolean";
|
|
166
|
+
const optional = (value: unknown, check: (value: unknown) => boolean): boolean =>
|
|
167
|
+
value === undefined || check(value);
|
|
168
|
+
const nullable = (value: unknown, check: (value: unknown) => boolean): boolean =>
|
|
169
|
+
value === undefined || value === null || check(value);
|
|
170
|
+
const isMessageText = (value: unknown): boolean => value === null || isString(value);
|
|
171
|
+
const isIdRefList = (value: unknown): boolean =>
|
|
172
|
+
Array.isArray(value) && value.every((item) => {
|
|
173
|
+
const ref = record(item);
|
|
174
|
+
return ref !== null && isString(ref.id) && optional(ref.seq, isNumber);
|
|
175
|
+
});
|
|
176
|
+
const isParticipantList = (value: unknown): boolean =>
|
|
177
|
+
Array.isArray(value) && value.every((item) => {
|
|
178
|
+
const participant = record(item);
|
|
179
|
+
return participant !== null && optional(participant.id, isString) && optional(participant.name, isString);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Valid entries are kept; one malformed entry is skipped so the caller still
|
|
183
|
+
// gets the rest of an otherwise valid page.
|
|
184
|
+
function keepItems<T>(value: unknown, guard: (value: unknown) => value is T): T[] | null {
|
|
185
|
+
return Array.isArray(value) ? value.filter(guard) : null;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export function isStoredMessage(value: unknown): value is ChatMessage {
|
|
189
|
+
const message = record(value);
|
|
190
|
+
return message !== null
|
|
191
|
+
&& isString(message.id) && message.id !== ""
|
|
192
|
+
&& optional(message.createdAt, (item) => isNumber(item) || isString(item))
|
|
193
|
+
&& optional(message.text, isString)
|
|
194
|
+
&& optional(message.seq, isNumber)
|
|
195
|
+
&& optional(message.senderId, isString)
|
|
196
|
+
&& optional(message.senderSessionID, isString)
|
|
197
|
+
&& optional(message.recalledAt, isNumber)
|
|
198
|
+
&& optional(message.isQuestion, isBoolean);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export function isInboxItem(value: unknown): value is InboxItem {
|
|
202
|
+
if (!isStoredMessage(value)) return false;
|
|
203
|
+
const item = record(value);
|
|
204
|
+
return item !== null
|
|
205
|
+
&& optional(item.roomName, isString)
|
|
206
|
+
&& optional(item.roomKind, (kind) => kind === "group" || kind === "direct")
|
|
207
|
+
&& optional(item.answerQuestionExcerpt, isString);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export function isRoom(value: unknown): value is RoomWire {
|
|
211
|
+
const room = record(value);
|
|
212
|
+
if (!room || !isString(room.id) || !room.id) return false;
|
|
213
|
+
if (!optional(room.name, isString)
|
|
214
|
+
|| !optional(room.hasMore, isBoolean)
|
|
215
|
+
|| !nullable(room.nextBeforeSeq, isNumber)
|
|
216
|
+
|| !optional(room.recallVersion, isNumber)
|
|
217
|
+
|| !optional(room.joined, isBoolean)
|
|
218
|
+
|| !optional(room.ownerId, isString)
|
|
219
|
+
|| !optional(room.adminIds, (ids) => Array.isArray(ids) && ids.every(isString))
|
|
220
|
+
|| !nullable(room.successorId, isString)
|
|
221
|
+
|| !optional(room.joinPolicy, isString)
|
|
222
|
+
|| !optional(room.kind, isString)
|
|
223
|
+
|| !nullable(room.adminSessionID, isString)
|
|
224
|
+
|| !optional(room.participants, isParticipantList)) return false;
|
|
225
|
+
const messages = keepItems(room.messages, isStoredMessage);
|
|
226
|
+
if (room.messages !== undefined && messages === null) return false;
|
|
227
|
+
if (messages) room.messages = messages;
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export function roomList(value: unknown): RoomWire[] {
|
|
232
|
+
return Array.isArray(value) ? value.filter(isRoom) : [];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function isHistoryPage(value: unknown): value is HistoryPage {
|
|
236
|
+
const page = record(value);
|
|
237
|
+
if (page === null || !optional(page.hasMore, isBoolean)
|
|
238
|
+
|| !nullable(page.nextBeforeSeq, isNumber)
|
|
239
|
+
|| !optional(page.recallVersion, isNumber)) return false;
|
|
240
|
+
const messages = keepItems(page.messages, isStoredMessage);
|
|
241
|
+
if (messages === null) return false;
|
|
242
|
+
page.messages = messages;
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function isInboxPage(value: unknown): value is InboxPage {
|
|
247
|
+
const page = record(value);
|
|
248
|
+
if (page === null || !isBoolean(page.member)
|
|
249
|
+
|| !optional(page.hasMore, isBoolean)
|
|
250
|
+
|| !optional(page.recallVersion, isNumber)) return false;
|
|
251
|
+
const items = keepItems(page.items, isInboxItem);
|
|
252
|
+
if (items === null) return false;
|
|
253
|
+
page.items = items;
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export function isMessageView(value: unknown): value is MessageView {
|
|
258
|
+
const message = record(value);
|
|
259
|
+
return message !== null
|
|
260
|
+
&& isString(message.id) && message.id !== ""
|
|
261
|
+
&& optional(message.roomId, isString)
|
|
262
|
+
&& optional(message.seq, isNumber)
|
|
263
|
+
&& optional(message.senderId, isString)
|
|
264
|
+
&& optional(message.senderName, isString)
|
|
265
|
+
&& optional(message.text, isMessageText)
|
|
266
|
+
&& optional(message.createdAt, (item) => isNumber(item) || isString(item))
|
|
267
|
+
&& optional(message.isQuestion, isBoolean)
|
|
268
|
+
&& nullable(message.parentMessageId, isString)
|
|
269
|
+
&& nullable(message.answeredByMessageId, isString)
|
|
270
|
+
&& optional(message.recalled, isBoolean)
|
|
271
|
+
&& optional(message.recalledAt, isNumber)
|
|
272
|
+
&& nullable(message.recalledBy, isString)
|
|
273
|
+
&& optional(message.unavailable, isString)
|
|
274
|
+
&& optional(message.resourceIDs, (ids) => Array.isArray(ids) && ids.every(isString));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export function isCatchUpPage(value: unknown): value is CatchUpPage {
|
|
278
|
+
const page = record(value);
|
|
279
|
+
if (page === null || !optional(page.nextCursor, isNumber)
|
|
280
|
+
|| !optional(page.hasMore, isBoolean)
|
|
281
|
+
|| !optional(page.unreadMentions, isIdRefList)
|
|
282
|
+
|| !optional(page.unreadMentionCount, isNumber)
|
|
283
|
+
|| !optional(page.unansweredQuestions, isIdRefList)
|
|
284
|
+
|| !optional(page.unansweredQuestionCount, isNumber)) return false;
|
|
285
|
+
const messages = keepItems(page.messages, isMessageView);
|
|
286
|
+
if (messages === null) return false;
|
|
287
|
+
page.messages = messages;
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export function isRecallResult(value: unknown): value is RecallResult {
|
|
292
|
+
const result = record(value);
|
|
293
|
+
return result !== null
|
|
294
|
+
&& optional(result.ok, isBoolean)
|
|
295
|
+
&& optional(result.messageID, isString)
|
|
296
|
+
&& optional(result.text, isMessageText)
|
|
297
|
+
&& optional(result.senderId, isString)
|
|
298
|
+
&& optional(result.createdAt, isNumber)
|
|
299
|
+
&& optional(result.recalledAt, isNumber);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export function isRevealed(value: unknown): value is RevealedMessage {
|
|
303
|
+
const message = record(value);
|
|
304
|
+
return message !== null
|
|
305
|
+
&& optional(message.messageID, isString)
|
|
306
|
+
&& optional(message.text, isMessageText)
|
|
307
|
+
&& optional(message.senderId, isString)
|
|
308
|
+
&& optional(message.createdAt, isNumber)
|
|
309
|
+
&& optional(message.recalledAt, isNumber);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export function isResource(value: unknown): value is Resource {
|
|
313
|
+
const resource = record(value);
|
|
314
|
+
return resource !== null
|
|
315
|
+
&& optional(resource.name, isString)
|
|
316
|
+
&& optional(resource.uploaderName, isString)
|
|
317
|
+
&& optional(resource.uploaderSessionID, isString);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export function isResourcesPage(value: unknown): value is ResourcesPage {
|
|
321
|
+
const page = record(value);
|
|
322
|
+
if (page === null || !optional(page.total, isNumber)) return false;
|
|
323
|
+
const resources = keepItems(page.resources, isResource);
|
|
324
|
+
if (resources === null) return false;
|
|
325
|
+
page.resources = resources;
|
|
326
|
+
return true;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export function isMember(value: unknown): value is Member {
|
|
330
|
+
const member = record(value);
|
|
331
|
+
return member !== null
|
|
332
|
+
&& optional(member.sessionID, isString)
|
|
333
|
+
&& optional(member.membershipID, isString)
|
|
334
|
+
&& optional(member.name, isString)
|
|
335
|
+
&& optional(member.type, isString)
|
|
336
|
+
&& optional(member.protocol, isString)
|
|
337
|
+
&& optional(member.host, isString)
|
|
338
|
+
&& optional(member.activity, (item) => {
|
|
339
|
+
const activity = record(item);
|
|
340
|
+
return activity !== null
|
|
341
|
+
&& optional(activity.state, isString)
|
|
342
|
+
&& nullable(activity.observedAt, isNumber);
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export function isAnnouncement(value: unknown): value is Announcement {
|
|
347
|
+
const announcement = record(value);
|
|
348
|
+
return announcement !== null && optional(announcement.name, isString);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export function isQuestion(value: unknown): value is Question {
|
|
352
|
+
const question = record(value);
|
|
353
|
+
return question !== null && optional(question.senderId, isString);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export function isJoinRequest(value: unknown): value is JoinRequest {
|
|
357
|
+
const request = record(value);
|
|
358
|
+
return request !== null
|
|
359
|
+
&& optional(request.name, isString)
|
|
360
|
+
&& optional(request.participantId, isString);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export function isReminder(value: unknown): value is Reminder {
|
|
364
|
+
const reminder = record(value);
|
|
365
|
+
return reminder !== null && optional(reminder.schedule, (item) => {
|
|
366
|
+
const schedule = record(item);
|
|
367
|
+
return schedule !== null
|
|
368
|
+
&& optional(schedule.type, isString)
|
|
369
|
+
&& optional(schedule.expression, isString)
|
|
370
|
+
&& optional(schedule.timezone, isString)
|
|
371
|
+
&& optional(schedule.at, isString);
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export function isQuestionsAnswer(value: unknown): value is QuestionAnswer {
|
|
376
|
+
const answer = record(value);
|
|
377
|
+
return answer !== null && optional(answer.questionID, isString);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export function isOk(value: unknown): value is OkResult {
|
|
381
|
+
const result = record(value);
|
|
382
|
+
return result !== null && optional(result.ok, isBoolean);
|
|
383
|
+
}
|