@ph-cms/client-sdk 0.1.13 → 0.1.15

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.
@@ -1,4 +1,4 @@
1
- import { UpdateContentRequest, ListContentQuery, ContentDto, BoundsQuery } from '@ph-cms/api-contract';
1
+ import { UpdateContentRequest, ListContentQuery, ContentDto } from '@ph-cms/api-contract';
2
2
  export declare const contentKeys: {
3
3
  all: readonly ["contents"];
4
4
  lists: () => readonly ["contents", "list"];
@@ -20,13 +20,6 @@ export declare const contentKeys: {
20
20
  withDetail?: boolean | undefined;
21
21
  includeDeleted?: boolean | undefined;
22
22
  }];
23
- geoLists: () => readonly ["contents", "geo-list"];
24
- geoList: (bounds: BoundsQuery) => readonly ["contents", "geo-list", {
25
- minLat: number;
26
- maxLat: number;
27
- minLng: number;
28
- maxLng: number;
29
- }];
30
23
  details: () => readonly ["contents", "detail"];
31
24
  detail: (uid: string) => readonly ["contents", "detail", string];
32
25
  likes: () => readonly ["contents", "like"];
@@ -42,7 +35,6 @@ export declare const useContentList: (params: ListContentQuery, enabled?: boolea
42
35
  last: boolean;
43
36
  empty: boolean;
44
37
  }, Error>;
45
- export declare const useContentGeoList: (bounds: BoundsQuery) => import("@tanstack/react-query").UseQueryResult<ContentDto[], Error>;
46
38
  export declare const useContentDetail: (uid: string) => import("@tanstack/react-query").UseQueryResult<ContentDto, Error>;
