diff --git a/keyserver/src/endpoints.js b/keyserver/src/endpoints.js --- a/keyserver/src/endpoints.js +++ b/keyserver/src/endpoints.js @@ -19,6 +19,11 @@ deltaEntryInfosResultValidator, restoreEntryResponseValidator, } from 'lib/types/validators/entry-validators.js'; +import { createOrUpdateFarcasterChannelTagResponseValidator } from 'lib/types/validators/farcaster-channel-tag-validators.js'; +import { + fetchInviteLinksResponseValidator, + inviteLinkVerificationResponseValidator, +} from 'lib/types/validators/link-validators.js'; import { updateUserAvatarRequestValidator } from 'lib/utils/avatar-utils.js'; import { @@ -52,7 +57,6 @@ deleteFarcasterChannelTagResponder, createOrUpdateFarcasterChannelTagInputValidator, deleteFarcasterChannelTagInputValidator, - createOrUpdateFarcasterChannelTagResponseValidator, } from './responders/farcaster-channel-tag-responders.js'; import type { JSONResponder } from './responders/handlers.js'; import { createJSONResponder } from './responders/handlers.js'; @@ -64,9 +68,7 @@ inviteLinkVerificationResponder, createOrUpdatePublicLinkInputValidator, disableInviteLinkInputValidator, - fetchInviteLinksResponseValidator, inviteLinkVerificationRequestInputValidator, - inviteLinkVerificationResponseValidator, } from './responders/link-responders.js'; import { messageReportCreationResponder, diff --git a/keyserver/src/responders/farcaster-channel-tag-responders.js b/keyserver/src/responders/farcaster-channel-tag-responders.js --- a/keyserver/src/responders/farcaster-channel-tag-responders.js +++ b/keyserver/src/responders/farcaster-channel-tag-responders.js @@ -19,12 +19,6 @@ farcasterChannelID: t.String, }); -const createOrUpdateFarcasterChannelTagResponseValidator: TInterface = - tShape({ - commCommunityID: tID, - blobHolder: t.String, - }); - async function createOrUpdateFarcasterChannelTagResponder( viewer: Viewer, request: CreateOrUpdateFarcasterChannelTagRequest, @@ -49,7 +43,6 @@ export { createOrUpdateFarcasterChannelTagResponder, createOrUpdateFarcasterChannelTagInputValidator, - createOrUpdateFarcasterChannelTagResponseValidator, deleteFarcasterChannelTagResponder, deleteFarcasterChannelTagInputValidator, }; diff --git a/keyserver/src/responders/link-responders.js b/keyserver/src/responders/link-responders.js --- a/keyserver/src/responders/link-responders.js +++ b/keyserver/src/responders/link-responders.js @@ -1,13 +1,12 @@ // @flow -import t, { type TUnion, type TInterface } from 'tcomb'; +import t, { type TInterface } from 'tcomb'; import { type InviteLinkVerificationRequest, type InviteLinkVerificationResponse, type FetchInviteLinksResponse, type InviteLink, - inviteLinkValidator, type CreateOrUpdatePublicLinkRequest, type DisableInviteLinkRequest, type InviteLinkWithHolder, @@ -27,20 +26,6 @@ secret: t.String, }); -export const inviteLinkVerificationResponseValidator: TUnion = - t.union([ - tShape({ - status: t.enums.of(['valid', 'already_joined']), - community: tShape({ - name: t.String, - id: tID, - }), - }), - tShape({ - status: t.enums.of(['invalid', 'expired']), - }), - ]); - async function inviteLinkVerificationResponder( viewer: Viewer, request: InviteLinkVerificationRequest, @@ -48,11 +33,6 @@ return await verifyInviteLink(viewer, request); } -export const fetchInviteLinksResponseValidator: TInterface = - tShape({ - links: t.list(inviteLinkValidator), - }); - async function fetchPrimaryInviteLinksResponder( viewer: Viewer, ): Promise { diff --git a/keyserver/src/responders/responder-validators.test.js b/keyserver/src/responders/responder-validators.test.js --- a/keyserver/src/responders/responder-validators.test.js +++ b/keyserver/src/responders/responder-validators.test.js @@ -12,11 +12,11 @@ deltaEntryInfosResultValidator, restoreEntryResponseValidator, } from 'lib/types/validators/entry-validators.js'; - import { inviteLinkVerificationResponseValidator, fetchInviteLinksResponseValidator, -} from './link-responders.js'; +} from 'lib/types/validators/link-validators.js'; + import { messageReportCreationResultValidator } from './message-report-responder.js'; import { fetchMessageInfosResponseValidator, diff --git a/lib/types/validators/farcaster-channel-tag-validators.js b/lib/types/validators/farcaster-channel-tag-validators.js new file mode 100644 --- /dev/null +++ b/lib/types/validators/farcaster-channel-tag-validators.js @@ -0,0 +1,12 @@ +// @flow + +import t, { type TInterface } from 'tcomb'; + +import { tShape, tID } from '../../utils/validation-utils.js'; +import type { CreateOrUpdateFarcasterChannelTagResponse } from '../community-types'; + +export const createOrUpdateFarcasterChannelTagResponseValidator: TInterface = + tShape({ + commCommunityID: tID, + blobHolder: t.String, + }); diff --git a/lib/types/validators/link-validators.js b/lib/types/validators/link-validators.js new file mode 100644 --- /dev/null +++ b/lib/types/validators/link-validators.js @@ -0,0 +1,29 @@ +// @flow + +import t, { type TUnion, type TInterface } from 'tcomb'; + +import { tShape, tID } from '../../utils/validation-utils.js'; +import { + type InviteLinkVerificationResponse, + type FetchInviteLinksResponse, + inviteLinkValidator, +} from '../link-types.js'; + +export const fetchInviteLinksResponseValidator: TInterface = + tShape({ + links: t.list(inviteLinkValidator), + }); + +export const inviteLinkVerificationResponseValidator: TUnion = + t.union([ + tShape({ + status: t.enums.of(['valid', 'already_joined']), + community: tShape({ + name: t.String, + id: tID, + }), + }), + tShape({ + status: t.enums.of(['invalid', 'expired']), + }), + ]);