Skip to content

Commit

Permalink
Update: add Usc Id to all community related ep
Browse files Browse the repository at this point in the history
  • Loading branch information
utkusarioglu committed Mar 2, 2021
1 parent e8610ad commit 4963bf1
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 9 deletions.
13 changes: 9 additions & 4 deletions src/endpoints/community.endpoint.types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {
CommunitySelect,
CommunityPostRes,
CommunitySaveReq,
WithCommunitySlug,
CommunityWithSubscriptionStatus,
CommunityForCommunityPost,
} from '../references/community.reference.types';
import { Get, Post } from '../helpers/endpoint.types';
import type { WithRequestId } from '../helpers/mixin.types';
Expand All @@ -12,20 +13,24 @@ export interface CommunityEndpoint {
_v1: Get<
'/community/:communitySlug/:requestId',
WithCommunitySlug & WithRequestId,
CommunitySelect
CommunityWithSubscriptionStatus
>;
};

_list: {
_v1: Get<'/communities/:requestId', WithRequestId, CommunitySelect[]>;
_v1: Get<
'/communities/:requestId',
WithRequestId,
CommunityWithSubscriptionStatus[]
>;
};

_community_post: {
_list: {
_v1: Get<
'/community/:communitySlug/post/:requestId',
WithCommunitySlug & WithRequestId,
CommunityPostRes[]
CommunityForCommunityPost[]
>;
};

Expand Down
47 changes: 42 additions & 5 deletions src/references/community.reference.types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { isoDate, uint, uuid } from '../helpers/alias.types';
import { DataNode } from '../helpers/data-node';
import { BuildSelect } from '../helpers/select.types';
import type { WithNullableUCSId } from './user-community-subscription.reference.types';

export type CommunityPipeline = {
_request: DataNode<{
Expand Down Expand Up @@ -52,15 +53,51 @@ export type CommunitySelect = BuildSelect<
export type CommunitySaveReq = CommunityPipeline['_request']['In'];

/**
* Properties send to the client when a post that is associated with a community
* is requested
* Action types a user can take against a community
*/
export type CommunityPostRes = CommunitySelect & WithCommunityId;
export type CommunityActionTypes = 'subscribe' | 'unsubscribe';

/**
* Action types a user can take against a community
* Includes ucsId, which is the subscription id for the community, if one
* exists
*/
export type CommunityActionTypes = 'subscribe' | 'unsubscribe';
export type CommunityWithSubscriptionStatus = BuildSelect<
CommunityPipeline,
| 'description'
| 'name'
| 'slug'
| 'id'
| 'created_at'
| 'post_count'
| 'subscriber_count',
WithNullableUCSId,
{
created_at: 'createdAt';
post_count: 'postCount';
subscriber_count: 'subscriberCount';
}
>['Select'];

/**
* Returns JS naming convention properties for posts of a single
* community. Does not include ucsId
*/
export type CommunityForCommunityPost = BuildSelect<
CommunityPipeline,
| 'description'
| 'name'
| 'slug'
| 'id'
| 'created_at'
| 'post_count'
| 'subscriber_count',
{},
{
created_at: 'createdAt';
post_count: 'postCount';
subscriber_count: 'subscriberCount';
}
>['Select'];

/**
* MIXINS
Expand Down
11 changes: 11 additions & 0 deletions src/references/user-community-subscription.reference.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,14 @@ export type UserCommunitySubscription_id_list_res = BuildSelect<
{},
{ community_id: 'communityId' }
>['Select']['communityId'][];

export type WithUCSId = BuildSelect<
UserCommunitySubscriptionPipeline,
'id',
{},
{ id: 'ucsId' }
>['Select'];

export type WithNullableUCSId = {
ucsId: WithUCSId['ucsId'] | null;
};

0 comments on commit 4963bf1

Please sign in to comment.