@ph-cms/client-sdk-admin 0.1.1

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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/dist/client.d.ts +17 -0
  3. package/dist/client.js +22 -0
  4. package/dist/context.d.ts +10 -0
  5. package/dist/context.js +53 -0
  6. package/dist/errors.d.ts +1 -0
  7. package/dist/errors.js +7 -0
  8. package/dist/hooks/useDashboard.d.ts +16 -0
  9. package/dist/hooks/useDashboard.js +13 -0
  10. package/dist/hooks/useHierarchy.d.ts +34 -0
  11. package/dist/hooks/useHierarchy.js +31 -0
  12. package/dist/hooks/usePolicy.d.ts +23 -0
  13. package/dist/hooks/usePolicy.js +19 -0
  14. package/dist/hooks/useSystem.d.ts +17 -0
  15. package/dist/hooks/useSystem.js +29 -0
  16. package/dist/hooks/useTerms.d.ts +26 -0
  17. package/dist/hooks/useTerms.js +19 -0
  18. package/dist/hooks/useUser.d.ts +108 -0
  19. package/dist/hooks/useUser.js +66 -0
  20. package/dist/index.d.ts +15 -0
  21. package/dist/index.js +35 -0
  22. package/dist/modules/dashboard.d.ts +7 -0
  23. package/dist/modules/dashboard.js +12 -0
  24. package/dist/modules/hierarchy.d.ts +14 -0
  25. package/dist/modules/hierarchy.js +33 -0
  26. package/dist/modules/policy.d.ts +11 -0
  27. package/dist/modules/policy.js +24 -0
  28. package/dist/modules/system.d.ts +21 -0
  29. package/dist/modules/system.js +24 -0
  30. package/dist/modules/terms.d.ts +11 -0
  31. package/dist/modules/terms.js +21 -0
  32. package/dist/modules/user.d.ts +11 -0
  33. package/dist/modules/user.js +44 -0
  34. package/package.json +42 -0
  35. package/src/client.ts +28 -0
  36. package/src/context.tsx +35 -0
  37. package/src/errors.ts +1 -0
  38. package/src/hooks/useDashboard.ts +10 -0
  39. package/src/hooks/useHierarchy.ts +30 -0
  40. package/src/hooks/usePolicy.ts +18 -0
  41. package/src/hooks/useSystem.ts +26 -0
  42. package/src/hooks/useTerms.ts +18 -0
  43. package/src/hooks/useUser.ts +69 -0
  44. package/src/index.ts +17 -0
  45. package/src/modules/dashboard.ts +10 -0
  46. package/src/modules/hierarchy.ts +38 -0
  47. package/src/modules/policy.ts +26 -0
  48. package/src/modules/system.ts +23 -0
  49. package/src/modules/terms.ts +23 -0
  50. package/src/modules/user.ts +47 -0
  51. package/tsconfig.json +15 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PH-CMS contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,17 @@
