@ph-cms/client-sdk 0.1.45 → 0.1.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -891,6 +891,28 @@ function FollowButton({ userUid }: { userUid: string }) {
891
891
  }
892
892
  ```
893
893
 
894
+ ### Followers / Followings List
895
+
896
+ 특정 사용자의 팔로워 목록/팔로잉 목록을 페이지네이션으로 조회할 수 있습니다.
897
+
898
+ ```tsx
899
+ import { useFollowers, useFollowings } from '@ph-cms/client-sdk';
900
+
901
+ function FollowLists({ userUid }: { userUid: string }) {
902
+ const { data: followers, isLoading: isFollowersLoading } = useFollowers(userUid, { page: 1, limit: 20 });
903
+ const { data: followings, isLoading: isFollowingsLoading } = useFollowings(userUid, { page: 1, limit: 20 });
904
+
905
+ if (isFollowersLoading || isFollowingsLoading) return <div>Loading...</div>;
906
+
907
+ return (
908
+ <div>
909
+ <p>followers: {followers?.total ?? 0}</p>
910
+ <p>followings: {followings?.total ?? 0}</p>
911
+ </div>
912
+ );
913
+ }
914
+ ```
915
+
894
916
  ### `useLikedStats` (Liked Statistics)
895
917
 
896
918
  특정 사용자가 좋아요를 누른 콘텐츠의 타입별 통계를 조회합니다.
@@ -1316,6 +1338,20 @@ const unfollowResult = await client.user.unfollow('target-user-uid');
1316
1338
  // React Hook 사용
1317
1339
  const { mutate: unfollowUser } = useUnfollowUser();
1318
1340
  unfollowUser('target-user-uid');
1341
+
1342
+ // 4. 사용자 팔로워 목록 조회 (Public)
1343
+ const followers = await client.user.getFollowers('target-user-uid', { page: 1, limit: 20 });
1344
+ // => PagedUserProfileListResponse
1345
+
1346
+ // React Hook 사용
1347
+ const { data: followerList } = useFollowers('target-user-uid', { page: 1, limit: 20 });
1348
+
1349
+ // 5. 사용자 팔로잉 목록 조회 (Public)
1350
+ const followings = await client.user.getFollowings('target-user-uid', { page: 1, limit: 20 });
1351
+ // => PagedUserProfileListResponse
1352
+
1353
+ // React Hook 사용
1354
+ const { data: followingList } = useFollowings('target-user-uid', { page: 1, limit: 20 });
1319
1355
  ```
1320
1356
 
1321
1357
  ## Global Ban (글로벌 밴 - 관리자 전용)
@@ -1758,6 +1794,8 @@ const result = await content.list({ channelUid: 'my-channel' });
1758
1794
  | `getFollowStatus(uid: string)` | 현재 로그인 사용자의 대상 유저 팔로우 상태 조회 → `FollowStatusResponse` |
1759
1795
  | `follow(uid: string)` | 특정 사용자 팔로우 → `FollowUserResponse` |
1760
1796
  | `unfollow(uid: string)` | 특정 사용자 언팔로우 → `FollowUserResponse` |
1797
+ | `getFollowers(uid: string, params?: { page?: number; limit?: number })` | 특정 사용자의 팔로워 목록 조회 → `PagedUserProfileListResponse` |
1798
+ | `getFollowings(uid: string, params?: { page?: number; limit?: number })` | 특정 사용자의 팔로잉 목록 조회 → `PagedUserProfileListResponse` |
1761
1799
  | `updateProfile(uid: string, data: UpdateUserProfileRequest)` | 유저의 프로필 정보 업데이트 → `UserDto` |
1762
1800
  | `getLikedContents(uid: string, params?: Partial<ListLikedContentQuery>)` | 사용자가 좋아요 누른 콘텐츠 목록 조회 → `PagedContentListResponse` |
