@ph-cms/client-sdk 0.1.37 → 0.1.42
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 +121 -1
- package/dist/hooks/useAuth.d.ts +14 -14
- package/dist/hooks/useContent.d.ts +7 -1
- package/dist/hooks/useContent.js +8 -1
- package/dist/hooks/useUser.d.ts +66 -3
- package/dist/hooks/useUser.js +67 -1
- package/dist/modules/content.d.ts +2 -1
- package/dist/modules/content.js +9 -0
- package/dist/modules/user.d.ts +45 -1
- package/dist/modules/user.js +69 -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.42
|
|
2
2
|
|
|
3
3
|
PH-CMS 클라이언트 SDK — 브라우저 및 React 애플리케이션을 위한 통합 클라이언트.
|
|
4
4
|
|
|
@@ -56,6 +56,12 @@ import type {
|
|
|
56
56
|
|
|
57
57
|
// User
|
|
58
58
|
UserDto,
|
|
59
|
+
BlockUserRequest,
|
|
60
|
+
BlockUserResponse,
|
|
61
|
+
BlockedUserDto,
|
|
62
|
+
PagedBlockedUserListResponse,
|
|
63
|
+
SuspendUserRequest,
|
|
64
|
+
SuspendUserResponse,
|
|
59
65
|
|
|
60
66
|
// Channel
|
|
61
67
|
ChannelDto,
|
|
@@ -72,6 +78,8 @@ import type {
|
|
|
72
78
|
ListLikersQuery,
|
|
73
79
|
ListLikedContentQuery,
|
|
74
80
|
PagedContentListResponse,
|
|
81
|
+
ReportContentRequest,
|
|
82
|
+
ReportContentResponse,
|
|
75
83
|
|
|
76
84
|
// Hierarchy / Policy
|
|
77
85
|
HierarchySetDto,
|
|
@@ -807,6 +815,28 @@ function UserProfileCard({ userId }) {
|
|
|
807
815
|
</div>
|
|
808
816
|
);
|
|
809
817
|
}
|
|
818
|
+
|
|
819
|
+
### `useLikedStats` (Liked Statistics)
|
|
820
|
+
|
|
821
|
+
특정 사용자가 좋아요를 누른 콘텐츠의 타입별 통계를 조회합니다.
|
|
822
|
+
|
|
823
|
+
```tsx
|
|
824
|
+
import { useLikedStats } from '@ph-cms/client-sdk';
|
|
825
|
+
|
|
826
|
+
function UserLikedStats({ userUid }) {
|
|
827
|
+
const { data: stats, isLoading } = useLikedStats(userUid);
|
|
828
|
+
|
|
829
|
+
if (isLoading) return <div>Loading...</div>;
|
|
830
|
+
|
|
831
|
+
return (
|
|
832
|
+
<ul>
|
|
833
|
+
{stats?.map(item => (
|
|
834
|
+
<li key={item.type}>{item.type}: {item.count}</li>
|
|
835
|
+
))}
|
|
836
|
+
</ul>
|
|
837
|
+
);
|
|
838
|
+
}
|
|
839
|
+
```
|
|
810
840
|
```
|
|
811
841
|
|
|
812
842
|
### Profile Update (`useUpdateProfile`)
|
|
@@ -1123,6 +1153,89 @@ const likers = await client.content.getLikers('content-uid', { page: 1, limit: 1
|
|
|
1123
1153
|
// 2. 특정 사용자가 좋아요를 누른 콘텐츠 목록 (타입 필터링 지원)
|
|
1124
1154
|
const likedContents = await client.user.getLikedContents('user-uid', { type: 'post', page: 1 });
|
|
1125
1155
|
// => PagedContentListResponse
|
|
1156
|
+
|
|
1157
|
+
// 3. 특정 사용자가 좋아요를 누른 콘텐츠 타입별 통계
|
|
1158
|
+
const likedStats = await client.user.getLikedStats('user-uid');
|
|
1159
|
+
// => [{ type: 'post', count: 5 }, { type: 'place', count: 2 }]
|
|
1160
|
+
```
|
|
1161
|
+
|
|
1162
|
+
## Content Report (콘텐츠 신고)
|
|
1163
|
+
|
|
1164
|
+
부적절한 콘텐츠를 신고할 수 있습니다. (인증 필수)
|
|
1165
|
+
|
|
1166
|
+
```ts
|
|
1167
|
+
// 모듈 직접 사용
|
|
1168
|
+
const result = await client.content.report('content-uid', {
|
|
1169
|
+
reason: 'SPAM',
|
|
1170
|
+
description: '이 콘텐츠는 스팸입니다.'
|
|
1171
|
+
});
|
|
1172
|
+
// => { message: 'Report submitted successfully' }
|
|
1173
|
+
|
|
1174
|
+
// React Hook 사용
|
|
1175
|
+
const { mutate: reportContent } = useReportContent();
|
|
1176
|
+
|
|
1177
|
+
reportContent({
|
|
1178
|
+
uid: 'content-uid',
|
|
1179
|
+
data: {
|
|
1180
|
+
reason: 'INAPPROPRIATE',
|
|
1181
|
+
description: '부적절한 내용이 포함되어 있습니다.'
|
|
1182
|
+
}
|
|
1183
|
+
});
|
|
1184
|
+
```
|
|
1185
|
+
|
|
1186
|
+
## User Block (사용자 차단)
|
|
1187
|
+
|
|
1188
|
+
특정 사용자를 차단하거나 차단 해제할 수 있습니다. (인증 필수)
|
|
1189
|
+
|
|
1190
|
+
```ts
|
|
1191
|
+
// 1. 사용자 차단
|
|
1192
|
+
const blockResult = await client.user.block('target-user-uid', {
|
|
1193
|
+
reason: '부적절한 언행'
|
|
1194
|
+
});
|
|
1195
|
+
// => { success: true, message: 'User blocked' }
|
|
1196
|
+
|
|
1197
|
+
// React Hook 사용
|
|
1198
|
+
const { mutate: blockUser } = useBlockUser();
|
|
1199
|
+
blockUser({ uid: 'target-user-uid', data: { reason: '사유' } });
|
|
1200
|
+
|
|
1201
|
+
// 2. 사용자 차단 해제
|
|
1202
|
+
const unblockResult = await client.user.unblock('target-user-uid');
|
|
1203
|
+
// => { success: true, message: 'User unblocked' }
|
|
1204
|
+
|
|
1205
|
+
// React Hook 사용
|
|
1206
|
+
const { mutate: unblockUser } = useUnblockUser();
|
|
1207
|
+
unblockUser('target-user-uid');
|
|
1208
|
+
|
|
1209
|
+
// 3. 차단한 사용자 목록 조회
|
|
1210
|
+
const blockedUsers = await client.user.getBlockedUsers('my-user-uid', { page: 1, limit: 10 });
|
|
1211
|
+
// => PagedBlockedUserListResponse
|
|
1212
|
+
|
|
1213
|
+
// React Hook 사용
|
|
1214
|
+
const { data: blockedList } = useBlockedUsers('my-user-uid', { page: 1 });
|
|
1215
|
+
```
|
|
1216
|
+
|
|
1217
|
+
## Global Ban (글로벌 밴 - 관리자 전용)
|
|
1218
|
+
|
|
1219
|
+
특정 사용자의 활동을 전역적으로 정지시키거나 해제할 수 있습니다. (관리자 권한 필수)
|
|
1220
|
+
|
|
1221
|
+
```ts
|
|
1222
|
+
// 1. 사용자 활동 정지 (Suspend)
|
|
1223
|
+
const suspendResult = await client.user.suspend('target-user-uid', {
|
|
1224
|
+
reason: '운영 정책 위반'
|
|
1225
|
+
});
|
|
1226
|
+
// => { success: true, message: 'User suspended' }
|
|
1227
|
+
|
|
1228
|
+
// React Hook 사용
|
|
1229
|
+
const { mutate: suspendUser } = useSuspendUser();
|
|
1230
|
+
suspendUser({ uid: 'target-user-uid', data: { reason: '사유' } });
|
|
1231
|
+
|
|
1232
|
+
// 2. 사용자 활동 정지 해제 (Unsuspend)
|
|
1233
|
+
const unsuspendResult = await client.user.unsuspend('target-user-uid');
|
|
1234
|
+
// => { success: true, message: 'User unsuspended' }
|
|
1235
|
+
|
|
1236
|
+
// React Hook 사용
|
|
1237
|
+
const { mutate: unsuspendUser } = useUnsuspendUser();
|
|
1238
|
+
unsuspendUser('target-user-uid');
|
|
1126
1239
|
```
|
|
1127
1240
|
|
|
1128
1241
|
## Stamp Tour
|
|
@@ -1540,6 +1653,12 @@ const result = await content.list({ channelUid: 'my-channel' });
|
|
|
1540
1653
|
| `getProfile(uid: string)` | 유저의 공개 프로필 정보 조회 → `UserProfileDto` |
|
|
1541
1654
|
| `updateProfile(uid: string, data: UpdateUserProfileRequest)` | 유저의 프로필 정보 업데이트 → `UserDto` |
|
|
1542
1655
|
| `getLikedContents(uid: string, params?: Partial<ListLikedContentQuery>)` | 사용자가 좋아요 누른 콘텐츠 목록 조회 → `PagedContentListResponse` |
|
|
1656
|
+
| `getLikedStats(uid: string)` | 사용자가 좋아요 누른 콘텐츠 타입별 통계 조회 → `LikedStatsByTypeResponse` |
|
|
1657
|
+
| `block(uid: string, data?: BlockUserRequest)` | 특정 사용자 차단 → `BlockUserResponse` |
|
|
1658
|
+
| `unblock(uid: string)` | 특정 사용자 차단 해제 → `BlockUserResponse` |
|
|
1659
|
+
| `getBlockedUsers(uid: string, params?: { page?: number; limit?: number })` | 차단한 사용자 목록 조회 → `PagedBlockedUserListResponse` |
|
|
1660
|
+
| `suspend(uid: string, data?: SuspendUserRequest)` | 유저 활동 정지 (글로벌 밴) → `SuspendUserResponse` |
|
|
1661
|
+
| `unsuspend(uid: string)` | 유저 활동 정지 해제 → `SuspendUserResponse` |
|
|
1543
1662
|
|
|
1544
1663
|
### `AuthModule` (`client.auth`)
|
|
1545
1664
|
|
|
@@ -1572,6 +1691,7 @@ const result = await content.list({ channelUid: 'my-channel' });
|
|
|
1572
1691
|
| `toggleLike(uid: string)` | 좋아요 토글 → `ToggleLikeResponse` |
|
|
1573
1692
|
| `getLikeStatus(uid: string)` | 내 좋아요 여부 확인 → `LikeStatusResponse` |
|
|
1574
1693
|
| `getLikers(uid: string, params?: Partial<ListLikersQuery>)` | 콘텐츠에 좋아요 누른 사용자 목록 조회 → `PagedResponse<UserProfileDto>` |
|
|
1694
|
+
| `report(uid: string, data: ReportContentRequest)` | 콘텐츠 신고 → `ReportContentResponse` |
|
|
1575
1695
|
|
|
1576
1696
|
### `ChannelModule` (`client.channel`)
|
|
1577
1697
|
|
package/dist/hooks/useAuth.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type RegisterInput = FirebaseRegisterInput | EmailRegisterInput;
|
|
|
17
17
|
*/
|
|
18
18
|
export declare const useAuth: () => {
|
|
19
19
|
user: {
|
|
20
|
-
status:
|
|
20
|
+
status: "active" | "inactive" | "suspended" | "pending";
|
|
21
21
|
uid: string;
|
|
22
22
|
email: string;
|
|
23
23
|
username: string | null;
|
|
@@ -53,7 +53,7 @@ export declare const useAuth: () => {
|
|
|
53
53
|
login: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
54
54
|
refreshToken: string;
|
|
55
55
|
user: {
|
|
56
|
-
status:
|
|
56
|
+
status: "active" | "inactive" | "suspended" | "pending";
|
|
57
57
|
uid: string;
|
|
58
58
|
email: string;
|
|
59
59
|
username: string | null;
|
|
@@ -92,7 +92,7 @@ export declare const useAuth: () => {
|
|
|
92
92
|
loginWithFirebase: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
93
93
|
refreshToken: string;
|
|
94
94
|
user: {
|
|
95
|
-
status:
|
|
95
|
+
status: "active" | "inactive" | "suspended" | "pending";
|
|
96
96
|
uid: string;
|
|
97
97
|
email: string;
|
|
98
98
|
username: string | null;
|
|
@@ -131,7 +131,7 @@ export declare const useAuth: () => {
|
|
|
131
131
|
register: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
132
132
|
refreshToken: string;
|
|
133
133
|
user: {
|
|
134
|
-
status:
|
|
134
|
+
status: "active" | "inactive" | "suspended" | "pending";
|
|
135
135
|
uid: string;
|
|
136
136
|
email: string;
|
|
137
137
|
username: string | null;
|
|
@@ -167,7 +167,7 @@ export declare const useAuth: () => {
|
|
|
167
167
|
loginAnonymous: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
168
168
|
refreshToken: string;
|
|
169
169
|
user: {
|
|
170
|
-
status:
|
|
170
|
+
status: "active" | "inactive" | "suspended" | "pending";
|
|
171
171
|
uid: string;
|
|
172
172
|
email: string;
|
|
173
173
|
username: string | null;
|
|
@@ -203,7 +203,7 @@ export declare const useAuth: () => {
|
|
|
203
203
|
channelUid?: string;
|
|
204
204
|
} | undefined, unknown>;
|
|
205
205
|
upgradeAnonymous: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
206
|
-
status:
|
|
206
|
+
status: "active" | "inactive" | "suspended" | "pending";
|
|
207
207
|
uid: string;
|
|
208
208
|
email: string;
|
|
209
209
|
username: string | null;
|
|
@@ -245,7 +245,7 @@ export declare const useAuth: () => {
|
|
|
245
245
|
loginStatus: import("@tanstack/react-query").UseMutationResult<{
|
|
246
246
|
refreshToken: string;
|
|
247
247
|
user: {
|
|
248
|
-
status:
|
|
248
|
+
status: "active" | "inactive" | "suspended" | "pending";
|
|
249
249
|
uid: string;
|
|
250
250
|
email: string;
|
|
251
251
|
username: string | null;
|
|
@@ -284,7 +284,7 @@ export declare const useAuth: () => {
|
|
|
284
284
|
loginWithFirebaseStatus: import("@tanstack/react-query").UseMutationResult<{
|
|
285
285
|
refreshToken: string;
|
|
286
286
|
user: {
|
|
287
|
-
status:
|
|
287
|
+
status: "active" | "inactive" | "suspended" | "pending";
|
|
288
288
|
uid: string;
|
|
289
289
|
email: string;
|
|
290
290
|
username: string | null;
|
|
@@ -323,7 +323,7 @@ export declare const useAuth: () => {
|
|
|
323
323
|
registerStatus: import("@tanstack/react-query").UseMutationResult<{
|
|
324
324
|
refreshToken: string;
|
|
325
325
|
user: {
|
|
326
|
-
status:
|
|
326
|
+
status: "active" | "inactive" | "suspended" | "pending";
|
|
327
327
|
uid: string;
|
|
328
328
|
email: string;
|
|
329
329
|
username: string | null;
|
|
@@ -359,7 +359,7 @@ export declare const useAuth: () => {
|
|
|
359
359
|
loginAnonymousStatus: import("@tanstack/react-query").UseMutationResult<{
|
|
360
360
|
refreshToken: string;
|
|
361
361
|
user: {
|
|
362
|
-
status:
|
|
362
|
+
status: "active" | "inactive" | "suspended" | "pending";
|
|
363
363
|
uid: string;
|
|
364
364
|
email: string;
|
|
365
365
|
username: string | null;
|
|
@@ -395,7 +395,7 @@ export declare const useAuth: () => {
|
|
|
395
395
|
channelUid?: string;
|
|
396
396
|
} | undefined, unknown>;
|
|
397
397
|
upgradeAnonymousStatus: import("@tanstack/react-query").UseMutationResult<{
|
|
398
|
-
status:
|
|
398
|
+
status: "active" | "inactive" | "suspended" | "pending";
|
|
399
399
|
uid: string;
|
|
400
400
|
email: string;
|
|
401
401
|
username: string | null;
|
|
@@ -437,7 +437,7 @@ export declare const useAuth: () => {
|
|
|
437
437
|
export declare const useLogin: () => import("@tanstack/react-query").UseMutationResult<{
|
|
438
438
|
refreshToken: string;
|
|
439
439
|
user: {
|
|
440
|
-
status:
|
|
440
|
+
status: "active" | "inactive" | "suspended" | "pending";
|
|
441
441
|
uid: string;
|
|
442
442
|
email: string;
|
|
443
443
|
username: string | null;
|
|
@@ -477,7 +477,7 @@ export declare const useLogout: () => import("@tanstack/react-query").UseMutatio
|
|
|
477
477
|
export declare const useLoginAnonymous: () => import("@tanstack/react-query").UseMutationResult<{
|
|
478
478
|
refreshToken: string;
|
|
479
479
|
user: {
|
|
480
|
-
status:
|
|
480
|
+
status: "active" | "inactive" | "suspended" | "pending";
|
|
481
481
|
uid: string;
|
|
482
482
|
email: string;
|
|
483
483
|
username: string | null;
|
|
@@ -513,7 +513,7 @@ export declare const useLoginAnonymous: () => import("@tanstack/react-query").Us
|
|
|
513
513
|
channelUid?: string;
|
|
514
514
|
} | undefined, unknown>;
|
|
515
515
|
export declare const useUpgradeAnonymous: () => import("@tanstack/react-query").UseMutationResult<{
|
|
516
|
-
status:
|
|
516
|
+
status: "active" | "inactive" | "suspended" | "pending";
|
|
517
517
|
uid: string;
|
|
518
518
|
email: string;
|
|
519
519
|
username: string | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UpdateContentRequest, ListContentQuery, ContentDto } from '@ph-cms/api-contract';
|
|
1
|
+
import { UpdateContentRequest, ListContentQuery, ContentDto, ReportContentRequest } from '@ph-cms/api-contract';
|
|
2
2
|
export declare const contentKeys: {
|
|
3
3
|
all: readonly ["contents"];
|
|
4
4
|
lists: () => readonly ["contents", "list"];
|
|
@@ -82,3 +82,9 @@ export declare const useUpdateContent: () => import("@tanstack/react-query").Use
|
|
|
82
82
|
data: UpdateContentRequest;
|
|
83
83
|
}, unknown>;
|
|
84
84
|
export declare const useDeleteContent: () => import("@tanstack/react-query").UseMutationResult<void, Error, string, unknown>;
|
|
85
|
+
export declare const useReportContent: () => import("@tanstack/react-query").UseMutationResult<{
|
|
86
|
+
message: string;
|
|
87
|
+
}, Error, {
|
|
88
|
+
uid: string;
|
|
89
|
+
data: ReportContentRequest;
|
|
90
|
+
}, unknown>;
|
package/dist/hooks/useContent.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useDeleteContent = exports.useUpdateContent = exports.useToggleLike = exports.useLikeStatus = exports.useCreateContent = exports.useIncrementView = exports.useContentDetail = exports.useContentList = exports.contentKeys = void 0;
|
|
3
|
+
exports.useReportContent = exports.useDeleteContent = exports.useUpdateContent = exports.useToggleLike = exports.useLikeStatus = exports.useCreateContent = exports.useIncrementView = exports.useContentDetail = exports.useContentList = exports.contentKeys = void 0;
|
|
4
4
|
const react_query_1 = require("@tanstack/react-query");
|
|
5
5
|
const context_1 = require("../context");
|
|
6
6
|
exports.contentKeys = {
|
|
@@ -177,3 +177,10 @@ const useDeleteContent = () => {
|
|
|
177
177
|
});
|
|
178
178
|
};
|
|
179
179
|
exports.useDeleteContent = useDeleteContent;
|
|
180
|
+
const useReportContent = () => {
|
|
181
|
+
const client = (0, context_1.usePHCMS)();
|
|
182
|
+
return (0, react_query_1.useMutation)({
|
|
183
|
+
mutationFn: ({ uid, data }) => client.content.report(uid, data),
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
exports.useReportContent = useReportContent;
|
package/dist/hooks/useUser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ListLikedContentQuery, UpdateUserProfileRequest } from '@ph-cms/api-contract';
|
|
1
|
+
import { ListLikedContentQuery, 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"];
|
|
@@ -8,7 +8,7 @@ export declare const termsKeys: {
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const useUser: () => {
|
|
10
10
|
data: {
|
|
11
|
-
status:
|
|
11
|
+
status: "active" | "inactive" | "suspended" | "pending";
|
|
12
12
|
uid: string;
|
|
13
13
|
email: string;
|
|
14
14
|
username: string | null;
|
|
@@ -58,7 +58,7 @@ export declare const useUserProfile: (uid: string) => import("@tanstack/react-qu
|
|
|
58
58
|
* Typically used by a user to update their own profile.
|
|
59
59
|
*/
|
|
60
60
|
export declare const useUpdateProfile: () => import("@tanstack/react-query").UseMutationResult<{
|
|
61
|
-
status:
|
|
61
|
+
status: "active" | "inactive" | "suspended" | "pending";
|
|
62
62
|
uid: string;
|
|
63
63
|
email: string;
|
|
64
64
|
username: string | null;
|
|
@@ -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
|
*/
|
|
@@ -126,3 +133,59 @@ export declare const useAgreeTerms: () => import("@tanstack/react-query").UseMut
|
|
|
126
133
|
termCodes: string[];
|
|
127
134
|
channelUid?: string;
|
|
128
135
|
}, unknown>;
|
|
136
|
+
/**
|
|
137
|
+
* Hook to block a user.
|
|
138
|
+
*/
|
|
139
|
+
export declare const useBlockUser: () => import("@tanstack/react-query").UseMutationResult<{
|
|
140
|
+
message: string;
|
|
141
|
+
success: boolean;
|
|
142
|
+
}, Error, {
|
|
143
|
+
uid: string;
|
|
144
|
+
data?: BlockUserRequest;
|
|
145
|
+
}, unknown>;
|
|
146
|
+
/**
|
|
147
|
+
* Hook to unblock a user.
|
|
148
|
+
*/
|
|
149
|
+
export declare const useUnblockUser: () => import("@tanstack/react-query").UseMutationResult<{
|
|
150
|
+
message: string;
|
|
151
|
+
success: boolean;
|
|
152
|
+
}, Error, string, unknown>;
|
|
153
|
+
/**
|
|
154
|
+
* Hook to fetch the list of blocked users.
|
|
155
|
+
*/
|
|
156
|
+
export declare const useBlockedUsers: (uid: string, params?: {
|
|
157
|
+
page?: number;
|
|
158
|
+
limit?: number;
|
|
159
|
+
}) => import("@tanstack/react-query").UseQueryResult<{
|
|
160
|
+
items: {
|
|
161
|
+
uid: string;
|
|
162
|
+
username: string | null;
|
|
163
|
+
display_name: string;
|
|
164
|
+
avatar_url: string | null;
|
|
165
|
+
reason: string | null;
|
|
166
|
+
blocked_at: string;
|
|
167
|
+
}[];
|
|
168
|
+
total: number;
|
|
169
|
+
page: number;
|
|
170
|
+
limit: number;
|
|
171
|
+
totalPages: number;
|
|
172
|
+
}, Error>;
|
|
173
|
+
/**
|
|
174
|
+
* Hook to suspend a user (Global Ban).
|
|
175
|
+
* Admin only.
|
|
176
|
+
*/
|
|
177
|
+
export declare const useSuspendUser: () => import("@tanstack/react-query").UseMutationResult<{
|
|
178
|
+
message: string;
|
|
179
|
+
success: boolean;
|
|
180
|
+
}, Error, {
|
|
181
|
+
uid: string;
|
|
182
|
+
data?: SuspendUserRequest;
|
|
183
|
+
}, unknown>;
|
|
184
|
+
/**
|
|
185
|
+
* Hook to unsuspend a user.
|
|
186
|
+
* Admin only.
|
|
187
|
+
*/
|
|
188
|
+
export declare const useUnsuspendUser: () => import("@tanstack/react-query").UseMutationResult<{
|
|
189
|
+
message: string;
|
|
190
|
+
success: boolean;
|
|
191
|
+
}, Error, string, unknown>;
|
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.useUnsuspendUser = exports.useSuspendUser = exports.useBlockedUsers = exports.useUnblockUser = exports.useBlockUser = 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
|
*/
|
|
@@ -81,3 +93,57 @@ const useAgreeTerms = () => {
|
|
|
81
93
|
});
|
|
82
94
|
};
|
|
83
95
|
exports.useAgreeTerms = useAgreeTerms;
|
|
96
|
+
/**
|
|
97
|
+
* Hook to block a user.
|
|
98
|
+
*/
|
|
99
|
+
const useBlockUser = () => {
|
|
100
|
+
const client = (0, context_1.usePHCMS)();
|
|
101
|
+
return (0, react_query_1.useMutation)({
|
|
102
|
+
mutationFn: ({ uid, data }) => client.user.block(uid, data),
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
exports.useBlockUser = useBlockUser;
|
|
106
|
+
/**
|
|
107
|
+
* Hook to unblock a user.
|
|
108
|
+
*/
|
|
109
|
+
const useUnblockUser = () => {
|
|
110
|
+
const client = (0, context_1.usePHCMS)();
|
|
111
|
+
return (0, react_query_1.useMutation)({
|
|
112
|
+
mutationFn: (uid) => client.user.unblock(uid),
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
exports.useUnblockUser = useUnblockUser;
|
|
116
|
+
/**
|
|
117
|
+
* Hook to fetch the list of blocked users.
|
|
118
|
+
*/
|
|
119
|
+
const useBlockedUsers = (uid, params = {}) => {
|
|
120
|
+
const client = (0, context_1.usePHCMS)();
|
|
121
|
+
return (0, react_query_1.useQuery)({
|
|
122
|
+
queryKey: ['user-blocked-users', uid, params],
|
|
123
|
+
queryFn: () => client.user.getBlockedUsers(uid, params),
|
|
124
|
+
enabled: !!uid,
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
exports.useBlockedUsers = useBlockedUsers;
|
|
128
|
+
/**
|
|
129
|
+
* Hook to suspend a user (Global Ban).
|
|
130
|
+
* Admin only.
|
|
131
|
+
*/
|
|
132
|
+
const useSuspendUser = () => {
|
|
133
|
+
const client = (0, context_1.usePHCMS)();
|
|
134
|
+
return (0, react_query_1.useMutation)({
|
|
135
|
+
mutationFn: ({ uid, data }) => client.user.suspend(uid, data),
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
exports.useSuspendUser = useSuspendUser;
|
|
139
|
+
/**
|
|
140
|
+
* Hook to unsuspend a user.
|
|
141
|
+
* Admin only.
|
|
142
|
+
*/
|
|
143
|
+
const useUnsuspendUser = () => {
|
|
144
|
+
const client = (0, context_1.usePHCMS)();
|
|
145
|
+
return (0, react_query_1.useMutation)({
|
|
146
|
+
mutationFn: (uid) => client.user.unsuspend(uid),
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
exports.useUnsuspendUser = useUnsuspendUser;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CollectStampRequest, ContentDto, CreateContentRequest, CreateStampTourRequest, LikeStatusResponse, ListContentQuery, ListLikersQuery, PagedContentListResponse, PagedResponse, StampStatusDto, ToggleLikeResponse, TourStatsDto, UpdateContentRequest, UpdateStampTourRequest, UserProfileDto } from "@ph-cms/api-contract";
|
|
1
|
+
import { CollectStampRequest, ContentDto, CreateContentRequest, CreateStampTourRequest, LikeStatusResponse, ListContentQuery, ListLikersQuery, PagedContentListResponse, PagedResponse, StampStatusDto, ToggleLikeResponse, TourStatsDto, UpdateContentRequest, UpdateStampTourRequest, UserProfileDto, ReportContentRequest, ReportContentResponse } from "@ph-cms/api-contract";
|
|
2
2
|
import { AxiosInstance } from "axios";
|
|
3
3
|
export declare class ContentModule {
|
|
4
4
|
private client;
|
|
@@ -21,4 +21,5 @@ export declare class ContentModule {
|
|
|
21
21
|
toggleLike(uid: string): Promise<ToggleLikeResponse>;
|
|
22
22
|
getLikeStatus(uid: string): Promise<LikeStatusResponse>;
|
|
23
23
|
getLikers(uid: string, params?: Partial<ListLikersQuery>): Promise<PagedResponse<UserProfileDto>>;
|
|
24
|
+
report(uid: string, data: ReportContentRequest): Promise<ReportContentResponse>;
|
|
24
25
|
}
|
package/dist/modules/content.js
CHANGED
|
@@ -104,5 +104,14 @@ class ContentModule {
|
|
|
104
104
|
}
|
|
105
105
|
return this.client.get(`${this.prefix}/contents/${uid}/likers`, { params });
|
|
106
106
|
}
|
|
107
|
+
async report(uid, data) {
|
|
108
|
+
if (!uid)
|
|
109
|
+
throw new errors_1.ValidationError("UID is required", []);
|
|
110
|
+
const validation = api_contract_1.ReportContentSchema.safeParse(data);
|
|
111
|
+
if (!validation.success) {
|
|
112
|
+
throw new errors_1.ValidationError("Invalid report content data", validation.error.errors);
|
|
113
|
+
}
|
|
114
|
+
return this.client.post(`${this.prefix}/contents/${uid}/report`, data);
|
|
115
|
+
}
|
|
107
116
|
}
|
|
108
117
|
exports.ContentModule = ContentModule;
|
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, 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,4 +28,48 @@ 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>;
|
|
37
|
+
/**
|
|
38
|
+
* Blocks a user.
|
|
39
|
+
*
|
|
40
|
+
* @param uid - The UID of the user to block.
|
|
41
|
+
* @param data - The block reason (optional).
|
|
42
|
+
*/
|
|
43
|
+
block(uid: string, data?: BlockUserRequest): Promise<BlockUserResponse>;
|
|
44
|
+
/**
|
|
45
|
+
* Unblocks a user.
|
|
46
|
+
*
|
|
47
|
+
* @param uid - The UID of the user to unblock.
|
|
48
|
+
*/
|
|
49
|
+
unblock(uid: string): Promise<BlockUserResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Retrieves the list of blocked users.
|
|
52
|
+
*
|
|
53
|
+
* @param uid - The UID of the user (must be self or admin).
|
|
54
|
+
* @param params - Paging parameters.
|
|
55
|
+
*/
|
|
56
|
+
getBlockedUsers(uid: string, params?: {
|
|
57
|
+
page?: number;
|
|
58
|
+
limit?: number;
|
|
59
|
+
}): Promise<PagedBlockedUserListResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* Suspends a user (Global Ban).
|
|
62
|
+
* Admin only.
|
|
63
|
+
*
|
|
64
|
+
* @param uid - The UID of the user to suspend.
|
|
65
|
+
* @param data - Optional reason for suspension.
|
|
66
|
+
*/
|
|
67
|
+
suspend(uid: string, data?: SuspendUserRequest): Promise<SuspendUserResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* Unsuspends a user.
|
|
70
|
+
* Admin only.
|
|
71
|
+
*
|
|
72
|
+
* @param uid - The UID of the user to unsuspend.
|
|
73
|
+
*/
|
|
74
|
+
unsuspend(uid: string): Promise<SuspendUserResponse>;
|
|
31
75
|
}
|
package/dist/modules/user.js
CHANGED
|
@@ -44,5 +44,74 @@ 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
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Blocks a user.
|
|
59
|
+
*
|
|
60
|
+
* @param uid - The UID of the user to block.
|
|
61
|
+
* @param data - The block reason (optional).
|
|
62
|
+
*/
|
|
63
|
+
async block(uid, data = {}) {
|
|
64
|
+
if (!uid)
|
|
65
|
+
throw new errors_1.ValidationError("UID is required", []);
|
|
66
|
+
const validation = api_contract_1.BlockUserSchema.safeParse(data);
|
|
67
|
+
if (!validation.success) {
|
|
68
|
+
throw new errors_1.ValidationError("Invalid block user data", validation.error.errors);
|
|
69
|
+
}
|
|
70
|
+
return this.client.post(`${this.prefix}/users/${uid}/block`, data);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Unblocks a user.
|
|
74
|
+
*
|
|
75
|
+
* @param uid - The UID of the user to unblock.
|
|
76
|
+
*/
|
|
77
|
+
async unblock(uid) {
|
|
78
|
+
if (!uid)
|
|
79
|
+
throw new errors_1.ValidationError("UID is required", []);
|
|
80
|
+
return this.client.delete(`${this.prefix}/users/${uid}/block`);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves the list of blocked users.
|
|
84
|
+
*
|
|
85
|
+
* @param uid - The UID of the user (must be self or admin).
|
|
86
|
+
* @param params - Paging parameters.
|
|
87
|
+
*/
|
|
88
|
+
async getBlockedUsers(uid, params = {}) {
|
|
89
|
+
if (!uid)
|
|
90
|
+
throw new errors_1.ValidationError("UID is required", []);
|
|
91
|
+
return this.client.get(`${this.prefix}/users/${uid}/blocks`, { params });
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Suspends a user (Global Ban).
|
|
95
|
+
* Admin only.
|
|
96
|
+
*
|
|
97
|
+
* @param uid - The UID of the user to suspend.
|
|
98
|
+
* @param data - Optional reason for suspension.
|
|
99
|
+
*/
|
|
100
|
+
async suspend(uid, data = {}) {
|
|
101
|
+
if (!uid)
|
|
102
|
+
throw new errors_1.ValidationError("UID is required", []);
|
|
103
|
+
return this.client.post(`${this.prefix}/users/${uid}/suspend`, data);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Unsuspends a user.
|
|
107
|
+
* Admin only.
|
|
108
|
+
*
|
|
109
|
+
* @param uid - The UID of the user to unsuspend.
|
|
110
|
+
*/
|
|
111
|
+
async unsuspend(uid) {
|
|
112
|
+
if (!uid)
|
|
113
|
+
throw new errors_1.ValidationError("UID is required", []);
|
|
114
|
+
return this.client.delete(`${this.prefix}/users/${uid}/suspend`);
|
|
115
|
+
}
|
|
47
116
|
}
|
|
48
117
|
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.42",
|
|
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.19",
|
|
34
34
|
"@tanstack/react-query": "^5.0.0",
|
|
35
35
|
"axios": "^1.6.0",
|
|
36
36
|
"zod": "^3.22.4"
|