@ph-cms/client-sdk 0.1.42 → 0.1.43

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
@@ -1,4 +1,4 @@
1
- # @ph-cms/client-sdk 0.1.42
1
+ # @ph-cms/client-sdk 0.1.43
2
2
 
3
3
  PH-CMS 클라이언트 SDK — 브라우저 및 React 애플리케이션을 위한 통합 클라이언트.
4
4
 
@@ -1679,7 +1679,7 @@ const result = await content.list({ channelUid: 'my-channel' });
1679
1679
  | 메서드 | 설명 |
1680
1680
  |---|---|
1681
1681
  | `list(query: ListContentQuery)` | 콘텐츠 목록 조회 → `PagedContentListResponse` |
1682
- | `get(uid: string)` | 단일 콘텐츠 상세 조회 → `ContentDto` |
1682
+ | `get(uid: string, params?: { withParent?: boolean; withDetail?: boolean })` | 단일 콘텐츠 상세 조회 → `ContentDto` |
1683
1683
  | `create(data: CreateContentRequest)` | 일반 콘텐츠 생성 → `ContentDto` |
1684
1684
  | `update(uid: string, data: UpdateContentRequest)` | 콘텐츠 수정 → `ContentDto` |
1685
1685
  | `delete(uid: string)` | 콘텐츠 삭제 |
@@ -1693,6 +1693,13 @@ const result = await content.list({ channelUid: 'my-channel' });
1693
1693
  | `getLikers(uid: string, params?: Partial<ListLikersQuery>)` | 콘텐츠에 좋아요 누른 사용자 목록 조회 → `PagedResponse<UserProfileDto>` |
1694
1694
  | `report(uid: string, data: ReportContentRequest)` | 콘텐츠 신고 → `ReportContentResponse` |
1695
1695
 
1696
+ 예시:
1697
+
1698
+ ```ts
1699
+ await client.content.list({ withParent: true, withDetail: true, page: 1, limit: 20 });
1700
+ await client.content.get('cnt_123', { withParent: true, withDetail: true });
1701
+ ```
1702
+
1696
1703
  ### `ChannelModule` (`client.channel`)
1697
1704
 
1698
1705
  | 메서드 | 설명 |
@@ -9,6 +9,8 @@ export declare const contentKeys: {
9
9
  type?: string | undefined;
10
10
  channelUid?: string | undefined;
11
11
  channelSlug?: string | undefined;
12
+ withDetail?: boolean | undefined;
13
+ withParent?: boolean | undefined;
12
14
  tags?: string[] | undefined;
13
15
  parentUid?: string | undefined;
14
16
  authorUid?: string | undefined;
@@ -17,11 +19,17 @@ export declare const contentKeys: {
17
19
  keyword?: string | undefined;
18
20
  orderBy?: "title" | "created_at" | "updated_at" | "published_at" | "view_count" | "like_count" | undefined;
19
21
  orderDir?: "asc" | "desc" | undefined;
20
- withDetail?: boolean | undefined;
21
22
  includeDeleted?: boolean | undefined;
22
23
  }];
23
24
  details: () => readonly ["contents", "detail"];
24
- detail: (uid: string) => readonly ["contents", "detail", string];
25
+ detailPrefix: (uid: string) => readonly ["contents", "detail", string];
26
+ detail: (uid: string, params?: {
27
+ withParent?: boolean;
28
+ withDetail?: boolean;
29
+ }) => readonly ["contents", "detail", string, {
30
+ withParent?: boolean;
31
+ withDetail?: boolean;
32
+ }];
25
33
  likes: () => readonly ["contents", "like"];
26
34
  like: (uid: string) => readonly ["contents", "like", string];
27
35
  };
@@ -35,7 +43,10 @@ export declare const useContentList: (params: ListContentQuery, enabled?: boolea
35
43
  last: boolean;
36
44
  empty: boolean;
37
45
  }, Error>;
38
- export declare const useContentDetail: (uid: string) => import("@tanstack/react-query").UseQueryResult<ContentDto, Error>;
46
+ export declare const useContentDetail: (uid: string, params?: {
47
+ withParent?: boolean;
48
+ withDetail?: boolean;
49
+ }) => import("@tanstack/react-query").UseQueryResult<ContentDto, Error>;
39
50
  export declare const useIncrementView: () => import("@tanstack/react-query").UseMutationResult<void, Error, string, {
40
51
  previousDetail: ContentDto | undefined;
41
52
  uid: string;
@@ -8,7 +8,8 @@ exports.contentKeys = {
8
8
  lists: () => [...exports.contentKeys.all, 'list'],
9
9
  list: (params) => [...exports.contentKeys.lists(), params],
10
10
  details: () => [...exports.contentKeys.all, 'detail'],
11
- detail: (uid) => [...exports.contentKeys.details(), uid],
11
+ detailPrefix: (uid) => [...exports.contentKeys.details(), uid],
12
+ detail: (uid, params) => [...exports.contentKeys.details(), uid, params ?? {}],
12
13
  likes: () => [...exports.contentKeys.all, 'like'],
13
14
  like: (uid) => [...exports.contentKeys.likes(), uid],
14
15
  };
@@ -27,11 +28,11 @@ const useContentList = (params, enabled = true) => {
27
28
  });
