@ph-cms/client-sdk 0.1.11 → 0.1.12

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
@@ -799,10 +799,72 @@ function CreateTourForm() {
799
799
  alert('투어가 생성되었습니다.');
800
800
  };
801
801
 
802
- return <button onClick={handleCreate} disabled={isPending}>투어 만들기</button>;
802
+ return <button onClick={handleCreate} disabled={isPending}>생성</button>;
803
803
  }
804
804
  ```
805
805
 
806
+ ---
807
+
808
+ ## User Terms (사용자 약관)
809
+
810
+ PH-CMS는 글로벌 약관과 채널별 약관을 지원하며, 사용자의 동의 여부와 최신 버전 준수 여부를 트래킹합니다.
811
+
812
+ ### Channel Context Setup
813
+
814
+ 특정 채널의 서비스라면 `PHCMSProvider`에 `channelUid`를 전달하여, 해당 채널의 약관 준수 상태를 자동으로 가져올 수 있습니다.
815
+
816
+ ```tsx
817
+ <PHCMSProvider client={client} channelUid="my-channel-slug">
818
+ <App />
819
+ </PHCMSProvider>
820
+ ```
821
+
822
+ 이렇게 설정하면 `useAuth()`나 `usePHCMSContext()`를 통해 가져오는 `user` 객체의 `channel_agreements` 필드에 해당 채널의 약관 요약 정보가 포함됩니다.
823
+
824
+ ### Checking Compliance
825
+
826
+ 사용자가 필수 약관에 모두 동의했는지, 혹은 약관이 개정되어 재동의가 필요한지 확인합니다.
827
+
828
+ ```tsx
829
+ function TermsGuard({ children }) {
830
+ const { user } = useAuth();
831
+
832
+ // 현재 채널에 대한 동의 요약 찾기
833
+ const compliance = user?.channel_agreements?.[0];
834
+
835
+ if (compliance && !compliance.is_fully_compliant) {
836
+ return <TermsAgreementModal summary={compliance} />;
837
+ }
838
+
839
+ return children;
840
+ }
841
+ ```
842
+
843
+ ### Hooks for Terms
844
+
845
+ #### 1. `useChannelTerms(channelUid)`
846
+ 특정 채널에 할당된 약관 목록을 조회합니다.
847
+
848
+ ```tsx
849
+ const { data: terms } = useChannelTerms('my-channel-slug');
850
+ ```
851
+
852
+ #### 2. `useAgreeTerms()`
853
+ 약관 동의를 제출합니다.
854
+
855
+ ```tsx
856
+ const { mutateAsync: agree } = useAgreeTerms();
857
+
858
+ const handleAgree = async (termCodes: string[]) => {
859
+ await agree({
860
+ termCodes,
861
+ channelUid: 'my-channel-slug' // 선택 사항 (Provider에 설정되어 있어도 명시 가능)
862
+ });
863
+ };
864
+ ```
865
+
866
+ ---
867
+
806
868
  #### 스탬프 투어 수정 (인증 필수)
807
869
 
808
870
  기존 스탬프 투어의 정보나 마커 목록을 수정합니다. (참여자가 있는 경우 마커 목록 수정은 제한될 수 있습니다.)
package/dist/context.d.ts CHANGED
@@ -8,8 +8,9 @@ export interface PHCMSContextType {
8
8
  user: UserDto | null;
9
9
  isAuthenticated: boolean;
10
10
  isLoading: boolean;
11
- /** Whether the user profile fetch failed. */
12
11
  isError: boolean;
12
+ /** The current channel context for terms compliance. */
13
+ channelUid?: string;
13
14
  /**
14
15
  * Fine-grained authentication status.
15
16
  * - `'loading'`: Token exists, `/auth/me` is being fetched.
@@ -25,10 +26,10 @@ export interface PHCMSContextType {
25
26
  export interface PHCMSProviderProps {
26
27
  client: PHCMSClient;
27
28
  queryClient?: QueryClient;
29
+ channelUid?: string;
28
30
  children: ReactNode;
29
31
  }
30
32
  /**
31
- * Root Provider for PH-CMS
32
33
  * Automatically includes QueryClientProvider
33
34
  */
34
35
  export declare const PHCMSProvider: React.FC<PHCMSProviderProps>;
package/dist/context.js CHANGED
@@ -41,15 +41,15 @@ const AUTH_ME_QUERY_KEY = ['auth', 'me'];
41
41
  /**
42
42
  * Internal component to handle auth state and provide to context
43
43
  */
44
- const PHCMSInternalProvider = ({ client, children }) => {
44
+ const PHCMSInternalProvider = ({ client, channelUid, children }) => {
45
45
  const queryClient = (0, react_query_1.useQueryClient)();
46
46
  // Track token presence in state to trigger re-renders when it changes.
47
47
  // Initial value from provider.
48
48
  const [hasToken, setHasToken] = (0, react_1.useState)(() => client.authProvider?.hasToken() ?? false);
49
49
  // The 'me' query is only enabled if we have a token.
50
50
  const { data: user, isLoading, isError, refetch } = (0, react_query_1.useQuery)({
51
- queryKey: [...AUTH_ME_QUERY_KEY],
52
- queryFn: () => client.auth.me(),
51
+ queryKey: [...AUTH_ME_QUERY_KEY, channelUid],
52
+ queryFn: () => client.auth.me({ channelUid }),
53
53
  enabled: hasToken,
54
54
  retry: false,
55
55
  staleTime: 1000 * 60 * 5,
@@ -92,16 +92,16 @@ const PHCMSInternalProvider = ({ client, children }) => {
92
92
  isError,
93
93
  authStatus,
94
94
  hasToken,
95
+ channelUid,
95
96
  refreshUser,
96
97
  };
97
- }, [client, user, isError, isLoading, hasToken, refreshUser]);
98
+ }, [client, user, isError, isLoading, hasToken, channelUid, refreshUser]);
98
99
  return react_1.default.createElement(PHCMSContext.Provider, { value: value }, children);
99
100
  };
100
101
  /**
101
- * Root Provider for PH-CMS
102
102
  * Automatically includes QueryClientProvider
103
103
  */
104
- const PHCMSProvider = ({ client, queryClient, children }) => {
104
+ const PHCMSProvider = ({ client, queryClient, channelUid, children }) => {
105
105
  const internalQueryClient = (0, react_1.useMemo)(() => queryClient ??
106
106
  new react_query_1.QueryClient({
107
107
  defaultOptions: {
@@ -112,7 +112,7 @@ const PHCMSProvider = ({ client, queryClient, children }) => {
112
112
  },
113
113
  }), [queryClient]);
114
114
  return (react_1.default.createElement(react_query_1.QueryClientProvider, { client: internalQueryClient },
115
- react_1.default.createElement(PHCMSInternalProvider, { client: client }, children)));
115
+ react_1.default.createElement(PHCMSInternalProvider, { client: client, channelUid: channelUid }, children)));
116
116
  };
117
117
  exports.PHCMSProvider = PHCMSProvider;
118
118
  /**
@@ -4,6 +4,7 @@
4
4
  */
5
5
  export declare const useAuth: () => {
6
6
  user: {
7
+ status: string;
7
8
  uid: string;
8
9
  email: string;
9
10
  username: string | null;
@@ -14,18 +15,32 @@ export declare const useAuth: () => {
14
15
  phone_verified_at: string | null;
15
16
  locale: string;
16
17
  timezone: string;
17
- status: string;
18
18
  role: string[];
19
19
  profile_data: Record<string, any>;
20
20
  last_login_at: string | null;
21
21
  created_at: string;
22
22
  updated_at: string;
23
+ channel_agreements?: {
24
+ channel_uid: string | null;
25
+ is_fully_compliant: boolean;
26
+ agreements: {
27
+ code: string;
28
+ version: string;
29
+ title: string;
30
+ term_id: number;
31
+ is_agreed: boolean;
32
+ is_required: boolean;
33
+ is_latest: boolean;
34
+ agreed_at: string | null;
35
+ }[];
36
+ }[] | undefined;
23
37
  } | null;
24
38
  isAuthenticated: boolean;
25
39
  isLoading: boolean;
26
40
  login: import("@tanstack/react-query").UseMutateAsyncFunction<{
27
41
  refreshToken: string;
28
42
  user: {
43
+ status: string;
29
44
  uid: string;
30
45
  email: string;
31
46
  username: string | null;
@@ -36,12 +51,25 @@ export declare const useAuth: () => {
36
51
  phone_verified_at: string | null;
37
52
  locale: string;
38
53
  timezone: string;
39
- status: string;
40
54
  role: string[];
41
55
  profile_data: Record<string, any>;
42
56
  last_login_at: string | null;
43
57
  created_at: string;
44
58
  updated_at: string;
59
+ channel_agreements?: {
60
+ channel_uid: string | null;
61
+ is_fully_compliant: boolean;
62
+ agreements: {
63
+ code: string;
64
+ version: string;
65
+ title: string;
66
+ term_id: number;
67
+ is_agreed: boolean;
68
+ is_required: boolean;
69
+ is_latest: boolean;
70
+ agreed_at: string | null;
71
+ }[];
72
+ }[] | undefined;
45
73
  };
46
74
  accessToken: string;
47
75
  }, Error, {
@@ -51,6 +79,7 @@ export declare const useAuth: () => {
51
79
  loginWithFirebase: import("@tanstack/react-query").UseMutateAsyncFunction<{
52
80
  refreshToken: string;
53
81
  user: {
82
+ status: string;
54
83
  uid: string;
55
84
  email: string;
56
85
  username: string | null;
@@ -61,12 +90,25 @@ export declare const useAuth: () => {
61
90
  phone_verified_at: string | null;
62
91
  locale: string;
63
92
  timezone: string;
64
- status: string;
65
93
  role: string[];
66
94
  profile_data: Record<string, any>;
67
95
  last_login_at: string | null;
68
96
  created_at: string;
69
97
  updated_at: string;
98
+ channel_agreements?: {
99
+ channel_uid: string | null;
100
+ is_fully_compliant: boolean;
101
+ agreements: {
102
+ code: string;
103
+ version: string;
104
+ title: string;
105
+ term_id: number;
106
+ is_agreed: boolean;
107
+ is_required: boolean;
108
+ is_latest: boolean;
109
+ agreed_at: string | null;
110
+ }[];
111
+ }[] | undefined;
70
112
  };
71
113
  accessToken: string;
72
114
  }, Error, {
@@ -75,6 +117,7 @@ export declare const useAuth: () => {
75
117
  register: import("@tanstack/react-query").UseMutateAsyncFunction<{
76
118
  refreshToken: string;
77
119
  user: {
120
+ status: string;
78
121
  uid: string;
79
122
  email: string;
80
123
  username: string | null;
@@ -85,12 +128,25 @@ export declare const useAuth: () => {
85
128
  phone_verified_at: string | null;
86
129
  locale: string;
87
130
  timezone: string;
88
- status: string;
89
131
  role: string[];
90
132
  profile_data: Record<string, any>;
91
133
  last_login_at: string | null;
92
134
  created_at: string;
93
135
  updated_at: string;
136
+ channel_agreements?: {
137
+ channel_uid: string | null;
138
+ is_fully_compliant: boolean;
139
+ agreements: {
140
+ code: string;
141
+ version: string;
142
+ title: string;
143
+ term_id: number;
144
+ is_agreed: boolean;
145
+ is_required: boolean;
146
+ is_latest: boolean;
147
+ agreed_at: string | null;
148
+ }[];
149
+ }[] | undefined;
94
150
  };
95
151
  accessToken: string;
96
152
  }, Error, {
@@ -101,11 +157,13 @@ export declare const useAuth: () => {
101
157
  provider?: string | undefined;
102
158
  provider_subject?: string | undefined;
103
159
  termCodes?: string[] | undefined;
160
+ channelUid?: string | undefined;
104
161
  }, unknown>;
105
162
  logout: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, void, unknown>;
106
163
  loginStatus: import("@tanstack/react-query").UseMutationResult<{
107
164
  refreshToken: string;
108
165
  user: {
166
+ status: string;
109
167
  uid: string;
110
168
  email: string;
111
169
  username: string | null;
@@ -116,12 +174,25 @@ export declare const useAuth: () => {
116
174
  phone_verified_at: string | null;
117
175
  locale: string;
118
176
  timezone: string;
119
- status: string;
120
177
  role: string[];
121
178
  profile_data: Record<string, any>;
122
179
  last_login_at: string | null;
123
180
  created_at: string;
124
181
  updated_at: string;
182
+ channel_agreements?: {
183
+ channel_uid: string | null;
184
+ is_fully_compliant: boolean;
185
+ agreements: {
186
+ code: string;
187
+ version: string;
188
+ title: string;
189
+ term_id: number;
190
+ is_agreed: boolean;
191
+ is_required: boolean;
192
+ is_latest: boolean;
193
+ agreed_at: string | null;
194
+ }[];
195
+ }[] | undefined;
125
196
  };
126
197
  accessToken: string;
127
198
  }, Error, {
@@ -131,6 +202,7 @@ export declare const useAuth: () => {
131
202
  loginWithFirebaseStatus: import("@tanstack/react-query").UseMutationResult<{
132
203
  refreshToken: string;
133
204
  user: {
205
+ status: string;
134
206
  uid: string;
135
207
  email: string;
136
208
  username: string | null;
@@ -141,12 +213,25 @@ export declare const useAuth: () => {
141
213
  phone_verified_at: string | null;
142
214
  locale: string;
143
215
  timezone: string;
144
- status: string;
145
216
  role: string[];
146
217
  profile_data: Record<string, any>;
147
218
  last_login_at: string | null;
148
219
  created_at: string;
149
220
  updated_at: string;
221
+ channel_agreements?: {
222
+ channel_uid: string | null;
223
+ is_fully_compliant: boolean;
224
+ agreements: {
225
+ code: string;
226
+ version: string;
227
+ title: string;
228
+ term_id: number;
229
+ is_agreed: boolean;
230
+ is_required: boolean;
231
+ is_latest: boolean;
232
+ agreed_at: string | null;
233
+ }[];
234
+ }[] | undefined;
150
235
  };
151
236
  accessToken: string;
152
237
  }, Error, {
@@ -155,6 +240,7 @@ export declare const useAuth: () => {
155
240
  registerStatus: import("@tanstack/react-query").UseMutationResult<{
156
241
  refreshToken: string;
157
242
  user: {
243
+ status: string;
158
244
  uid: string;
159
245
  email: string;
160
246
  username: string | null;
@@ -165,12 +251,25 @@ export declare const useAuth: () => {
165
251
  phone_verified_at: string | null;
166
252
  locale: string;
167
253
  timezone: string;
168
- status: string;
169
254
  role: string[];
170
255
  profile_data: Record<string, any>;
171
256
  last_login_at: string | null;
172
257
  created_at: string;
173
258
  updated_at: string;
259
+ channel_agreements?: {
260
+ channel_uid: string | null;
261
+ is_fully_compliant: boolean;
262
+ agreements: {
263
+ code: string;
264
+ version: string;
265
+ title: string;
266
+ term_id: number;
267
+ is_agreed: boolean;
268
+ is_required: boolean;
269
+ is_latest: boolean;
270
+ agreed_at: string | null;
271
+ }[];
272
+ }[] | undefined;
174
273
  };
175
274
  accessToken: string;
176
275
  }, Error, {
@@ -181,11 +280,13 @@ export declare const useAuth: () => {
181
280
  provider?: string | undefined;
182
281
  provider_subject?: string | undefined;
183
282
  termCodes?: string[] | undefined;
283
+ channelUid?: string | undefined;
184
284
  }, unknown>;
185
285
  logoutStatus: import("@tanstack/react-query").UseMutationResult<void, Error, void, unknown>;
186
286
  };
187
287
  export declare const useUser: () => {
188
288
  data: {
289
+ status: string;
189
290
  uid: string;
190
291
  email: string;
191
292
  username: string | null;
@@ -196,12 +297,25 @@ export declare const useUser: () => {
196
297
  phone_verified_at: string | null;
197
298
  locale: string;
198
299
  timezone: string;
199
- status: string;
200
300
  role: string[];
201
301
  profile_data: Record<string, any>;
202
302
  last_login_at: string | null;
203
303
  created_at: string;
204
304
  updated_at: string;
305
+ channel_agreements?: {
306
+ channel_uid: string | null;
307
+ is_fully_compliant: boolean;
308
+ agreements: {
309
+ code: string;
310
+ version: string;
311
+ title: string;
312
+ term_id: number;
313
+ is_agreed: boolean;
314
+ is_required: boolean;
315
+ is_latest: boolean;
316
+ agreed_at: string | null;
317
+ }[];
318
+ }[] | undefined;
205
319
  } | null;
206
320
  isLoading: boolean;
207
321
  isAuthenticated: boolean;
@@ -210,6 +324,7 @@ export declare const useUser: () => {
210
324
  export declare const useLogin: () => import("@tanstack/react-query").UseMutationResult<{
211
325
  refreshToken: string;
212
326
  user: {
327
+ status: string;
213
328
  uid: string;
214
329
  email: string;
215
330
  username: string | null;
@@ -220,12 +335,25 @@ export declare const useLogin: () => import("@tanstack/react-query").UseMutation
220
335
  phone_verified_at: string | null;
221
336
  locale: string;
222
337
  timezone: string;
223
- status: string;
224
338
  role: string[];
225
339
  profile_data: Record<string, any>;
226
340
  last_login_at: string | null;
227
341
  created_at: string;
228
342
  updated_at: string;
343
+ channel_agreements?: {
344
+ channel_uid: string | null;
345
+ is_fully_compliant: boolean;
346
+ agreements: {
347
+ code: string;
348
+ version: string;
349
+ title: string;
350
+ term_id: number;
351
+ is_agreed: boolean;
352
+ is_required: boolean;
353
+ is_latest: boolean;
354
+ agreed_at: string | null;
355
+ }[];
356
+ }[] | undefined;
229
357
  };
230
358
  accessToken: string;
231
359
  }, Error, {
@@ -11,8 +11,8 @@ export declare const channelKeys: {
11
11
  };
12
12
  export declare const useChannelList: (params: ListChannelQuery) => import("@tanstack/react-query").UseQueryResult<{
13
13
  items: {
14
- uid: string;
15
14
  status: string;
15
+ uid: string;
16
16
  created_at: string;
17
17
  updated_at: string;
18
18
  name: string;
@@ -37,8 +37,8 @@ export declare const useChannelList: (params: ListChannelQuery) => import("@tans
37
37
  totalPages: number;
38
38
  }, Error>;
39
39
  export declare const useCreateChannel: () => import("@tanstack/react-query").UseMutationResult<{
40
- uid: string;
41
40
  status: string;
41
+ uid: string;
42
42
  created_at: string;
43
43
  updated_at: string;
44
44
  name: string;
@@ -7,15 +7,15 @@ export declare const contentKeys: {
7
7
  limit: number;
8
8
  status?: string | undefined;
9
9
  type?: string | undefined;
10
- tags?: string[] | undefined;
11
10
  channelUid?: string | undefined;
11
+ tags?: string[] | undefined;
12
12
  channelSlug?: string | undefined;
13
13
  parentUid?: string | undefined;
14
14
  authorUid?: string | undefined;
15
15
  uids?: string[] | undefined;
16
16
  rootUid?: string | undefined;
17
17
  keyword?: string | undefined;
18
- orderBy?: "created_at" | "updated_at" | "published_at" | "title" | "view_count" | "like_count" | undefined;
18
+ orderBy?: "title" | "created_at" | "updated_at" | "published_at" | "view_count" | "like_count" | undefined;
19
19
  orderDir?: "asc" | "desc" | undefined;
20
20
  withDetail?: boolean | undefined;
21
21
  includeDeleted?: boolean | undefined;
@@ -35,8 +35,8 @@ export declare const contentKeys: {
35
35
  export declare const useContentList: (params: ListContentQuery, enabled?: boolean) => import("@tanstack/react-query").UseQueryResult<{
36
36
  number: number;
37
37
  totalPages: number;
38
- size: number;
39
38
  content: ContentDto[];
39
+ size: number;
40
40
  totalElements: number;
41
41
  first: boolean;
42
42
  last: boolean;
@@ -44,10 +44,15 @@ export declare const useContentList: (params: ListContentQuery, enabled?: boolea
44
44
  }, Error>;
45
45
  export declare const useContentGeoList: (bounds: BoundsQuery) => import("@tanstack/react-query").UseQueryResult<ContentDto[], Error>;
46
46
  export declare const useContentDetail: (uid: string) => import("@tanstack/react-query").UseQueryResult<ContentDto, Error>;
47
+ export declare const useIncrementView: () => import("@tanstack/react-query").UseMutationResult<void, Error, string, {
48
+ previousDetail: ContentDto | undefined;
49
+ uid: string;
50
+ }>;
47
51
  export declare const useCreateContent: () => import("@tanstack/react-query").UseMutationResult<ContentDto, Error, {
48
52
  type: string;
49
53
  title: string;
50
54
  status?: string | undefined;
55
+ channelUid?: string | undefined;
51
56
  geometry?: {
52
57
  type: "Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon" | "GeometryCollection" | "Feature" | "FeatureCollection";
53
58
  coordinates?: any[] | undefined;
@@ -62,7 +67,6 @@ export declare const useCreateContent: () => import("@tanstack/react-query").Use
62
67
  summary?: string | null | undefined;
63
68
  slug?: string | null | undefined;
64
69
  tags?: string[] | undefined;
65
- channelUid?: string | undefined;
66
70
  channelSlug?: string | undefined;
67
71
  parentUid?: string | undefined;
68
72
  sortOrder?: number | undefined;
@@ -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.useContentDetail = exports.useContentGeoList = exports.useContentList = exports.contentKeys = void 0;
3
+ exports.useDeleteContent = exports.useUpdateContent = exports.useToggleLike = exports.useLikeStatus = exports.useCreateContent = exports.useIncrementView = exports.useContentDetail = exports.useContentGeoList = 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 = {
@@ -42,6 +42,37 @@ const useContentDetail = (uid) => {
42
42
  });
43
43
  };
44
44
  exports.useContentDetail = useContentDetail;
45
+ const useIncrementView = () => {
46
+ const client = (0, context_1.usePHCMS)();
47
+ const queryClient = (0, react_query_1.useQueryClient)();
48
+ return (0, react_query_1.useMutation)({
49
+ mutationFn: (uid) => client.content.incrementView(uid),
50
+ onMutate: async (uid) => {
51
+ // Cancel any outgoing refetches for the content detail
52
+ await queryClient.cancelQueries({ queryKey: exports.contentKeys.detail(uid) });
53
+ // Snapshot the previous detail
54
+ const previousDetail = queryClient.getQueryData(exports.contentKeys.detail(uid));
55
+ // Optimistically update the view count in the detail cache
56
+ if (previousDetail) {
57
+ queryClient.setQueryData(exports.contentKeys.detail(uid), {
58
+ ...previousDetail,
59
+ stat: {
60
+ ...previousDetail.stat,
61
+ view_count: previousDetail.stat.view_count + 1,
62
+ },
63
+ });
64
+ }
65
+ return { previousDetail, uid };
66
+ },
67
+ onError: (err, uid, context) => {
68
+ // Roll back to the previous detail if the mutation fails
69
+ if (context?.previousDetail) {
70
+ queryClient.setQueryData(exports.contentKeys.detail(uid), context.previousDetail);
71
+ }
72
+ },
73
+ });
74
+ };
75
+ exports.useIncrementView = useIncrementView;
45
76
  const useCreateContent = () => {
46
77
  const client = (0, context_1.usePHCMS)();
47
78
  const queryClient = (0, react_query_1.useQueryClient)();
@@ -19,8 +19,8 @@ export declare const useUploadToS3: () => import("@tanstack/react-query").UseMut
19
19
  file: File | Blob;
20
20
  }, unknown>;
21
21
  export declare const useMediaDetail: (uid: string) => import("@tanstack/react-query").UseQueryResult<{
22
- uid: string;
23
22
  type: "image" | "video" | "audio" | "document" | "file";
23
+ uid: string;
24
24
  url: string;
25
25
  name: string;
26
26
  mimeType: string;
@@ -6,10 +6,11 @@ export declare const stampTourKeys: {
6
6
  };
7
7
  export declare const useCreateStampTour: () => import("@tanstack/react-query").UseMutationResult<ContentDto, Error, {
8
8
  title: string;
9
+ isActive: boolean;
9
10
  parentUid: string;
10
11
  markerUids: string[];
11
- isActive: boolean;
12
12
  status?: string | undefined;
13
+ channelUid?: string | undefined;
13
14
  geometry?: {
14
15
  type: "Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon" | "GeometryCollection" | "Feature" | "FeatureCollection";
15
16
  coordinates?: any[] | undefined;
@@ -21,7 +22,6 @@ export declare const useCreateStampTour: () => import("@tanstack/react-query").U
21
22
  image?: string | null | undefined;
22
23
  summary?: string | null | undefined;
23
24
  tags?: string[] | undefined;
24
- channelUid?: string | undefined;
25
25
  channelSlug?: string | undefined;
26
26
  startsAt?: string | null | undefined;
27
27
  endsAt?: string | null | undefined;
@@ -12,11 +12,11 @@ export declare const termsKeys: {
12
12
  export declare const useTermsList: (params?: ListTermsQuery) => import("@tanstack/react-query").UseQueryResult<{
13
13
  items: {
14
14
  code: string;
15
+ id: number;
16
+ version: string;
15
17
  title: string;
16
18
  content: string;
17
19
  isActive: boolean;
18
- id: number;
19
- version: string;
20
20
  createdAt: string;
21
21
  }[];
22
22
  total: number;
@@ -24,3 +24,16 @@ export declare const useTermsList: (params?: ListTermsQuery) => import("@tanstac
24
24
  limit: number;
25
25
  totalPages: number;
26
26
  }, Error>;
27
+ export declare const useChannelTerms: (channelUid: string) => import("@tanstack/react-query").UseQueryResult<{
28
+ code: string;
29
+ id: number;
30
+ version: string;
31
+ title: string;
32
+ content: string;
33
+ isActive: boolean;
34
+ createdAt: string;
35
+ }[], Error>;
36
+ export declare const useAgreeTerms: () => import("@tanstack/react-query").UseMutationResult<void, Error, {
37
+ termCodes: string[];
38
+ channelUid?: string;
39
+ }, unknown>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useTermsList = exports.termsKeys = void 0;
3
+ exports.useAgreeTerms = exports.useChannelTerms = exports.useTermsList = 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 = {
@@ -17,3 +17,19 @@ const useTermsList = (params) => {
17
17
  });
18
18
  };
19
19
  exports.useTermsList = useTermsList;
20
+ const useChannelTerms = (channelUid) => {
21
+ const client = (0, context_1.usePHCMS)();
22
+ return (0, react_query_1.useQuery)({
23
+ queryKey: [...exports.termsKeys.all, 'channel', channelUid],
24
+ queryFn: () => client.terms.listByChannel(channelUid),
25
+ enabled: !!channelUid,
26
+ });
27
+ };
28
+ exports.useChannelTerms = useChannelTerms;
29
+ const useAgreeTerms = () => {
30
+ const client = (0, context_1.usePHCMS)();
31
+ return (0, react_query_1.useMutation)({
32
+ mutationFn: (data) => client.terms.agree(data),
33
+ });
34
+ };
35
+ exports.useAgreeTerms = useAgreeTerms;
@@ -4,6 +4,7 @@ import { UpdateUserProfileRequest } from '@ph-cms/api-contract';
4
4
  * Typically used by a user to update their own profile.
5
5
  */
6
6
  export declare const useUpdateProfile: () => import("@tanstack/react-query").UseMutationResult<{
7
+ status: string;
7
8
  uid: string;
8
9
  email: string;
9
10
  username: string | null;
@@ -14,12 +15,25 @@ export declare const useUpdateProfile: () => import("@tanstack/react-query").Use
14
15
  phone_verified_at: string | null;
15
16
  locale: string;
16
17
  timezone: string;
17
- status: string;
18
18
  role: string[];
19
19
  profile_data: Record<string, any>;
20
20
  last_login_at: string | null;
21
21
  created_at: string;
22
22
  updated_at: string;
23
+ channel_agreements?: {
24
+ channel_uid: string | null;
25
+ is_fully_compliant: boolean;
26
+ agreements: {
27
+ code: string;
28
+ version: string;
29
+ title: string;
30
+ term_id: number;
31
+ is_agreed: boolean;
32
+ is_required: boolean;
33
+ is_latest: boolean;
34
+ agreed_at: string | null;
35
+ }[];
36
+ }[] | undefined;
23
37
  }, Error, {
24
38
  uid: string;
25
39
  data: UpdateUserProfileRequest | Record<string, any>;
@@ -14,7 +14,9 @@ export declare class AuthModule {
14
14
  */
15
15
  loginWithFirebase(data: FirebaseExchangeRequest): Promise<AuthResponse>;
16
16
  register(data: RegisterRequest): Promise<AuthResponse>;
17
- me(): Promise<UserDto>;
17
+ me(params?: {
18
+ channelUid?: string;
19
+ }): Promise<UserDto>;
18
20
  refresh(refreshToken: string): Promise<{
19
21
  accessToken: string;
20
22
  refreshToken: string;
@@ -47,8 +47,8 @@ class AuthModule {
47
47
  }
48
48
  return response;
49
49
  }
50
- async me() {
51
- return this.client.get('/api/auth/me');
50
+ async me(params) {
51
+ return this.client.get('/api/auth/me', { params });
52
52
  }
53
53
  async refresh(refreshToken) {
54
54
  return this.client.post('/api/auth/refresh', { refreshToken });
@@ -6,6 +6,7 @@ export declare class ContentModule {
6
6
  list(params: ListContentQuery): Promise<PagedContentListResponse>;
7
7
  listGeo(bounds: BoundsQuery): Promise<ContentDto[]>;
8
8
  get(uid: string): Promise<ContentDto>;
9
+ incrementView(uid: string): Promise<void>;
9
10
  create(data: CreateContentRequest): Promise<ContentDto>;
10
11
  update(uid: string, data: UpdateContentRequest): Promise<ContentDto>;
11
12
  delete(uid: string): Promise<void>;
@@ -26,6 +26,11 @@ class ContentModule {
26
26
  throw new errors_1.ValidationError("UID is required", []);
27
27
  return this.client.get(`/api/contents/${uid}`);
28
28
  }
29
+ async incrementView(uid) {
30
+ if (!uid)
31
+ throw new errors_1.ValidationError("UID is required", []);
32
+ await this.client.post(`/api/contents/${uid}/view`);
33
+ }
29
34
  async create(data) {
30
35
  const validation = api_contract_1.CreateContentSchema.safeParse(data);
31
36
  if (!validation.success) {
@@ -5,4 +5,9 @@ export declare class TermsModule {
5
5
  constructor(client: AxiosInstance);
6
6
  list(params?: ListTermsQuery): Promise<PagedTermListResponse>;
7
7
  get(id: number): Promise<TermDto>;
8
+ agree(data: {
9
+ termCodes: string[];
10
+ channelUid?: string;
11
+ }): Promise<void>;
12
+ listByChannel(channelUid: string): Promise<TermDto[]>;
8
13
  }
@@ -11,5 +11,11 @@ class TermsModule {
11
11
  async get(id) {
12
12
  return this.client.get(`/api/terms/${id}`);
13
13
  }
14
+ async agree(data) {
15
+ await this.client.post('/api/terms/agree', data);
16
+ }
17
+ async listByChannel(channelUid) {
18
+ return this.client.get(`/api/terms/channels/${channelUid}`);
19
+ }
14
20
  }
15
21
  exports.TermsModule = TermsModule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ph-cms/client-sdk",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "Unified PH-CMS Client SDK (React + Core)",
5
5
  "keywords": [],
6
6
  "license": "MIT",