Changeset View
Changeset View
Standalone View
Standalone View
lib/types/subscription-types.js
// @flow | // @flow | ||||
import _mapValues from 'lodash/fp/mapValues.js'; | |||||
import t, { type TInterface } from 'tcomb'; | |||||
import type { Shape } from './core.js'; | import type { Shape } from './core.js'; | ||||
import { tShape } from '../utils/validation-utils.js'; | |||||
export const threadSubscriptions = Object.freeze({ | export const threadSubscriptions = Object.freeze({ | ||||
home: 'home', | home: 'home', | ||||
pushNotifs: 'pushNotifs', | pushNotifs: 'pushNotifs', | ||||
}); | }); | ||||
export type ThreadSubscription = $ObjMap< | export type ThreadSubscription = $ObjMap< | ||||
typeof threadSubscriptions, | typeof threadSubscriptions, | ||||
() => boolean, | () => boolean, | ||||
>; | >; | ||||
export const threadSubscriptionValidator: TInterface<ThreadSubscription> = | |||||
tShape<ThreadSubscription>(_mapValues(() => t.Boolean)(threadSubscriptions)); | |||||
export type SubscriptionUpdateRequest = { | export type SubscriptionUpdateRequest = { | ||||
threadID: string, | threadID: string, | ||||
updatedFields: Shape<ThreadSubscription>, | updatedFields: Shape<ThreadSubscription>, | ||||
}; | }; | ||||
export type SubscriptionUpdateResponse = { | export type SubscriptionUpdateResponse = { | ||||
threadSubscription: ThreadSubscription, | threadSubscription: ThreadSubscription, | ||||
}; | }; | ||||
export type SubscriptionUpdateResult = { | export type SubscriptionUpdateResult = { | ||||
threadID: string, | threadID: string, | ||||
subscription: ThreadSubscription, | subscription: ThreadSubscription, | ||||
}; | }; |