28
29
  };
29
30
  exports.useContentList = useContentList;
30
- const useContentDetail = (uid) => {
31
+ const useContentDetail = (uid, params) => {
31
32
  const client = (0, context_1.usePHCMS)();
32
33
  return (0, react_query_1.useQuery)({
33
- queryKey: exports.contentKeys.detail(uid),
34
- queryFn: () => client.content.get(uid),
34
+ queryKey: exports.contentKeys.detail(uid, params),
35
+ queryFn: () => client.content.get(uid, params),
35
36
  enabled: !!uid,
36
37
  });
37
38
  };
@@ -43,7 +44,7 @@ const useIncrementView = () => {
43
44
  mutationFn: (uid) => client.content.incrementView(uid),
44
45
  onMutate: async (uid) => {
45
46
  // Cancel any outgoing refetches for the content detail
46
- await queryClient.cancelQueries({ queryKey: exports.contentKeys.detail(uid) });
47
+ await queryClient.cancelQueries({ queryKey: exports.contentKeys.detailPrefix(uid) });
47
48
  // Snapshot the previous detail
48
49
  const previousDetail = queryClient.getQueryData(exports.contentKeys.detail(uid));
49
50
  // Optimistically update the view count in the detail cache
@@ -99,7 +100,7 @@ const useToggleLike = () => {
99
100
  onMutate: async (uid) => {
100
101
  // Cancel any outgoing refetches so they don't overwrite our optimistic update
101
102
  await queryClient.cancelQueries({ queryKey: exports.contentKeys.like(uid) });
102
- await queryClient.cancelQueries({ queryKey: exports.contentKeys.detail(uid) });
103
+ await queryClient.cancelQueries({ queryKey: exports.contentKeys.detailPrefix(uid) });
103
104
  // Snapshot the previous values
104
105
  const previousLikeStatus = queryClient.getQueryData(exports.contentKeys.like(uid));
105
106
  const previousDetail = queryClient.getQueryData(exports.contentKeys.detail(uid));
@@ -161,6 +162,7 @@ const useUpdateContent = () => {
161
162
  mutationFn: ({ uid, data }) => client.content.update(uid, data),
162
163
  onSuccess: (data, variables) => {
163
164
  queryClient.invalidateQueries({ queryKey: exports.contentKeys.detail(variables.uid) });
165
+ queryClient.invalidateQueries({ queryKey: exports.contentKeys.detailPrefix(variables.uid) });
164
166
  queryClient.invalidateQueries({ queryKey: exports.contentKeys.lists() });
165
167
  },
166
168
  });
@@ -5,7 +5,10 @@ export declare class ContentModule {
5
5
  private prefix;
6
6
  constructor(client: AxiosInstance, prefix?: string);
7
7
  list(params: ListContentQuery): Promise<PagedContentListResponse>;
8
- get(uid: string): Promise<ContentDto>;
8
+ get(uid: string, params?: {
9
+ withParent?: boolean;
10
+ withDetail?: boolean;
11
+ }): Promise<ContentDto>;
9
12
  incrementView(uid: string): Promise<void>;
10
13
  create(data: CreateContentRequest): Promise<ContentDto>;
11
14
  update(uid: string, data: UpdateContentRequest): Promise<ContentDto>;
@@ -15,10 +15,10 @@ class ContentModule {
15
15
  }
16
16
  return this.client.get(`${this.prefix}/contents`, { params });
17
17
  }
18
- async get(uid) {
18
+ async get(uid, params) {
19
19
  if (!uid)
20
20
  throw new errors_1.ValidationError("UID is required", []);
21
- return this.client.get(`${this.prefix}/contents/${uid}`);
21
+ return this.client.get(`${this.prefix}/contents/${uid}`, { params });
22
22
  }
23
23
  async incrementView(uid) {
24
24
  if (!uid)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ph-cms/client-sdk",
3
- "version": "0.1.42",
3
+ "version": "0.1.43",
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.19",
33
+ "@ph-cms/api-contract": "^0.1.20",
34
34
  "@tanstack/react-query": "^5.0.0",
35
35
  "axios": "^1.6.0",
36
36
  "zod": "^3.22.4"