Changeset View
Changeset View
Standalone View
Standalone View
lib/types/link-types.js
// @flow | // @flow | ||||
import t, { type TInterface } from 'tcomb'; | |||||
import { tID, tShape } from '../utils/validation-utils.js'; | |||||
export type InviteLinkVerificationRequest = { | export type InviteLinkVerificationRequest = { | ||||
+secret: string, | +secret: string, | ||||
}; | }; | ||||
export type InviteLinkVerificationResponse = | export type InviteLinkVerificationResponse = | ||||
| { | | { | ||||
+status: 'valid' | 'already_joined', | +status: 'valid' | 'already_joined', | ||||
+community: { | +community: { | ||||
Show All 10 Lines | export type InviteLink = { | ||||
+primary: boolean, | +primary: boolean, | ||||
+role: string, | +role: string, | ||||
+communityID: string, | +communityID: string, | ||||
+expirationTime: ?number, | +expirationTime: ?number, | ||||
+limitOfUses: ?number, | +limitOfUses: ?number, | ||||
+numberOfUses: number, | +numberOfUses: number, | ||||
}; | }; | ||||
export const inviteLinkValidator: TInterface<InviteLink> = tShape<InviteLink>({ | |||||
name: t.String, | |||||
primary: t.Boolean, | |||||
role: tID, | |||||
communityID: tID, | |||||
expirationTime: t.maybe(t.Number), | |||||
limitOfUses: t.maybe(t.Number), | |||||
numberOfUses: t.Number, | |||||
}); | |||||
export type FetchInviteLinksResponse = { | export type FetchInviteLinksResponse = { | ||||
+links: $ReadOnlyArray<InviteLink>, | +links: $ReadOnlyArray<InviteLink>, | ||||
}; | }; | ||||
export type CommunityLinks = { | export type CommunityLinks = { | ||||
+primaryLink: ?InviteLink, | +primaryLink: ?InviteLink, | ||||
}; | }; | ||||
export type InviteLinksStore = { | export type InviteLinksStore = { | ||||
+links: { | +links: { | ||||
+[communityID: string]: CommunityLinks, | +[communityID: string]: CommunityLinks, | ||||
}, | }, | ||||
}; | }; | ||||
export type CreateOrUpdatePublicLinkRequest = { | |||||
+name: string, | |||||
+communityID: string, | |||||
}; |