1763
1801
  | `getLikedStats(uid: string)` | 사용자가 좋아요 누른 콘텐츠 타입별 통계 조회 → `LikedStatsByTypeResponse` |
@@ -1,4 +1,4 @@
1
- import { ListLikedContentQuery, UpdateUserProfileRequest, BlockUserRequest, SuspendUserRequest } from '@ph-cms/api-contract';
1
+ import { ListLikedContentQuery, ListUserFollowQuery, UpdateUserProfileRequest, BlockUserRequest, SuspendUserRequest } from '@ph-cms/api-contract';
2
2
  export declare const termsKeys: {
3
3
  all: readonly ["terms"];
4
4
  lists: () => readonly ["terms", "list"];
@@ -7,6 +7,14 @@ export declare const userKeys: {
7
7
  all: readonly ["users"];
8
8
  profile: (uid: string) => readonly ["users", "profile", string];
9
9
  followStatus: (uid: string) => readonly ["users", "follow-status", string];
10
+ followers: (uid: string, params: Partial<ListUserFollowQuery>) => readonly ["users", "followers", string, Partial<{
11
+ page: number;
12
+ limit: number;
13
+ }>];
14
+ followings: (uid: string, params: Partial<ListUserFollowQuery>) => readonly ["users", "followings", string, Partial<{
15
+ page: number;
16
+ limit: number;
17
+ }>];
10
18
  };
11
19
  /**
12
20
  * Access the current user profile and status.
@@ -66,6 +74,40 @@ export declare const useUserProfile: (uid: string) => import("@tanstack/react-qu
66
74
  export declare const useFollowStatus: (uid: string, enabled?: boolean) => import("@tanstack/react-query").UseQueryResult<{
67
75
  is_following: boolean;
68
76
  }, Error>;
77
+ /**
78
+ * Hook to fetch followers of a target user.
79
+ */
80
+ export declare const useFollowers: (uid: string, params?: Partial<ListUserFollowQuery>, enabled?: boolean) => import("@tanstack/react-query").UseQueryResult<{
81
+ items: {
82
+ uid: string;
83
+ username: string | null;
84
+ display_name: string;
85
+ avatar_url: string | null;
86
+ follower_count: number;
87
+ profile_data: Record<string, any>;
88
+ }[];
89
+ total: number;
90
+ page: number;
91
+ limit: number;
92
+ totalPages: number;
93
+ }, Error>;
94
+ /**
95
+ * Hook to fetch followings of a target user.
96
+ */
97
+ export declare const useFollowings: (uid: string, params?: Partial<ListUserFollowQuery>, enabled?: boolean) => import("@tanstack/react-query").UseQueryResult<{
98
+ items: {
99
+ uid: string;
100
+ username: string | null;
101
+ display_name: string;
102
+ avatar_url: string | null;
103
+ follower_count: number;
104
+ profile_data: Record<string, any>;
105
+ }[];
106
+ total: number;
107
+ page: number;
108
+ limit: number;
109
+ totalPages: number;
110
+ }, Error>;
69
111
  /**
70
112
  * Hook to update a user's profile.
71
113
  * Typically used by a user to update their own profile.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useUnsuspendUser = exports.useSuspendUser = exports.useBlockedUsers = exports.useUnblockUser = exports.useBlockUser = exports.useAgreeTerms = exports.useChannelTerms = exports.useLikedStats = exports.useLikedContents = exports.useUnfollowUser = exports.useFollowUser = exports.useUpdateProfile = exports.useFollowStatus = exports.useUserProfile = exports.useUser = exports.userKeys = exports.termsKeys = void 0;
3
+ exports.useUnsuspendUser = exports.useSuspendUser = exports.useBlockedUsers = exports.useUnblockUser = exports.useBlockUser = exports.useAgreeTerms = exports.useChannelTerms = exports.useLikedStats = exports.useLikedContents = exports.useUnfollowUser = exports.useFollowUser = exports.useUpdateProfile = exports.useFollowings = exports.useFollowers = exports.useFollowStatus = exports.useUserProfile = exports.useUser = exports.userKeys = exports.termsKeys = void 0;
4
4
  const react_query_1 = require("@tanstack/react-query");
5
5
  const context_1 = require("../context");
6
6
  exports.termsKeys = {
@@ -11,6 +11,8 @@ exports.userKeys = {
11
11
  all: ['users'],
12
12
  profile: (uid) => [...exports.userKeys.all, 'profile', uid],
13
13
  followStatus: (uid) => [...exports.userKeys.all, 'follow-status', uid],
14
+ followers: (uid, params) => [...exports.userKeys.all, 'followers', uid, params],
15
+ followings: (uid, params) => [...exports.userKeys.all, 'followings', uid, params],
14
16
  };
15
17
  /**
16
18
  * Access the current user profile and status.
@@ -44,6 +46,30 @@ const useFollowStatus = (uid, enabled = true) => {
44
46
  });
45
47
  };
46
48
  exports.useFollowStatus = useFollowStatus;
49
+ /**
50
+ * Hook to fetch followers of a target user.
51
+ */
52
+ const useFollowers = (uid, params = {}, enabled = true) => {
53
+ const client = (0, context_1.usePHCMS)();
54
+ return (0, react_query_1.useQuery)({
55
+ queryKey: exports.userKeys.followers(uid, params),
56
+ queryFn: () => client.user.getFollowers(uid, params),
57
+ enabled: !!uid && enabled,
58
+ });
59
+ };
60
+ exports.useFollowers = useFollowers;
61
+ /**
62
+ * Hook to fetch followings of a target user.
63
+ */
64
+ const useFollowings = (uid, params = {}, enabled = true) => {
65
+ const client = (0, context_1.usePHCMS)();
66
+ return (0, react_query_1.useQuery)({
67
+ queryKey: exports.userKeys.followings(uid, params),
68
+ queryFn: () => client.user.getFollowings(uid, params),
69
+ enabled: !!uid && enabled,
70
+ });
71
+ };
72
+ exports.useFollowings = useFollowings;
47
73
  /**
48
74
  * Hook to update a user's profile.
49
75
  * Typically used by a user to update their own profile.
@@ -1,4 +1,4 @@
1
- import { LikedStatsByTypeResponse, ListLikedContentQuery, PagedContentListResponse, UpdateUserProfileRequest, UserDto, UserProfileDto, FollowStatusResponse, FollowUserResponse, BlockUserRequest, BlockUserResponse, PagedBlockedUserListResponse, SuspendUserRequest, SuspendUserResponse } from "@ph-cms/api-contract";
1
+ import { LikedStatsByTypeResponse, ListLikedContentQuery, ListUserFollowQuery, PagedContentListResponse, PagedUserProfileListResponse, UpdateUserProfileRequest, UserDto, UserProfileDto, FollowStatusResponse, FollowUserResponse, BlockUserRequest, BlockUserResponse, PagedBlockedUserListResponse, SuspendUserRequest, SuspendUserResponse } from "@ph-cms/api-contract";
2
2
  import { AxiosInstance } from "axios";
3
3
  export declare class UserModule {
4
4
  private client;
@@ -28,6 +28,20 @@ export declare class UserModule {
28
28
  * @param uid - The UID of the target user.
29
29
  */
30
30
  unfollow(uid: string): Promise<FollowUserResponse>;
31
+ /**
32
+ * Retrieves followers of a user.
33
+ *
34
+ * @param uid - The UID of the target user.
35
+ * @param params - Paging parameters.
36
+ */
37
+ getFollowers(uid: string, params?: Partial<ListUserFollowQuery>): Promise<PagedUserProfileListResponse>;
38
+ /**
39
+ * Retrieves followings of a user.
40
+ *
41
+ * @param uid - The UID of the target user.
42
+ * @param params - Paging parameters.
43
+ */
44
+ getFollowings(uid: string, params?: Partial<ListUserFollowQuery>): Promise<PagedUserProfileListResponse>;
31
45
  /**
32
46
  * Updates a user's profile.
33
47
  *
@@ -46,6 +46,36 @@ class UserModule {
46
46
  throw new errors_1.ValidationError("UID is required", []);
47
47
  return this.client.delete(`${this.prefix}/users/${uid}/follow`);
48
48
  }
49
+ /**
50
+ * Retrieves followers of a user.
51
+ *
52
+ * @param uid - The UID of the target user.
53
+ * @param params - Paging parameters.
54
+ */
55
+ async getFollowers(uid, params = {}) {
56
+ if (!uid)
57
+ throw new errors_1.ValidationError("UID is required", []);
58
+ const validation = api_contract_1.ListUserFollowQuerySchema.safeParse(params);
59
+ if (!validation.success) {
60
+ throw new errors_1.ValidationError("Invalid followers list params", validation.error.errors);
61
+ }
62
+ return this.client.get(`${this.prefix}/users/${uid}/followers`, { params: validation.data });
63
+ }
64
+ /**
65
+ * Retrieves followings of a user.
66
+ *
67
+ * @param uid - The UID of the target user.
68
+ * @param params - Paging parameters.
69
+ */
70
+ async getFollowings(uid, params = {}) {
71
+ if (!uid)
72
+ throw new errors_1.ValidationError("UID is required", []);
73
+ const validation = api_contract_1.ListUserFollowQuerySchema.safeParse(params);
74
+ if (!validation.success) {
75
+ throw new errors_1.ValidationError("Invalid followings list params", validation.error.errors);
76
+ }
77
+ return this.client.get(`${this.prefix}/users/${uid}/followings`, { params: validation.data });
78
+ }
49
79
  /**
50
80
  * Updates a user's profile.
51
81
  *
package/dist/types.d.ts CHANGED
@@ -5,7 +5,7 @@ export type { AuthStatus, PHCMSContextType, PHCMSProviderProps } from './context
5
5
  export type { FirebaseAuthSyncProps, UseFirebaseAuthSyncOptions, UseFirebaseAuthSyncReturn } from './hooks/useFirebaseAuthSync';
6
6
  export type { StampAvailability, CheckStampAvailabilityParams } from './hooks/useStampTour';
7
7
  export type { AnonymousLoginRequest, AuthResponse, FirebaseExchangeRequest, FirebaseRegisterRequest, LoginRequest, RefreshTokenRequest, RegisterRequest, } from '@ph-cms/api-contract';
8
- export type { UserDto, UserProfileDto, FollowStatusResponse, FollowUserResponse, } from '@ph-cms/api-contract';
8
+ export type { UserDto, UserProfileDto, FollowStatusResponse, FollowUserResponse, ListUserFollowQuery, PagedUserProfileListResponse, } from '@ph-cms/api-contract';
9
9
  export type { ChannelDto, CheckHierarchyQuery } from '@ph-cms/api-contract';
10
10
  export type { ContentDto, ContentStatDto, ContentMediaDto, ContentStatus, CreateContentRequest, ListContentQuery, PagedContentListResponse, UpdateContentRequest, } from '@ph-cms/api-contract';
11
11
  export type { HierarchySetDto } from '@ph-cms/api-contract';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ph-cms/client-sdk",
3
- "version": "0.1.45",
3
+ "version": "0.1.46",
4
4
  "description": "Unified PH-CMS Client SDK (React + Core)",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "LICENSE"
31
31
  ],
32
32
  "dependencies": {
33
- "@ph-cms/api-contract": "^0.1.22",
33
+ "@ph-cms/api-contract": "^0.1.23",
34
34
  "@tanstack/react-query": "^5.0.0",
35
35
  "axios": "^1.6.0",
36
36
  "zod": "^3.22.4"