diff --git a/keyserver/src/creators/message-creator.js b/keyserver/src/creators/message-creator.js --- a/keyserver/src/creators/message-creator.js +++ b/keyserver/src/creators/message-creator.js @@ -20,7 +20,7 @@ } from 'lib/types/message-types.js'; import { redisMessageTypes } from 'lib/types/redis-types.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; -import { updateTypes } from 'lib/types/update-types.js'; +import { updateTypes } from 'lib/types/update-types-enum.js'; import { promiseAll } from 'lib/utils/promises.js'; import createIDs from './id-creator.js'; diff --git a/keyserver/src/creators/update-creator.js b/keyserver/src/creators/update-creator.js --- a/keyserver/src/creators/update-creator.js +++ b/keyserver/src/creators/update-creator.js @@ -24,12 +24,12 @@ type NewUpdatesRedisMessage, } from 'lib/types/redis-types.js'; import type { RawThreadInfo } from 'lib/types/thread-types.js'; +import { updateTypes } from 'lib/types/update-types-enum.js'; import { type ServerUpdateInfo, type UpdateData, type RawUpdateInfo, type CreateUpdatesResult, - updateTypes, } from 'lib/types/update-types.js'; import type { UserInfos, diff --git a/keyserver/src/deleters/account-deleters.js b/keyserver/src/deleters/account-deleters.js --- a/keyserver/src/deleters/account-deleters.js +++ b/keyserver/src/deleters/account-deleters.js @@ -6,7 +6,7 @@ LogOutResponse, DeleteAccountRequest, } from 'lib/types/account-types.js'; -import { updateTypes } from 'lib/types/update-types.js'; +import { updateTypes } from 'lib/types/update-types-enum.js'; import type { UserInfo } from 'lib/types/user-types.js'; import { ServerError } from 'lib/utils/errors.js'; import { values } from 'lib/utils/objects.js'; diff --git a/keyserver/src/deleters/thread-deleters.js b/keyserver/src/deleters/thread-deleters.js --- a/keyserver/src/deleters/thread-deleters.js +++ b/keyserver/src/deleters/thread-deleters.js @@ -7,7 +7,7 @@ type ThreadDeletionRequest, type LeaveThreadResult, } from 'lib/types/thread-types.js'; -import { updateTypes } from 'lib/types/update-types.js'; +import { updateTypes } from 'lib/types/update-types-enum.js'; import { ServerError } from 'lib/utils/errors.js'; import { createUpdates } from '../creators/update-creator.js'; diff --git a/keyserver/src/fetchers/update-fetchers.js b/keyserver/src/fetchers/update-fetchers.js --- a/keyserver/src/fetchers/update-fetchers.js +++ b/keyserver/src/fetchers/update-fetchers.js @@ -3,11 +3,8 @@ import invariant from 'invariant'; import type { CalendarQuery } from 'lib/types/entry-types.js'; -import { - type RawUpdateInfo, - updateTypes, - assertUpdateType, -} from 'lib/types/update-types.js'; +import { updateTypes, assertUpdateType } from 'lib/types/update-types-enum.js'; +import { type RawUpdateInfo } from 'lib/types/update-types.js'; import { ServerError } from 'lib/utils/errors.js'; import { diff --git a/keyserver/src/push/send.js b/keyserver/src/push/send.js --- a/keyserver/src/push/send.js +++ b/keyserver/src/push/send.js @@ -34,7 +34,7 @@ ResolvedNotifTexts, } from 'lib/types/notif-types.js'; import type { ServerThreadInfo } from 'lib/types/thread-types.js'; -import { updateTypes } from 'lib/types/update-types.js'; +import { updateTypes } from 'lib/types/update-types-enum.js'; import { promiseAll } from 'lib/utils/promises.js'; import { getAPNsNotificationTopic } from './providers.js'; diff --git a/keyserver/src/scripts/merge-users.js b/keyserver/src/scripts/merge-users.js --- a/keyserver/src/scripts/merge-users.js +++ b/keyserver/src/scripts/merge-users.js @@ -2,7 +2,8 @@ import type { Shape } from 'lib/types/core.js'; import type { ServerThreadInfo } from 'lib/types/thread-types.js'; -import { type UpdateData, updateTypes } from 'lib/types/update-types.js'; +import { updateTypes } from 'lib/types/update-types-enum.js'; +import { type UpdateData } from 'lib/types/update-types.js'; import { endScript } from './utils.js'; import { createUpdates } from '../creators/update-creator.js'; diff --git a/keyserver/src/scripts/rename-user.js b/keyserver/src/scripts/rename-user.js --- a/keyserver/src/scripts/rename-user.js +++ b/keyserver/src/scripts/rename-user.js @@ -1,6 +1,6 @@ // @flow -import { updateTypes } from 'lib/types/update-types.js'; +import { updateTypes } from 'lib/types/update-types-enum.js'; import { main } from './utils.js'; import { createUpdates } from '../creators/update-creator.js'; diff --git a/keyserver/src/scripts/setup-sidebars.js b/keyserver/src/scripts/setup-sidebars.js --- a/keyserver/src/scripts/setup-sidebars.js +++ b/keyserver/src/scripts/setup-sidebars.js @@ -2,7 +2,7 @@ import { messageSpecs } from 'lib/shared/messages/message-specs.js'; import { messageTypes } from 'lib/types/message-types-enum.js'; -import { updateTypes } from 'lib/types/update-types.js'; +import { updateTypes } from 'lib/types/update-types-enum.js'; import { main } from './utils.js'; import { createUpdates } from '../creators/update-creator.js'; diff --git a/keyserver/src/updaters/account-updaters.js b/keyserver/src/updaters/account-updaters.js --- a/keyserver/src/updaters/account-updaters.js +++ b/keyserver/src/updaters/account-updaters.js @@ -15,7 +15,7 @@ UpdateUserAvatarRequest, UpdateUserAvatarResponse, } from 'lib/types/avatar-types.js'; -import { updateTypes } from 'lib/types/update-types.js'; +import { updateTypes } from 'lib/types/update-types-enum.js'; import type { CreateUpdatesResult, UpdateData, diff --git a/keyserver/src/updaters/activity-updaters.js b/keyserver/src/updaters/activity-updaters.js --- a/keyserver/src/updaters/activity-updaters.js +++ b/keyserver/src/updaters/activity-updaters.js @@ -13,7 +13,7 @@ } from 'lib/types/activity-types.js'; import { messageTypes } from 'lib/types/message-types-enum.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; -import { updateTypes } from 'lib/types/update-types.js'; +import { updateTypes } from 'lib/types/update-types-enum.js'; import { ServerError } from 'lib/utils/errors.js'; import { createUpdates } from '../creators/update-creator.js'; diff --git a/keyserver/src/updaters/entry-updaters.js b/keyserver/src/updaters/entry-updaters.js --- a/keyserver/src/updaters/entry-updaters.js +++ b/keyserver/src/updaters/entry-updaters.js @@ -16,10 +16,8 @@ } from 'lib/types/entry-types.js'; import { messageTypes } from 'lib/types/message-types-enum.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; -import { - updateTypes, - type ServerCreateUpdatesResponse, -} from 'lib/types/update-types.js'; +import { updateTypes } from 'lib/types/update-types-enum.js'; +import { type ServerCreateUpdatesResponse } from 'lib/types/update-types.js'; import { dateString } from 'lib/utils/date-utils.js'; import { ServerError } from 'lib/utils/errors.js'; import { values } from 'lib/utils/objects.js'; diff --git a/keyserver/src/updaters/relationship-updaters.js b/keyserver/src/updaters/relationship-updaters.js --- a/keyserver/src/updaters/relationship-updaters.js +++ b/keyserver/src/updaters/relationship-updaters.js @@ -13,7 +13,8 @@ directedStatus, } from 'lib/types/relationship-types.js'; import { threadTypes } from 'lib/types/thread-types-enum.js'; -import { updateTypes, type UpdateData } from 'lib/types/update-types.js'; +import { updateTypes } from 'lib/types/update-types-enum.js'; +import { type UpdateData } from 'lib/types/update-types.js'; import { cartesianProduct } from 'lib/utils/array.js'; import { ServerError } from 'lib/utils/errors.js'; import { promiseAll } from 'lib/utils/promises.js'; diff --git a/keyserver/src/updaters/thread-permission-updaters.js b/keyserver/src/updaters/thread-permission-updaters.js --- a/keyserver/src/updaters/thread-permission-updaters.js +++ b/keyserver/src/updaters/thread-permission-updaters.js @@ -19,8 +19,8 @@ type ThreadType, assertThreadType, } from 'lib/types/thread-types-enum.js'; +import { updateTypes } from 'lib/types/update-types-enum.js'; import { - updateTypes, type ServerUpdateInfo, type CreateUpdatesResult, } from 'lib/types/update-types.js'; diff --git a/keyserver/src/updaters/thread-updaters.js b/keyserver/src/updaters/thread-updaters.js --- a/keyserver/src/updaters/thread-updaters.js +++ b/keyserver/src/updaters/thread-updaters.js @@ -28,7 +28,7 @@ type ToggleMessagePinRequest, type ToggleMessagePinResult, } from 'lib/types/thread-types.js'; -import { updateTypes } from 'lib/types/update-types.js'; +import { updateTypes } from 'lib/types/update-types-enum.js'; import { ServerError } from 'lib/utils/errors.js'; import { promiseAll } from 'lib/utils/promises.js'; import { firstLine } from 'lib/utils/string-utils.js'; diff --git a/keyserver/src/updaters/user-subscription-updaters.js b/keyserver/src/updaters/user-subscription-updaters.js --- a/keyserver/src/updaters/user-subscription-updaters.js +++ b/keyserver/src/updaters/user-subscription-updaters.js @@ -5,7 +5,7 @@ ThreadSubscription, SubscriptionUpdateRequest, } from 'lib/types/subscription-types.js'; -import { updateTypes } from 'lib/types/update-types.js'; +import { updateTypes } from 'lib/types/update-types-enum.js'; import { ServerError } from 'lib/utils/errors.js'; import { createUpdates } from '../creators/update-creator.js'; diff --git a/lib/reducers/calendar-filters-reducer.js b/lib/reducers/calendar-filters-reducer.js --- a/lib/reducers/calendar-filters-reducer.js +++ b/lib/reducers/calendar-filters-reducer.js @@ -33,8 +33,8 @@ incrementalStateSyncActionType, } from '../types/socket-types.js'; import type { RawThreadInfo } from '../types/thread-types.js'; +import { updateTypes } from '../types/update-types-enum.js'; import { - updateTypes, type ClientUpdateInfo, processUpdatesActionType, } from '../types/update-types.js'; diff --git a/lib/reducers/device-token-reducer.js b/lib/reducers/device-token-reducer.js --- a/lib/reducers/device-token-reducer.js +++ b/lib/reducers/device-token-reducer.js @@ -3,7 +3,7 @@ import { setDeviceTokenActionTypes } from '../actions/device-actions.js'; import type { BaseAction } from '../types/redux-types'; import { incrementalStateSyncActionType } from '../types/socket-types.js'; -import { updateTypes } from '../types/update-types.js'; +import { updateTypes } from '../types/update-types-enum.js'; function reduceDeviceToken(state: ?string, action: BaseAction): ?string { if (action.type === setDeviceTokenActionTypes.success) { diff --git a/lib/reducers/entry-reducer.js b/lib/reducers/entry-reducer.js --- a/lib/reducers/entry-reducer.js +++ b/lib/reducers/entry-reducer.js @@ -64,8 +64,8 @@ incrementalStateSyncActionType, } from '../types/socket-types.js'; import { type RawThreadInfo } from '../types/thread-types.js'; +import { updateTypes } from '../types/update-types-enum.js'; import { - updateTypes, type ClientUpdateInfo, processUpdatesActionType, } from '../types/update-types.js'; diff --git a/lib/reducers/local-id-reducer.js b/lib/reducers/local-id-reducer.js --- a/lib/reducers/local-id-reducer.js +++ b/lib/reducers/local-id-reducer.js @@ -24,8 +24,8 @@ fullStateSyncActionType, incrementalStateSyncActionType, } from '../types/socket-types.js'; +import { updateTypes } from '../types/update-types-enum.js'; import { - updateTypes, type ClientUpdateInfo, processUpdatesActionType, } from '../types/update-types.js'; diff --git a/lib/reducers/message-reducer.js b/lib/reducers/message-reducer.js --- a/lib/reducers/message-reducer.js +++ b/lib/reducers/message-reducer.js @@ -92,8 +92,8 @@ } from '../types/socket-types.js'; import { threadPermissions } from '../types/thread-permission-types.js'; import { type RawThreadInfo } from '../types/thread-types.js'; +import { updateTypes } from '../types/update-types-enum.js'; import { - updateTypes, type ClientUpdateInfo, processUpdatesActionType, } from '../types/update-types.js'; diff --git a/lib/reducers/thread-reducer.js b/lib/reducers/thread-reducer.js --- a/lib/reducers/thread-reducer.js +++ b/lib/reducers/thread-reducer.js @@ -43,8 +43,8 @@ ThreadStore, ThreadStoreOperation, } from '../types/thread-types.js'; +import { updateTypes } from '../types/update-types-enum.js'; import { - updateTypes, type ClientUpdateInfo, processUpdatesActionType, } from '../types/update-types.js'; diff --git a/lib/reducers/user-reducer.js b/lib/reducers/user-reducer.js --- a/lib/reducers/user-reducer.js +++ b/lib/reducers/user-reducer.js @@ -29,10 +29,8 @@ fullStateSyncActionType, incrementalStateSyncActionType, } from '../types/socket-types.js'; -import { - updateTypes, - processUpdatesActionType, -} from '../types/update-types.js'; +import { updateTypes } from '../types/update-types-enum.js'; +import { processUpdatesActionType } from '../types/update-types.js'; import type { CurrentUserInfo, UserStore, diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js --- a/lib/shared/thread-utils.js +++ b/lib/shared/thread-utils.js @@ -76,7 +76,8 @@ type NewThreadResult, type ChangeThreadSettingsPayload, } from '../types/thread-types.js'; -import { type ClientUpdateInfo, updateTypes } from '../types/update-types.js'; +import { updateTypes } from '../types/update-types-enum.js'; +import { type ClientUpdateInfo } from '../types/update-types.js'; import type { GlobalAccountUserInfo, UserInfos, diff --git a/lib/shared/update-utils.js b/lib/shared/update-utils.js --- a/lib/shared/update-utils.js +++ b/lib/shared/update-utils.js @@ -3,11 +3,11 @@ import invariant from 'invariant'; import _maxBy from 'lodash/fp/maxBy.js'; +import { updateTypes } from '../types/update-types-enum.js'; import { type ServerUpdateInfo, type UpdateData, type RawUpdateInfo, - updateTypes, } from '../types/update-types.js'; function mostRecentUpdateTimestamp( diff --git a/lib/types/update-types-enum.js b/lib/types/update-types-enum.js new file mode 100644 --- /dev/null +++ b/lib/types/update-types-enum.js @@ -0,0 +1,31 @@ +// @flow + +import invariant from 'invariant'; + +export const updateTypes = Object.freeze({ + DELETE_ACCOUNT: 0, + UPDATE_THREAD: 1, + UPDATE_THREAD_READ_STATUS: 2, + DELETE_THREAD: 3, + JOIN_THREAD: 4, + BAD_DEVICE_TOKEN: 5, + UPDATE_ENTRY: 6, + UPDATE_CURRENT_USER: 7, + UPDATE_USER: 8, +}); +export type UpdateType = $Values; +export function assertUpdateType(ourUpdateType: number): UpdateType { + invariant( + ourUpdateType === 0 || + ourUpdateType === 1 || + ourUpdateType === 2 || + ourUpdateType === 3 || + ourUpdateType === 4 || + ourUpdateType === 5 || + ourUpdateType === 6 || + ourUpdateType === 7 || + ourUpdateType === 8, + 'number is not UpdateType enum', + ); + return ourUpdateType; +} diff --git a/lib/types/update-types.js b/lib/types/update-types.js --- a/lib/types/update-types.js +++ b/lib/types/update-types.js @@ -1,6 +1,5 @@ // @flow -import invariant from 'invariant'; import t, { type TUnion, type TInterface } from 'tcomb'; import { type RawEntryInfo, rawEntryInfoValidator } from './entry-types.js'; @@ -11,6 +10,7 @@ messageTruncationStatusValidator, } from './message-types.js'; import { type RawThreadInfo, rawThreadInfoValidator } from './thread-types.js'; +import { updateTypes } from './update-types-enum.js'; import { type UserInfo, userInfoValidator, @@ -23,34 +23,6 @@ } from './user-types.js'; import { tNumber, tShape, tID } from '../utils/validation-utils.js'; -export const updateTypes = Object.freeze({ - DELETE_ACCOUNT: 0, - UPDATE_THREAD: 1, - UPDATE_THREAD_READ_STATUS: 2, - DELETE_THREAD: 3, - JOIN_THREAD: 4, - BAD_DEVICE_TOKEN: 5, - UPDATE_ENTRY: 6, - UPDATE_CURRENT_USER: 7, - UPDATE_USER: 8, -}); -export type UpdateType = $Values; -export function assertUpdateType(ourUpdateType: number): UpdateType { - invariant( - ourUpdateType === 0 || - ourUpdateType === 1 || - ourUpdateType === 2 || - ourUpdateType === 3 || - ourUpdateType === 4 || - ourUpdateType === 5 || - ourUpdateType === 6 || - ourUpdateType === 7 || - ourUpdateType === 8, - 'number is not UpdateType enum', - ); - return ourUpdateType; -} - type AccountDeletionData = { +deletedUserID: string, }; diff --git a/lib/types/validation.test.js b/lib/types/validation.test.js --- a/lib/types/validation.test.js +++ b/lib/types/validation.test.js @@ -23,8 +23,8 @@ } from './socket-types.js'; import { threadTypes } from './thread-types-enum.js'; import { rawThreadInfoValidator } from './thread-types.js'; +import { updateTypes } from './update-types-enum.js'; import { - updateTypes, accountDeletionUpdateInfoValidator, badDeviceTokenUpdateInfoValidator, entryUpdateInfoValidator,