1
+ import { PHCMSClient } from "@ph-cms/client-sdk";
2
+ import { DashboardModule } from "./modules/dashboard";
3
+ import { HierarchyModule } from "./modules/hierarchy";
4
+ import { PolicyModule } from "./modules/policy";
5
+ import { SystemModule } from "./modules/system";
6
+ import { UserModule } from "./modules/user";
7
+ import { TermsModule } from "./modules/terms";
8
+ export declare class PHCMSAdminClient {
9
+ readonly base: PHCMSClient;
10
+ readonly dashboard: DashboardModule;
11
+ readonly hierarchy: HierarchyModule;
12
+ readonly policy: PolicyModule;
13
+ readonly system: SystemModule;
14
+ readonly user: UserModule;
15
+ readonly terms: TermsModule;
16
+ constructor(baseClient: PHCMSClient);
17
+ }
package/dist/client.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PHCMSAdminClient = void 0;
4
+ const dashboard_1 = require("./modules/dashboard");
5
+ const hierarchy_1 = require("./modules/hierarchy");
6
+ const policy_1 = require("./modules/policy");
7
+ const system_1 = require("./modules/system");
8
+ const user_1 = require("./modules/user");
9
+ const terms_1 = require("./modules/terms");
10
+ class PHCMSAdminClient {
11
+ constructor(baseClient) {
12
+ this.base = baseClient;
13
+ const axios = baseClient.axiosInstance;
14
+ this.dashboard = new dashboard_1.DashboardModule(axios);
15
+ this.hierarchy = new hierarchy_1.HierarchyModule(axios);
16
+ this.policy = new policy_1.PolicyModule(axios);
17
+ this.system = new system_1.SystemModule(axios);
18
+ this.user = new user_1.UserModule(axios);
19
+ this.terms = new terms_1.TermsModule(axios);
20
+ }
21
+ }
22
+ exports.PHCMSAdminClient = PHCMSAdminClient;
@@ -0,0 +1,10 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { QueryClient } from '@tanstack/react-query';
3
+ import { PHCMSAdminClient } from './client';
4
+ export interface PHCMSAdminProviderProps {
5
+ client: PHCMSAdminClient;
6
+ queryClient?: QueryClient;
7
+ children: ReactNode;
8
+ }
9
+ export declare const PHCMSAdminProvider: React.FC<PHCMSAdminProviderProps>;
10
+ export declare const usePHCMSAdmin: () => PHCMSAdminClient;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.usePHCMSAdmin = exports.PHCMSAdminProvider = void 0;
37
+ const react_1 = __importStar(require("react"));
38
+ const react_query_1 = require("@tanstack/react-query");
39
+ const PHCMSAdminContext = (0, react_1.createContext)(null);
40
+ const PHCMSAdminProvider = ({ client, queryClient, children }) => {
41
+ const internalQueryClient = (0, react_1.useMemo)(() => queryClient ?? new react_query_1.QueryClient(), [queryClient]);
42
+ return (react_1.default.createElement(PHCMSAdminContext.Provider, { value: { client } },
43
+ react_1.default.createElement(react_query_1.QueryClientProvider, { client: internalQueryClient }, children)));
44
+ };
45
+ exports.PHCMSAdminProvider = PHCMSAdminProvider;
46
+ const usePHCMSAdmin = () => {
47
+ const context = (0, react_1.useContext)(PHCMSAdminContext);
48
+ if (!context) {
49
+ throw new Error('usePHCMSAdmin must be used within a PHCMSAdminProvider');
50
+ }
51
+ return context.client;
52
+ };
53
+ exports.usePHCMSAdmin = usePHCMSAdmin;
@@ -0,0 +1 @@
1
+ export { PHCMSError, ValidationError, ApiError } from '@ph-cms/client-sdk';
package/dist/errors.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiError = exports.ValidationError = exports.PHCMSError = void 0;
4
+ var client_sdk_1 = require("@ph-cms/client-sdk");
5
+ Object.defineProperty(exports, "PHCMSError", { enumerable: true, get: function () { return client_sdk_1.PHCMSError; } });
6
+ Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return client_sdk_1.ValidationError; } });
7
+ Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return client_sdk_1.ApiError; } });
@@ -0,0 +1,16 @@
1
+ export declare const useDashboard: () => import("@tanstack/react-query").UseQueryResult<{
2
+ stats: {
3
+ totalUsers: number;
4
+ totalChannels: number;
5
+ totalContents: number;
6
+ newUsersToday: number;
7
+ newContentsToday: number;
8
+ };
9
+ recentActivities: {
10
+ type: "user" | "channel" | "content";
11
+ id: number;
12
+ action: string;
13
+ title: string;
14
+ timestamp: string;
15
+ }[];
16
+ }, Error>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useDashboard = void 0;
4
+ const react_query_1 = require("@tanstack/react-query");
5
+ const context_1 = require("../context");
6
+ const useDashboard = () => {
7
+ const client = (0, context_1.usePHCMSAdmin)();
8
+ return (0, react_query_1.useQuery)({
9
+ queryKey: ['dashboard', 'stats'],
10
+ queryFn: () => client.dashboard.getStats(),
11
+ });
12
+ };
13
+ exports.useDashboard = useDashboard;
@@ -0,0 +1,34 @@
1
+ import { ListHierarchyQuery } from '@ph-cms/api-contract-admin';
2
+ export declare const hierarchyKeys: {
3
+ all: readonly ["hierarchy"];
4
+ lists: () => readonly ["hierarchy", "list"];
5
+ list: (params?: ListHierarchyQuery) => readonly ["hierarchy", "list", {
6
+ limit?: number | undefined;
7
+ offset?: number | undefined;
8
+ } | undefined];
9
+ items: () => readonly ["hierarchy", "items"];
10
+ itemList: (setUid: string) => readonly ["hierarchy", "items", string];
11
+ };
12
+ export declare const useHierarchyList: (params?: ListHierarchyQuery) => import("@tanstack/react-query").UseQueryResult<{
13
+ items: {
14
+ name: string;
15
+ created_at: string;
16
+ updated_at: string;
17
+ uid: string;
18
+ description: string | null;
19
+ }[];
20
+ total: number;
21
+ page: number;
22
+ limit: number;
23
+ totalPages: number;
24
+ }, Error>;
25
+ export declare const useHierarchyItems: (setUid?: string, enabled?: boolean) => import("@tanstack/react-query").UseQueryResult<{
26
+ created_at: string;
27
+ uid: string;
28
+ description: string | null;
29
+ setUid: string;
30
+ parent_type: string | null;
31
+ child_type: string;
32
+ is_root: boolean;
33
+ is_geo: boolean;
34
+ }[], Error>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useHierarchyItems = exports.useHierarchyList = exports.hierarchyKeys = void 0;
4
+ const react_query_1 = require("@tanstack/react-query");
5
+ const context_1 = require("../context");
6
+ exports.hierarchyKeys = {
7
+ all: ['hierarchy'],
8
+ lists: () => [...exports.hierarchyKeys.all, 'list'],
9
+ list: (params) => [...exports.hierarchyKeys.lists(), params],
10
+ items: () => [...exports.hierarchyKeys.all, 'items'],
11
+ itemList: (setUid) => [...exports.hierarchyKeys.items(), setUid],
12
+ };
13
+ const useHierarchyList = (params) => {
14
+ const client = (0, context_1.usePHCMSAdmin)();
15
+ return (0, react_query_1.useQuery)({
16
+ queryKey: exports.hierarchyKeys.list(params),
17
+ queryFn: () => client.hierarchy.list(params),
18
+ staleTime: 1000 * 60 * 60, // 1 hour
19
+ });
20
+ };
21
+ exports.useHierarchyList = useHierarchyList;
22
+ const useHierarchyItems = (setUid, enabled = true) => {
23
+ const client = (0, context_1.usePHCMSAdmin)();
24
+ return (0, react_query_1.useQuery)({
25
+ queryKey: exports.hierarchyKeys.itemList(setUid || ''),
26
+ queryFn: () => client.hierarchy.listItems(setUid || ''),
27
+ staleTime: 1000 * 60 * 60, // 1 hour
28
+ enabled: enabled && !!setUid,
29
+ });
30
+ };
31
+ exports.useHierarchyItems = useHierarchyItems;
@@ -0,0 +1,23 @@
1
+ import { ListPolicyQuery } from '@ph-cms/api-contract-admin';
2
+ export declare const policyKeys: {
3
+ all: readonly ["policy"];
4
+ lists: () => readonly ["policy", "list"];
5
+ list: (params?: ListPolicyQuery) => readonly ["policy", "list", {
6
+ limit?: number | undefined;
7
+ offset?: number | undefined;
8
+ } | undefined];
9
+ };
10
+ export declare const usePolicyList: (params?: ListPolicyQuery) => import("@tanstack/react-query").UseQueryResult<{
11
+ items: {
12
+ name: string;
13
+ created_at: string;
14
+ updated_at: string;
15
+ uid: string;
16
+ description: string | null;
17
+ policy: Record<string, any>;
18
+ }[];
19
+ total: number;
20
+ page: number;
21
+ limit: number;
22
+ totalPages: number;
23
+ }, Error>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePolicyList = exports.policyKeys = void 0;
4
+ const react_query_1 = require("@tanstack/react-query");
5
+ const context_1 = require("../context");
6
+ exports.policyKeys = {
7
+ all: ['policy'],
8
+ lists: () => [...exports.policyKeys.all, 'list'],
9
+ list: (params) => [...exports.policyKeys.lists(), params],
10
+ };
11
+ const usePolicyList = (params) => {
12
+ const client = (0, context_1.usePHCMSAdmin)();
13
+ return (0, react_query_1.useQuery)({
14
+ queryKey: exports.policyKeys.list(params),
15
+ queryFn: () => client.policy.list(params),
16
+ staleTime: 1000 * 60 * 60, // 1 hour
17
+ });
18
+ };
19
+ exports.usePolicyList = usePolicyList;
@@ -0,0 +1,17 @@
1
+ export declare const useDbTables: () => import("@tanstack/react-query").UseQueryResult<{
2
+ name: string;
3
+ columns: string[];
4
+ }[], Error>;
5
+ export declare const useExecuteQuery: () => import("@tanstack/react-query").UseMutationResult<{
6
+ rows: any[];
7
+ fields: string[];
8
+ rowCount: number;
9
+ }, Error, string, unknown>;
10
+ export declare const useTableData: (tableName: string, page?: number, limit?: number) => import("@tanstack/react-query").UseQueryResult<{
11
+ rows: any[];
12
+ fields: string[];
13
+ page: number;
14
+ limit: number;
15
+ total: number;
16
+ totalPages: number;
17
+ }, Error>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTableData = exports.useExecuteQuery = exports.useDbTables = void 0;
4
+ const react_query_1 = require("@tanstack/react-query");
5
+ const context_1 = require("../context");
6
+ const useDbTables = () => {
7
+ const sdk = (0, context_1.usePHCMSAdmin)();
8
+ return (0, react_query_1.useQuery)({
9
+ queryKey: ['db-tables'],
10
+ queryFn: () => sdk.system.getDbTables(),
11
+ });
12
+ };
13
+ exports.useDbTables = useDbTables;
14
+ const useExecuteQuery = () => {
15
+ const sdk = (0, context_1.usePHCMSAdmin)();
16
+ return (0, react_query_1.useMutation)({
17
+ mutationFn: (sql) => sdk.system.executeQuery(sql),
18
+ });
19
+ };
20
+ exports.useExecuteQuery = useExecuteQuery;
21
+ const useTableData = (tableName, page = 1, limit = 20) => {
22
+ const sdk = (0, context_1.usePHCMSAdmin)();
23
+ return (0, react_query_1.useQuery)({
24
+ queryKey: ['table-data', tableName, page, limit],
25
+ queryFn: () => sdk.system.getTableData(tableName, page, limit),
26
+ enabled: !!tableName,
27
+ });
28
+ };
29
+ exports.useTableData = useTableData;
@@ -0,0 +1,26 @@
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
+ offset?: number | undefined;
9
+ isActive?: boolean | undefined;
10
+ } | undefined];
11
+ };
12
+ export declare const useTermsList: (params?: ListTermsQuery) => import("@tanstack/react-query").UseQueryResult<{
13
+ items: {
14
+ code: string;
15
+ title: string;
16
+ content: string;
17
+ id: number;
18
+ version: string;
19
+ isActive: boolean;
20
+ createdAt: string;
21
+ }[];
22
+ total: number;
23
+ page: number;
24
+ limit: number;
25
+ totalPages: number;
26
+ }, Error>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ 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.usePHCMSAdmin)();
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;
@@ -0,0 +1,108 @@
1
+ import { ListUserQuery, UpdateUserRequest } from '@ph-cms/api-contract-admin';
2
+ export declare const userKeys: {
3
+ all: readonly ["users"];
4
+ lists: () => readonly ["users", "list"];
5
+ list: (params: ListUserQuery) => readonly ["users", "list", {
6
+ limit: number;
7
+ offset: number;
8
+ status?: string | undefined;
9
+ role?: string | undefined;
10
+ searchKeyword?: string | undefined;
11
+ includeDeleted?: boolean | undefined;
12
+ orderBy?: "created_at" | "updated_at" | "username" | "display_name" | undefined;
13
+ orderDir?: "asc" | "desc" | undefined;
14
+ }];
15
+ details: () => readonly ["users", "detail"];
16
+ detail: (uid: string) => readonly ["users", "detail", string];
17
+ };
18
+ export declare const useUserList: (params: ListUserQuery) => import("@tanstack/react-query").UseQueryResult<{
19
+ items: {
20
+ uid: string;
21
+ email: string;
22
+ username: string | null;
23
+ display_name: string;
24
+ avatar_url: string | null;
25
+ phone_number: string | null;
26
+ email_verified_at: string | null;
27
+ phone_verified_at: string | null;
28
+ locale: string;
29
+ timezone: string;
30
+ status: string;
31
+ role: string[];
32
+ profile_data: Record<string, any>;
33
+ last_login_at: string | null;
34
+ created_at: string;
35
+ updated_at: string;
36
+ }[];
37
+ total: number;
38
+ page: number;
39
+ limit: number;
40
+ totalPages: number;
41
+ }, Error>;
42
+ export declare const useUserDetail: (uid: string) => import("@tanstack/react-query").UseQueryResult<{
43
+ uid: string;
44
+ email: string;
45
+ username: string | null;
46
+ display_name: string;
47
+ avatar_url: string | null;
48
+ phone_number: string | null;
49
+ email_verified_at: string | null;
50
+ phone_verified_at: string | null;
51
+ locale: string;
52
+ timezone: string;
53
+ status: string;
54
+ role: string[];
55
+ profile_data: Record<string, any>;
56
+ last_login_at: string | null;
57
+ created_at: string;
58
+ updated_at: string;
59
+ }, Error>;
60
+ export declare const useUpdateUser: () => import("@tanstack/react-query").UseMutationResult<{
61
+ uid: string;
62
+ email: string;
63
+ username: string | null;
64
+ display_name: string;
65
+ avatar_url: string | null;
66
+ phone_number: string | null;
67
+ email_verified_at: string | null;
68
+ phone_verified_at: string | null;
69
+ locale: string;
70
+ timezone: string;
71
+ status: string;
72
+ role: string[];
73
+ profile_data: Record<string, any>;
74
+ last_login_at: string | null;
75
+ created_at: string;
76
+ updated_at: string;
77
+ }, Error, {
78
+ uid: string;
79
+ data: UpdateUserRequest;
80
+ }, unknown>;
81
+ export declare const useCreateUser: () => import("@tanstack/react-query").UseMutationResult<{
82
+ uid: string;
83
+ email: string;
84
+ username: string | null;
85
+ display_name: string;
86
+ avatar_url: string | null;
87
+ phone_number: string | null;
88
+ email_verified_at: string | null;
89
+ phone_verified_at: string | null;
90
+ locale: string;
91
+ timezone: string;
92
+ status: string;
93
+ role: string[];
94
+ profile_data: Record<string, any>;
95
+ last_login_at: string | null;
96
+ created_at: string;
97
+ updated_at: string;
98
+ }, Error, {
99
+ display_name: string;
100
+ email: string;
101
+ username?: string | null | undefined;
102
+ role?: string[] | undefined;
103
+ password?: string | undefined;
104
+ provider?: string | undefined;
105
+ provider_subject?: string | undefined;
106
+ termCodes?: string[] | undefined;
107
+ }, unknown>;
108
+ export declare const useDeleteUser: () => import("@tanstack/react-query").UseMutationResult<void, Error, string, unknown>;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useDeleteUser = exports.useCreateUser = exports.useUpdateUser = exports.useUserDetail = exports.useUserList = exports.userKeys = void 0;
4
+ const react_query_1 = require("@tanstack/react-query");
5
+ const context_1 = require("../context");
6
+ exports.userKeys = {
7
+ all: ['users'],
8
+ lists: () => [...exports.userKeys.all, 'list'],
9
+ list: (params) => [...exports.userKeys.lists(), params],
10
+ details: () => [...exports.userKeys.all, 'detail'],
11
+ detail: (uid) => [...exports.userKeys.details(), uid],
12
+ };
13
+ const useUserList = (params) => {
14
+ const client = (0, context_1.usePHCMSAdmin)();
15
+ return (0, react_query_1.useQuery)({
16
+ queryKey: exports.userKeys.list(params),
17
+ queryFn: () => client.user.list(params),
18
+ staleTime: 1000 * 60, // 1 minute
19
+ placeholderData: react_query_1.keepPreviousData,
20
+ });
21
+ };
22
+ exports.useUserList = useUserList;
23
+ const useUserDetail = (uid) => {
24
+ const client = (0, context_1.usePHCMSAdmin)();
25
+ return (0, react_query_1.useQuery)({
26
+ queryKey: exports.userKeys.detail(uid),
27
+ queryFn: () => client.user.get(uid),
28
+ enabled: !!uid,
29
+ });
30
+ };
31
+ exports.useUserDetail = useUserDetail;
32
+ const useUpdateUser = () => {
33
+ const client = (0, context_1.usePHCMSAdmin)();
34
+ const queryClient = (0, react_query_1.useQueryClient)();
35
+ return (0, react_query_1.useMutation)({
36
+ mutationFn: ({ uid, data }) => client.user.update(uid, data),
37
+ onSuccess: (data, variables) => {
38
+ queryClient.invalidateQueries({ queryKey: exports.userKeys.detail(variables.uid) });
39
+ queryClient.invalidateQueries({ queryKey: exports.userKeys.lists() });
40
+ },
41
+ });
42
+ };
43
+ exports.useUpdateUser = useUpdateUser;
44
+ const useCreateUser = () => {
45
+ const client = (0, context_1.usePHCMSAdmin)();
46
+ const queryClient = (0, react_query_1.useQueryClient)();
47
+ return (0, react_query_1.useMutation)({
48
+ mutationFn: (data) => client.user.create(data),
49
+ onSuccess: (data) => {
50
+ queryClient.invalidateQueries({ queryKey: exports.userKeys.lists() });
51
+ queryClient.invalidateQueries({ queryKey: exports.userKeys.detail(data.uid) });
52
+ },
53
+ });
54
+ };
55
+ exports.useCreateUser = useCreateUser;
56
+ const useDeleteUser = () => {
57
+ const client = (0, context_1.usePHCMSAdmin)();
58
+ const queryClient = (0, react_query_1.useQueryClient)();
59
+ return (0, react_query_1.useMutation)({
60
+ mutationFn: (uid) => client.user.delete(uid),
61
+ onSuccess: () => {
62
+ queryClient.invalidateQueries({ queryKey: exports.userKeys.lists() });
63
+ },
64
+ });
65
+ };
66
+ exports.useDeleteUser = useDeleteUser;
@@ -0,0 +1,15 @@
1
+ export { PHCMSAdminClient } from './client';
2
+ export { PHCMSAdminProvider, usePHCMSAdmin } from './context';
3
+ export * from './errors';
4
+ export * from './modules/system';
5
+ export * from './modules/dashboard';
6
+ export * from './modules/user';
7
+ export * from './modules/policy';
8
+ export * from './modules/hierarchy';
9
+ export * from './modules/terms';
10
+ export * from './hooks/useSystem';
11
+ export * from './hooks/useDashboard';
12
+ export * from './hooks/useUser';
13
+ export * from './hooks/usePolicy';
14
+ export * from './hooks/useHierarchy';
15
+ export * from './hooks/useTerms';
package/dist/index.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.usePHCMSAdmin = exports.PHCMSAdminProvider = exports.PHCMSAdminClient = void 0;
18
+ var client_1 = require("./client");
19
+ Object.defineProperty(exports, "PHCMSAdminClient", { enumerable: true, get: function () { return client_1.PHCMSAdminClient; } });
20
+ var context_1 = require("./context");
21
+ Object.defineProperty(exports, "PHCMSAdminProvider", { enumerable: true, get: function () { return context_1.PHCMSAdminProvider; } });
22
+ Object.defineProperty(exports, "usePHCMSAdmin", { enumerable: true, get: function () { return context_1.usePHCMSAdmin; } });
23
+ __exportStar(require("./errors"), exports);
24
+ __exportStar(require("./modules/system"), exports);
25
+ __exportStar(require("./modules/dashboard"), exports);
26
+ __exportStar(require("./modules/user"), exports);
27
+ __exportStar(require("./modules/policy"), exports);
28
+ __exportStar(require("./modules/hierarchy"), exports);
29
+ __exportStar(require("./modules/terms"), exports);
30
+ __exportStar(require("./hooks/useSystem"), exports);
31
+ __exportStar(require("./hooks/useDashboard"), exports);
32
+ __exportStar(require("./hooks/useUser"), exports);
33
+ __exportStar(require("./hooks/usePolicy"), exports);
34
+ __exportStar(require("./hooks/useHierarchy"), exports);
35
+ __exportStar(require("./hooks/useTerms"), exports);
@@ -0,0 +1,7 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { DashboardDto } from "@ph-cms/api-contract-admin";
3
+ export declare class DashboardModule {
4
+ private client;
5
+ constructor(client: AxiosInstance);
6
+ getStats(): Promise<DashboardDto>;
7
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DashboardModule = void 0;
4
+ class DashboardModule {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ async getStats() {
9
+ return this.client.get('/api/dashboard');
10
+ }
11
+ }
12
+ exports.DashboardModule = DashboardModule;
@@ -0,0 +1,14 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { HierarchySetDto, CreateHierarchySetRequest, UpdateHierarchySetRequest, HierarchyItemDto, AddHierarchyItemRequest, ListHierarchyQuery, PagedHierarchySetListResponse } from "@ph-cms/api-contract-admin";
3
+ export declare class HierarchyModule {
4
+ private client;
5
+ constructor(client: AxiosInstance);
6
+ list(params?: ListHierarchyQuery): Promise<PagedHierarchySetListResponse>;
7
+ get(uid: string): Promise<HierarchySetDto>;
8
+ create(data: CreateHierarchySetRequest): Promise<HierarchySetDto>;
9
+ update(uid: string, data: UpdateHierarchySetRequest): Promise<HierarchySetDto>;
10
+ delete(uid: string): Promise<void>;
11
+ listItems(setUid: string): Promise<HierarchyItemDto[]>;
12
+ addItem(setUid: string, data: AddHierarchyItemRequest): Promise<HierarchyItemDto>;
13
+ removeItem(setUid: string, itemUid: string): Promise<void>;
14
+ }