47
39
  export declare const useIncrementView: () => import("@tanstack/react-query").UseMutationResult<void, Error, string, {
48
40
  previousDetail: ContentDto | undefined;
@@ -1,14 +1,12 @@
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.useContentGeoList = exports.useContentList = exports.contentKeys = void 0;
3
+ 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 = {
7
7
  all: ['contents'],
8
8
  lists: () => [...exports.contentKeys.all, 'list'],
9
9
  list: (params) => [...exports.contentKeys.lists(), params],
10
- geoLists: () => [...exports.contentKeys.all, 'geo-list'],
11
- geoList: (bounds) => [...exports.contentKeys.geoLists(), bounds],
12
10
  details: () => [...exports.contentKeys.all, 'detail'],
13
11
  detail: (uid) => [...exports.contentKeys.details(), uid],
14
12
  likes: () => [...exports.contentKeys.all, 'like'],
@@ -16,23 +14,19 @@ exports.contentKeys = {
16
14
  };
17
15
  const useContentList = (params, enabled = true) => {
18
16
  const client = (0, context_1.usePHCMS)();
17
+ const { channelUid } = (0, context_1.usePHCMSContext)();
18
+ const finalParams = {
19
+ channelUid: params.channelUid || channelUid,
20
+ ...params,
21
+ };
19
22
  return (0, react_query_1.useQuery)({
20
- queryKey: exports.contentKeys.list(params),
21
- queryFn: () => client.content.list(params),
23
+ queryKey: exports.contentKeys.list(finalParams),
24
+ queryFn: () => client.content.list(finalParams),
22
25
  staleTime: 1000 * 60, // 1 minute
23
26
  enabled,
24
27
  });
25
28
  };
26
29
  exports.useContentList = useContentList;
27
- const useContentGeoList = (bounds) => {
28
- const client = (0, context_1.usePHCMS)();
29
- return (0, react_query_1.useQuery)({
30
- queryKey: exports.contentKeys.geoList(bounds),
31
- queryFn: () => client.content.listGeo(bounds),
32
- enabled: !!(bounds.minLat && bounds.maxLat && bounds.minLng && bounds.maxLng),
33
- });
34
- };
35
- exports.useContentGeoList = useContentGeoList;
36
30
  const useContentDetail = (uid) => {
37
31
  const client = (0, context_1.usePHCMS)();
38
32
  return (0, react_query_1.useQuery)({
@@ -75,9 +69,13 @@ const useIncrementView = () => {
75
69
  exports.useIncrementView = useIncrementView;
76
70
  const useCreateContent = () => {
77
71
  const client = (0, context_1.usePHCMS)();
72
+ const { channelUid } = (0, context_1.usePHCMSContext)();
78
73
  const queryClient = (0, react_query_1.useQueryClient)();
79
74
  return (0, react_query_1.useMutation)({
80
- mutationFn: (data) => client.content.create(data),
75
+ mutationFn: (data) => client.content.create({
76
+ channelUid: data.channelUid || channelUid,
77
+ ...data,
78
+ }),
81
79
  onSuccess: () => {
82
80
  queryClient.invalidateQueries({ queryKey: exports.contentKeys.lists() });
83
81
  },
@@ -152,7 +150,6 @@ const useToggleLike = () => {
152
150
  onSettled: (data, error, uid) => {
153
151
  // Invalidate the lists so they fetch the latest liked status and like counts
154
152
  queryClient.invalidateQueries({ queryKey: exports.contentKeys.lists() });
155
- queryClient.invalidateQueries({ queryKey: exports.contentKeys.geoLists() });
156
153
  },
157
154
  });
158
155
  };
@@ -70,7 +70,7 @@ const context_1 = require("../context");
70
70
  */
71
71
  const useFirebaseAuthSync = (options) => {
72
72
  const { firebaseAuth, logoutOnFirebaseSignOut = true, onSyncSuccess, onSyncError, } = options;
73
- const { client, isAuthenticated, isLoading, refreshUser } = (0, context_1.usePHCMSContext)();
73
+ const { client, isAuthenticated, isLoading, refreshUser, channelUid } = (0, context_1.usePHCMSContext)();
74
74
  // Use refs for values that change frequently but should not re-trigger
75
75
  // the effect (which would tear down and re-create the Firebase listener).
76
76
  const isAuthenticatedRef = (0, react_1.useRef)(isAuthenticated);
@@ -106,7 +106,7 @@ const useFirebaseAuthSync = (options) => {
106
106
  setIsSyncing(true);
107
107
  try {
108
108
  const idToken = await fbUser.getIdToken();
109
- await client.auth.loginWithFirebase({ idToken });
109
+ await client.auth.loginWithFirebase({ idToken, channelUid });
110
110
  // loginWithFirebase stores the tokens in the provider.
111
111
  // Now refresh the context so `isAuthenticated` and `user` update.
112
112
  await refreshUser();
@@ -12,9 +12,13 @@ exports.stampTourKeys = {
12
12
  };
13
13
  const useCreateStampTour = () => {
14
14
  const client = (0, context_1.usePHCMS)();
15
+ const { channelUid } = (0, context_1.usePHCMSContext)();
15
16
  const queryClient = (0, react_query_1.useQueryClient)();
16
17
  return (0, react_query_1.useMutation)({
17
- mutationFn: (data) => client.content.createStampTour(data),
18
+ mutationFn: (data) => client.content.createStampTour({
19
+ channelUid: data.channelUid || channelUid,
20
+ ...data,
21
+ }),
18
22
  onSuccess: () => {
19
23
  // Invalidate content lists since a new tour is a content item
20
24
  queryClient.invalidateQueries({ queryKey: useContent_1.contentKeys.lists() });
@@ -1,4 +1,48 @@
1
1
  import { UpdateUserProfileRequest } from '@ph-cms/api-contract';
2
+ export declare const termsKeys: {
3
+ all: readonly ["terms"];
4
+ lists: () => readonly ["terms", "list"];
5
+ };
6
+ /**
7
+ * Access the current user profile and status.
8
+ */
9
+ export declare const useUser: () => {
10
+ data: {
11
+ status: string;
12
+ uid: string;
13
+ email: string;
14
+ username: string | null;
15
+ display_name: string;
16
+ avatar_url: string | null;
17
+ phone_number: string | null;
18
+ email_verified_at: string | null;
19
+ phone_verified_at: string | null;
20
+ locale: string;
21
+ timezone: string;
22
+ role: string[];
23
+ profile_data: Record<string, any>;
24
+ last_login_at: string | null;
25
+ created_at: string;
26
+ updated_at: string;
27
+ channel_agreements?: {
28
+ channel_uid: string | null;
29
+ is_fully_compliant: boolean;
30
+ agreements: {
31
+ code: string;
32
+ version: string;
33
+ title: string;
34
+ term_id: number;
35
+ is_agreed: boolean;
36
+ is_required: boolean;
37
+ is_latest: boolean;
38
+ agreed_at: string | null;
39
+ }[];
40
+ }[] | undefined;
41
+ } | null;
42
+ isLoading: boolean;
43
+ isAuthenticated: boolean;
44
+ error: boolean;
45
+ };
2
46
  /**
3
47
  * Hook to update a user's profile.
4
48
  * Typically used by a user to update their own profile.
@@ -38,3 +82,23 @@ export declare const useUpdateProfile: () => import("@tanstack/react-query").Use
38
82
  uid: string;
39
83
  data: UpdateUserProfileRequest | Record<string, any>;
40
84
  }, unknown>;
85
+ /**
86
+ * List terms required/available for the current channel.
87
+ */
88
+ export declare const useChannelTerms: () => import("@tanstack/react-query").UseQueryResult<{
89
+ code: string;
90
+ id: number;
91
+ version: string;
92
+ title: string;
93
+ content: string;
94
+ isActive: boolean;
95
+ createdAt: string;
96
+ isRequired?: boolean | undefined;
97
+ }[], Error>;
98
+ /**
99
+ * Submit term agreements for the current user.
100
+ */
101
+ export declare const useAgreeTerms: () => import("@tanstack/react-query").UseMutationResult<void, Error, {
102
+ termCodes: string[];
103
+ channelUid?: string;
104
+ }, unknown>;
@@ -1,8 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useUpdateProfile = void 0;
3
+ exports.useAgreeTerms = exports.useChannelTerms = exports.useUpdateProfile = exports.useUser = exports.termsKeys = void 0;
4
4
  const react_query_1 = require("@tanstack/react-query");
5
5
  const context_1 = require("../context");
6
+ exports.termsKeys = {
7
+ all: ['terms'],
8
+ lists: () => [...exports.termsKeys.all, 'list'],
9
+ };
10
+ /**
11
+ * Access the current user profile and status.
12
+ */
13
+ const useUser = () => {
14
+ const { user, isLoading, isAuthenticated, isError } = (0, context_1.usePHCMSContext)();
15
+ return { data: user, isLoading, isAuthenticated, error: isError };
16
+ };
17
+ exports.useUser = useUser;
6
18
  /**
7
19
  * Hook to update a user's profile.
8
20
  * Typically used by a user to update their own profile.
@@ -19,3 +31,29 @@ const useUpdateProfile = () => {
19
31
  });
20
32
  };
21
33
  exports.useUpdateProfile = useUpdateProfile;
34
+ /**
35
+ * List terms required/available for the current channel.
36
+ */
37
+ const useChannelTerms = () => {
38
+ const { client, channelUid } = (0, context_1.usePHCMSContext)();
39
+ return (0, react_query_1.useQuery)({
40
+ queryKey: [...exports.termsKeys.all, 'channel', channelUid],
41
+ queryFn: () => client.terms.listByChannel(channelUid),
42
+ enabled: !!channelUid,
43
+ });
44
+ };
45
+ exports.useChannelTerms = useChannelTerms;
46
+ /**
47
+ * Submit term agreements for the current user.
48
+ */
49
+ const useAgreeTerms = () => {
50
+ const client = (0, context_1.usePHCMS)();
51
+ const { channelUid } = (0, context_1.usePHCMSContext)();
52
+ return (0, react_query_1.useMutation)({
53
+ mutationFn: (data) => client.terms.agree({
54
+ channelUid: data.channelUid || channelUid,
55
+ ...data,
56
+ }),
57
+ });
58
+ };
59
+ exports.useAgreeTerms = useAgreeTerms;
package/dist/index.d.ts CHANGED
@@ -13,11 +13,9 @@ export * from './modules/terms';
13
13
  export * from './modules/user';
14
14
  export * from './context';
15
15
  export * from './hooks/useAuth';
16
- export * from './hooks/useChannel';
17
16
  export * from './hooks/useContent';
18
17
  export * from './hooks/useStampTour';
19
18
  export * from './hooks/useFirebaseAuthSync';
20
19
  export * from './hooks/useMedia';
21
- export * from './hooks/useTerms';
22
20
  export * from './hooks/useUser';
23
21
  export * from './types';
package/dist/index.js CHANGED
@@ -29,11 +29,9 @@ __exportStar(require("./modules/terms"), exports);
29
29
  __exportStar(require("./modules/user"), exports);
30
30
  __exportStar(require("./context"), exports);
31
31
  __exportStar(require("./hooks/useAuth"), exports);
32
- __exportStar(require("./hooks/useChannel"), exports);
33
32
  __exportStar(require("./hooks/useContent"), exports);
34
33
  __exportStar(require("./hooks/useStampTour"), exports);
35
34
  __exportStar(require("./hooks/useFirebaseAuthSync"), exports);
36
35
  __exportStar(require("./hooks/useMedia"), exports);
37
- __exportStar(require("./hooks/useTerms"), exports);
38
36
  __exportStar(require("./hooks/useUser"), exports);
39
37
  __exportStar(require("./types"), exports);
@@ -1,4 +1,4 @@
1
- import { AuthResponse, FirebaseExchangeRequest, LoginRequest, RegisterRequest, UserDto } from "@ph-cms/api-contract";
1
+ import { AuthResponse, FirebaseExchangeRequest, LoginRequest, RegisterRequest, UserDto, AnonymousLoginRequest } from "@ph-cms/api-contract";
2
2
  import { AxiosInstance } from "axios";
3
3
  import { AuthProvider } from "../auth/interfaces";
4
4
  export declare class AuthModule {
@@ -16,10 +16,18 @@ export declare class AuthModule {
16
16
  register(data: RegisterRequest): Promise<AuthResponse>;
17
17
  me(params?: {
18
18
  channelUid?: string;
19
+ channelSlug?: string;
19
20
  }): Promise<UserDto>;
20
21
  refresh(refreshToken: string): Promise<{
21
22
  accessToken: string;
22
23
  refreshToken: string;
23
24
  }>;
25
+ loginAnonymous(data: AnonymousLoginRequest): Promise<AuthResponse>;
26
+ upgradeAnonymous(data: {
27
+ email: string;
28
+ password: string;
29
+ display_name?: string;
30
+ username?: string;
31
+ }): Promise<UserDto>;
24
32
  logout(): Promise<void>;
25
33
  }
@@ -53,6 +53,20 @@ class AuthModule {
53
53
  async refresh(refreshToken) {
54
54
  return this.client.post('/api/auth/refresh', { refreshToken });
55
55
  }
56
+ async loginAnonymous(data) {
57
+ const validation = api_contract_1.AnonymousLoginSchema.safeParse(data);
58
+ if (!validation.success) {
59
+ throw new errors_1.ValidationError("Invalid anonymous login data", validation.error.errors);
60
+ }
61
+ const response = await this.client.post('/api/auth/anonymous', data);
62
+ if (this.provider) {
63
+ this.provider.setTokens(response.accessToken, response.refreshToken);
64
+ }
65
+ return response;
66
+ }
67
+ async upgradeAnonymous(data) {
68
+ return this.client.post('/api/auth/anonymous/upgrade', data);
69
+ }
56
70
  async logout() {
57
71
  if (this.provider) {
58
72
  await this.provider.logout();
@@ -1,12 +1,10 @@
1
- import { ChannelDto, CheckHierarchyQuery, CreateChannelDto, ListChannelQuery, PagedChannelListResponse } from "@ph-cms/api-contract";
1
+ import { ChannelDto, CheckHierarchyQuery } from "@ph-cms/api-contract";
2
2
  import { AxiosInstance } from "axios";
3
3
  export declare class ChannelModule {
4
4
  private client;
5
5
  constructor(client: AxiosInstance);
6
- list(params: ListChannelQuery): Promise<PagedChannelListResponse>;
7
6
  getByUid(uid: string): Promise<ChannelDto>;
8
7
  getBySlug(slug: string): Promise<ChannelDto>;
9
- create(data: CreateChannelDto): Promise<ChannelDto>;
10
8
  update(uid: string, data: any): Promise<ChannelDto>;
11
9
  checkHierarchy(params: CheckHierarchyQuery): Promise<{
12
10
  allowed: boolean;
@@ -7,13 +7,6 @@ class ChannelModule {
7
7
  constructor(client) {
8
8
  this.client = client;
9
9
  }
10
- async list(params) {
11
- const validation = api_contract_1.ListChannelQuerySchema.safeParse(params);
12
- if (!validation.success) {
13
- throw new errors_1.ValidationError("Invalid list channel params", validation.error.errors);
14
- }
15
- return this.client.get('/api/channels', { params });
16
- }
17
10
  async getByUid(uid) {
18
11
  if (!uid)
19
12
  throw new errors_1.ValidationError("UID is required", []);
@@ -24,13 +17,6 @@ class ChannelModule {
24
17
  throw new errors_1.ValidationError("Slug is required", []);
25
18
  return this.client.get(`/api/channels/s/${slug}`);
26
19
  }
27
- async create(data) {
28
- const validation = api_contract_1.CreateChannelSchema.safeParse(data);
29
- if (!validation.success) {
30
- throw new errors_1.ValidationError("Invalid create channel params", validation.error.errors);
31
- }
32
- return this.client.post('/api/channels', data);
33
- }
34
20
  async update(uid, data) {
35
21
  // TODO: Add schema validation for update channel
36
22
  if (!uid)
@@ -1,10 +1,9 @@
1
- import { BoundsQuery, CollectStampRequest, ContentDto, CreateContentRequest, CreateStampTourRequest, LikeStatusResponse, ListContentQuery, PagedContentListResponse, StampStatusDto, ToggleLikeResponse, TourStatsDto, UpdateContentRequest, UpdateStampTourRequest } from "@ph-cms/api-contract";
1
+ import { CollectStampRequest, ContentDto, CreateContentRequest, CreateStampTourRequest, LikeStatusResponse, ListContentQuery, PagedContentListResponse, StampStatusDto, ToggleLikeResponse, TourStatsDto, UpdateContentRequest, UpdateStampTourRequest } from "@ph-cms/api-contract";
2
2
  import { AxiosInstance } from "axios";
3
3
  export declare class ContentModule {
4
4
  private client;
5
5
  constructor(client: AxiosInstance);
6
6
  list(params: ListContentQuery): Promise<PagedContentListResponse>;
7
- listGeo(bounds: BoundsQuery): Promise<ContentDto[]>;
8
7
  get(uid: string): Promise<ContentDto>;
9
8
  incrementView(uid: string): Promise<void>;
10
9
  create(data: CreateContentRequest): Promise<ContentDto>;
@@ -14,13 +14,6 @@ class ContentModule {
14
14
  }
15
15
  return this.client.get('/api/contents', { params });
16
16
  }
17
- async listGeo(bounds) {
18
- const validation = api_contract_1.BoundsQuerySchema.safeParse(bounds);
19
- if (!validation.success) {
20
- throw new errors_1.ValidationError("Invalid bounds params", validation.error.errors);
21
- }
22
- return this.client.get('/api/contents/geo', { params: bounds });
23
- }
24
17
  async get(uid) {
25
18
  if (!uid)
26
19
  throw new errors_1.ValidationError("UID is required", []);
@@ -1,9 +1,8 @@
1
1
  import { AxiosInstance } from "axios";
2
- import { TermDto, ListTermsQuery, PagedTermListResponse } from "@ph-cms/api-contract";
2
+ import { TermDto } from "@ph-cms/api-contract";
3
3
  export declare class TermsModule {
4
4
  private client;
5
5
  constructor(client: AxiosInstance);
6
- list(params?: ListTermsQuery): Promise<PagedTermListResponse>;
7
6
  get(id: number): Promise<TermDto>;
8
7
  agree(data: {
9
8
  termCodes: string[];
@@ -5,9 +5,6 @@ class TermsModule {
5
5
  constructor(client) {
6
6
  this.client = client;
7
7
  }
8
- async list(params) {
9
- return this.client.get('/api/terms', { params });
10
- }
11
8
  async get(id) {
12
9
  return this.client.get(`/api/terms/${id}`);
13
10
  }
package/dist/types.d.ts CHANGED
@@ -6,11 +6,11 @@ export type { FirebaseAuthSyncProps, UseFirebaseAuthSyncOptions, UseFirebaseAuth
6
6
  export type { StampAvailability, CheckStampAvailabilityParams } from './hooks/useStampTour';
7
7
  export type { AuthResponse, FirebaseExchangeRequest, LoginRequest, RefreshTokenRequest, RegisterRequest } from '@ph-cms/api-contract';
8
8
  export type { UserDto } from '@ph-cms/api-contract';
9
- export type { ChannelDto, CheckHierarchyQuery, CreateChannelDto, ListChannelQuery, PagedChannelListResponse } from '@ph-cms/api-contract';
9
+ export type { ChannelDto, CheckHierarchyQuery } from '@ph-cms/api-contract';
10
10
  export type { ContentDto, ContentMediaDto, CreateContentRequest, ListContentQuery, PagedContentListResponse, UpdateContentRequest } from '@ph-cms/api-contract';
11
11
  export type { HierarchySetDto } from '@ph-cms/api-contract';
12
12
  export type { PermissionPolicySetDto } from '@ph-cms/api-contract';
13
- export type { ListTermsQuery, PagedTermListResponse, TermDto } from '@ph-cms/api-contract';
14
- export type { BoundsQuery, GeoJSON } from '@ph-cms/api-contract';
13
+ export type { TermDto } from '@ph-cms/api-contract';
14
+ export type { GeoJSON } from '@ph-cms/api-contract';
15
15
  export type { MediaUploadTicketBatchRequest, MediaUploadTicketBatchResponse, MediaUploadTicketRequest, MediaUploadTicketResponse } from '@ph-cms/api-contract';
16
16
  export type { PagedResponse } from '@ph-cms/api-contract';
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@ph-cms/client-sdk",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Unified PH-CMS Client SDK (React + Core)",
5
5
  "keywords": [],
6
6
  "license": "MIT",
7
7
  "author": "854dev",
8
8
  "type": "commonjs",
9
+ "bin": {
10
+ "ph-cms-client": "./bin/cli.js"
11
+ },
9
12
  "exports": {
10
13
  ".": {
11
14
  "types": "./dist/index.d.ts",
@@ -17,11 +20,12 @@
17
20
  "types": "dist/index.d.ts",
18
21
  "files": [
19
22
  "dist",
23
+ "bin",
20
24
  "README.md",
21
25
  "LICENSE"
22
26
  ],
23
27
  "dependencies": {
24
- "@ph-cms/api-contract": "^0.1.5",
28
+ "@ph-cms/api-contract": "^0.1.6",
25
29
  "@tanstack/react-query": "^5.0.0",
26
30
  "axios": "^1.6.0",
27
31
  "zod": "^3.22.4"
@@ -1,65 +0,0 @@
1
- import { ListChannelQuery } from '@ph-cms/api-contract';
2
- export declare const channelKeys: {
3
- all: readonly ["channels"];
4
- lists: () => readonly ["channels", "list"];
5
- list: (params: ListChannelQuery) => readonly ["channels", "list", {
6
- status?: string | undefined;
7
- limit?: number | undefined;
8
- offset?: number | undefined;
9
- ownerUid?: string | undefined;
10
- }];
11
- };
12
- export declare const useChannelList: (params: ListChannelQuery) => import("@tanstack/react-query").UseQueryResult<{
13
- items: {
14
- status: string;
15
- uid: string;
16
- created_at: string;
17
- updated_at: string;
18
- name: string;
19
- description: string | null;
20
- slug: string;
21
- hierarchySet: {
22
- uid: string;
23
- created_at: string;
24
- updated_at: string;
25
- name: string;
26
- description: string | null;
27
- } | null;
28
- permissionPolicySet: {
29
- uid: string;
30
- name: string;
31
- description: string | null;
32
- } | null;
33
- }[];
34
- total: number;
35
- page: number;
36
- limit: number;
37
- totalPages: number;
38
- }, Error>;
39
- export declare const useCreateChannel: () => import("@tanstack/react-query").UseMutationResult<{
40
- status: string;
41
- uid: string;
42
- created_at: string;
43
- updated_at: string;
44
- name: string;
45
- description: string | null;
46
- slug: string;
47
- hierarchySet: {
48
- uid: string;
49
- created_at: string;
50
- updated_at: string;
51
- name: string;
52
- description: string | null;
53
- } | null;
54
- permissionPolicySet: {
55
- uid: string;
56
- name: string;
57
- description: string | null;
58
- } | null;
59
- }, Error, {
60
- name: string;
61
- slug: string;
62
- hierarchySetUid: string;
63
- description?: string | undefined;
64
- permissionPolicySetUid?: string | undefined;
65
- }, unknown>;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useCreateChannel = exports.useChannelList = exports.channelKeys = void 0;
4
- const react_query_1 = require("@tanstack/react-query");
5
- const context_1 = require("../context");
6
- exports.channelKeys = {
7
- all: ['channels'],
8
- lists: () => [...exports.channelKeys.all, 'list'],
9
- list: (params) => [...exports.channelKeys.lists(), params],
10
- };
11
- const useChannelList = (params) => {
12
- const client = (0, context_1.usePHCMS)();
13
- return (0, react_query_1.useQuery)({
14
- queryKey: exports.channelKeys.list(params),
15
- queryFn: () => client.channel.list(params),
16
- staleTime: 1000 * 60 * 5, // 5 minutes
17
- });
18
- };
19
- exports.useChannelList = useChannelList;
20
- const useCreateChannel = () => {
21
- const client = (0, context_1.usePHCMS)();
22
- const queryClient = (0, react_query_1.useQueryClient)();
23
- return (0, react_query_1.useMutation)({
24
- mutationFn: (data) => client.channel.create(data),
25
- onSuccess: () => {
26
- queryClient.invalidateQueries({ queryKey: exports.channelKeys.lists() });
27
- },
28
- });
29
- };
30
- exports.useCreateChannel = useCreateChannel;
@@ -1,41 +0,0 @@
1
- import { ListTermsQuery } from '@ph-cms/api-contract';
2
- export declare const termsKeys: {
3
- all: readonly ["terms"];
4
- lists: () => readonly ["terms", "list"];
5
- list: (params?: ListTermsQuery) => readonly ["terms", "list", {
6
- code?: string | undefined;
7
- limit?: number | undefined;
8
- isActive?: boolean | undefined;
9
- offset?: number | undefined;
10
- } | undefined];
11
- };
12
- export declare const useTermsList: (params?: ListTermsQuery) => import("@tanstack/react-query").UseQueryResult<{
13
- items: {
14
- code: string;
15
- id: number;
16
- version: string;
17
- title: string;
18
- content: string;
19
- isActive: boolean;
20
- createdAt: string;
21
- isRequired?: boolean | undefined;
22
- }[];
23
- total: number;
24
- page: number;
25
- limit: number;
26
- totalPages: number;
27
- }, Error>;
28
- export declare const useChannelTerms: (channelUid: string) => import("@tanstack/react-query").UseQueryResult<{
29
- code: string;
30
- id: number;
31
- version: string;
32
- title: string;
33
- content: string;
34
- isActive: boolean;
35
- createdAt: string;
36
- isRequired?: boolean | undefined;
37
- }[], Error>;
38
- export declare const useAgreeTerms: () => import("@tanstack/react-query").UseMutationResult<void, Error, {
39
- termCodes: string[];
40
- channelUid?: string;
41
- }, unknown>;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useAgreeTerms = exports.useChannelTerms = exports.useTermsList = exports.termsKeys = void 0;
4
- const react_query_1 = require("@tanstack/react-query");
5
- const context_1 = require("../context");
6
- exports.termsKeys = {
7
- all: ['terms'],
8
- lists: () => [...exports.termsKeys.all, 'list'],
9
- list: (params) => [...exports.termsKeys.lists(), params],
10
- };
11
- const useTermsList = (params) => {
12
- const client = (0, context_1.usePHCMS)();
13
- return (0, react_query_1.useQuery)({
14
- queryKey: exports.termsKeys.list(params),
15
- queryFn: () => client.terms.list(params),
16
- staleTime: 1000 * 60 * 60, // 1 hour
17
- });
18
- };
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;