diff --git a/lib/types/thread-permission-types.js b/lib/types/thread-permission-types.js --- a/lib/types/thread-permission-types.js +++ b/lib/types/thread-permission-types.js @@ -1,10 +1,10 @@ // @flow import invariant from 'invariant'; -import t, { type TDict } from 'tcomb'; +import t, { type TDict, type TUnion } from 'tcomb'; import { values } from '../utils/objects.js'; -import { tBool, tShape } from '../utils/validation-utils.js'; +import { tBool, tShape, tID } from '../utils/validation-utils.js'; export const threadPermissions = Object.freeze({ KNOW_OF: 'know_of', @@ -87,10 +87,11 @@ export type ThreadPermissionInfo = | { +value: true, +source: string } | { +value: false, +source: null }; -const threadPermissionInfoValidator = t.union([ - tShape({ value: tBool(true), source: t.String }), - tShape({ value: tBool(false), source: t.Nil }), -]); +export const threadPermissionInfoValidator: TUnion = + t.union([ + tShape({ value: tBool(true), source: tID }), + tShape({ value: tBool(false), source: t.Nil }), + ]); export type ThreadPermissionsBlob = { +[permission: string]: ThreadPermissionInfo, };