diff --git a/lib/types/activity-types.js b/lib/types/activity-types.js --- a/lib/types/activity-types.js +++ b/lib/types/activity-types.js @@ -9,6 +9,12 @@ +threadID: string, +latestMessage: ?string, }; +export const activityUpdateValidator: TInterface = + tShape({ + focus: t.Boolean, + threadID: tID, + latestMessage: t.maybe(tID), + }); export type UpdateActivityRequest = { +updates: $ReadOnlyArray, diff --git a/lib/types/entry-types.js b/lib/types/entry-types.js --- a/lib/types/entry-types.js +++ b/lib/types/entry-types.js @@ -3,7 +3,11 @@ import t, { type TInterface } from 'tcomb'; import { type Platform, isWebPlatform } from './device-types.js'; -import { type CalendarFilter, defaultCalendarFilters } from './filter-types.js'; +import { + type CalendarFilter, + calendarFilterValidator, + defaultCalendarFilters, +} from './filter-types.js'; import type { RawMessageInfo } from './message-types.js'; import type { ServerCreateUpdatesResponse, @@ -73,6 +77,13 @@ +filters: $ReadOnlyArray, }; +export const calendarQueryValidator: TInterface = + tShape({ + startDate: t.String, + endDate: t.String, + filters: t.list(calendarFilterValidator), + }); + export const defaultCalendarQuery = ( platform: ?Platform, timeZone?: ?string, diff --git a/lib/types/filter-types.js b/lib/types/filter-types.js --- a/lib/types/filter-types.js +++ b/lib/types/filter-types.js @@ -1,6 +1,9 @@ // @flow +import t, { type TUnion } from 'tcomb'; + import type { ResolvedThreadInfo } from './thread-types.js'; +import { tID, tShape, tString } from '../utils/validation-utils.js'; export const calendarThreadFilterTypes = Object.freeze({ THREAD_LIST: 'threads', @@ -16,6 +19,14 @@ }; export type CalendarFilter = { +type: 'not_deleted' } | CalendarThreadFilter; +export const calendarFilterValidator: TUnion = t.union([ + tShape({ + type: tString('threads'), + threadIDs: t.list(tID), + }), + tShape({ type: tString('not_deleted') }), +]); + export const defaultCalendarFilters: $ReadOnlyArray = [ { type: calendarThreadFilterTypes.NOT_DELETED }, ]; diff --git a/lib/types/socket-types.js b/lib/types/socket-types.js --- a/lib/types/socket-types.js +++ b/lib/types/socket-types.js @@ -5,6 +5,7 @@ import { type ActivityUpdate, + activityUpdateValidator, type UpdateActivityResult, updateActivityResultValidator, } from './activity-types.js'; @@ -14,6 +15,7 @@ type RawEntryInfo, rawEntryInfoValidator, type CalendarQuery, + calendarQueryValidator, defaultCalendarQuery, } from './entry-types.js'; import { @@ -473,6 +475,21 @@ +lateResponses: $ReadOnlyArray, +showDisconnectedBar: boolean, }; +export const connectionInfoValidator: TInterface = + tShape({ + status: t.enums.of([ + 'connecting', + 'connected', + 'reconnecting', + 'disconnecting', + 'forcedDisconnecting', + 'disconnected', + ]), + queuedActivityUpdates: t.list(activityUpdateValidator), + actualizedCalendarQuery: calendarQueryValidator, + lateResponses: t.list(t.Number), + showDisconnectedBar: t.Boolean, + }); export const defaultConnectionInfo = ( platform: Platform, timeZone?: ?string,