@ph-cms/client-sdk 0.1.37 → 0.1.38
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 +28 -1
- package/dist/hooks/useUser.d.ts +7 -0
- package/dist/hooks/useUser.js +13 -1
- package/dist/modules/user.d.ts +7 -1
- package/dist/modules/user.js +10 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @ph-cms/client-sdk 0.1.
|
|
1
|
+
# @ph-cms/client-sdk 0.1.38
|
|
2
2
|
|
|
3
3
|
PH-CMS 클라이언트 SDK — 브라우저 및 React 애플리케이션을 위한 통합 클라이언트.
|
|
4
4
|
|
|
@@ -807,6 +807,28 @@ function UserProfileCard({ userId }) {
|
|
|
807
807
|
</div>
|
|
808
808
|
);
|
|
809
809
|
}
|
|
810
|
+
|
|
811
|
+
### `useLikedStats` (Liked Statistics)
|
|
812
|
+
|
|
813
|
+
특정 사용자가 좋아요를 누른 콘텐츠의 타입별 통계를 조회합니다.
|
|
814
|
+
|
|
815
|
+
```tsx
|
|
816
|
+
import { useLikedStats } from '@ph-cms/client-sdk';
|
|
817
|
+
|
|
818
|
+
function UserLikedStats({ userUid }) {
|
|
819
|
+
const { data: stats, isLoading } = useLikedStats(userUid);
|
|
820
|
+
|
|
821
|
+
if (isLoading) return <div>Loading...</div>;
|
|
822
|
+
|
|
823
|
+
return (
|
|
824
|
+
<ul>
|
|
825
|
+
{stats?.map(item => (
|
|
826
|
+
<li key={item.type}>{item.type}: {item.count}</li>
|
|
827
|
+
))}
|
|
828
|
+
</ul>
|
|
829
|
+
);
|
|
830
|
+
}
|
|
831
|
+
```
|
|
810
832
|
```
|
|
811
833
|
|
|
812
834
|
### Profile Update (`useUpdateProfile`)
|
|
@@ -1123,6 +1145,10 @@ const likers = await client.content.getLikers('content-uid', { page: 1, limit: 1
|
|
|
1123
1145
|
// 2. 특정 사용자가 좋아요를 누른 콘텐츠 목록 (타입 필터링 지원)
|
|
1124
1146
|
const likedContents = await client.user.getLikedContents('user-uid', { type: 'post', page: 1 });
|
|
1125
1147
|
// => PagedContentListResponse
|
|
1148
|
+
|
|
1149
|
+
// 3. 특정 사용자가 좋아요를 누른 콘텐츠 타입별 통계
|
|
1150
|
+
const likedStats = await client.user.getLikedStats('user-uid');
|
|
1151
|
+
// => [{ type: 'post', count: 5 }, { type: 'place', count: 2 }]
|
|
1126
1152
|
```
|
|
1127
1153
|
|
|
1128
1154
|
## Stamp Tour
|
|
@@ -1540,6 +1566,7 @@ const result = await content.list({ channelUid: 'my-channel' });
|
|
|
1540
1566
|
| `getProfile(uid: string)` | 유저의 공개 프로필 정보 조회 → `UserProfileDto` |
|
|
1541
1567
|
| `updateProfile(uid: string, data: UpdateUserProfileRequest)` | 유저의 프로필 정보 업데이트 → `UserDto` |
|
|
1542
1568
|
| `getLikedContents(uid: string, params?: Partial<ListLikedContentQuery>)` | 사용자가 좋아요 누른 콘텐츠 목록 조회 → `PagedContentListResponse` |
|
|
1569
|
+
| `getLikedStats(uid: string)` | 사용자가 좋아요 누른 콘텐츠 타입별 통계 조회 → `LikedStatsByTypeResponse` |
|
|
1543
1570
|
|
|
1544
1571
|
### `AuthModule` (`client.auth`)
|
|
1545
1572
|
|
package/dist/hooks/useUser.d.ts
CHANGED
|
@@ -105,6 +105,13 @@ export declare const useLikedContents: (uid: string, params?: Partial<ListLikedC
|
|
|
105
105
|
last: boolean;
|
|
106
106
|
empty: boolean;
|
|
107
107
|
}, Error>;
|
|
108
|
+
/**
|
|
109
|
+
* Hook to fetch statistics of liked contents by type for a specific user.
|
|
110
|
+
*/
|
|
111
|
+
export declare const useLikedStats: (uid: string) => import("@tanstack/react-query").UseQueryResult<{
|
|
112
|
+
type: string;
|
|
113
|
+
count: number;
|
|
114
|
+
}[], Error>;
|
|
108
115
|
/**
|
|
109
116
|
* List terms required/available for the current channel.
|
|
110
117
|
*/
|
package/dist/hooks/useUser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useAgreeTerms = exports.useChannelTerms = exports.useLikedContents = exports.useUpdateProfile = exports.useUserProfile = exports.useUser = exports.termsKeys = void 0;
|
|
3
|
+
exports.useAgreeTerms = exports.useChannelTerms = exports.useLikedStats = exports.useLikedContents = exports.useUpdateProfile = exports.useUserProfile = exports.useUser = 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 = {
|
|
@@ -55,6 +55,18 @@ const useLikedContents = (uid, params = {}) => {
|
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
57
|
exports.useLikedContents = useLikedContents;
|
|
58
|
+
/**
|
|
59
|
+
* Hook to fetch statistics of liked contents by type for a specific user.
|
|
60
|
+
*/
|
|
61
|
+
const useLikedStats = (uid) => {
|
|
62
|
+
const client = (0, context_1.usePHCMS)();
|
|
63
|
+
return (0, react_query_1.useQuery)({
|
|
64
|
+
queryKey: ['user-liked-stats', uid],
|
|
65
|
+
queryFn: () => client.user.getLikedStats(uid),
|
|
66
|
+
enabled: !!uid,
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
exports.useLikedStats = useLikedStats;
|
|
58
70
|
/**
|
|
59
71
|
* List terms required/available for the current channel.
|
|
60
72
|
*/
|
package/dist/modules/user.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ListLikedContentQuery, PagedContentListResponse, UpdateUserProfileRequest, UserDto, UserProfileDto } from "@ph-cms/api-contract";
|
|
1
|
+
import { LikedStatsByTypeResponse, ListLikedContentQuery, PagedContentListResponse, UpdateUserProfileRequest, UserDto, UserProfileDto } from "@ph-cms/api-contract";
|
|
2
2
|
import { AxiosInstance } from "axios";
|
|
3
3
|
export declare class UserModule {
|
|
4
4
|
private client;
|
|
@@ -28,4 +28,10 @@ export declare class UserModule {
|
|
|
28
28
|
* @param params - Query parameters for filtering and pagination.
|
|
29
29
|
*/
|
|
30
30
|
getLikedContents(uid: string, params?: Partial<ListLikedContentQuery>): Promise<PagedContentListResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves statistics of liked contents by type for a specific user.
|
|
33
|
+
*
|
|
34
|
+
* @param uid - The UID of the user.
|
|
35
|
+
*/
|
|
36
|
+
getLikedStats(uid: string): Promise<LikedStatsByTypeResponse>;
|
|
31
37
|
}
|
package/dist/modules/user.js
CHANGED
|
@@ -44,5 +44,15 @@ class UserModule {
|
|
|
44
44
|
}
|
|
45
45
|
return this.client.get(`${this.prefix}/users/${uid}/liked-contents`, { params });
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves statistics of liked contents by type for a specific user.
|
|
49
|
+
*
|
|
50
|
+
* @param uid - The UID of the user.
|
|
51
|
+
*/
|
|
52
|
+
async getLikedStats(uid) {
|
|
53
|
+
if (!uid)
|
|
54
|
+
throw new errors_1.ValidationError("UID is required", []);
|
|
55
|
+
return this.client.get(`${this.prefix}/users/${uid}/liked-stats`);
|
|
56
|
+
}
|
|
47
57
|
}
|
|
48
58
|
exports.UserModule = UserModule;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ph-cms/client-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.38",
|
|
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.
|
|
33
|
+
"@ph-cms/api-contract": "^0.1.15",
|
|
34
34
|
"@tanstack/react-query": "^5.0.0",
|
|
35
35
|
"axios": "^1.6.0",
|
|
36
36
|
"zod": "^3.22.4"
|