@syzy/apphost 1.0.1 → 1.0.3

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 (213) hide show
  1. package/dist/App.d.ts +4 -0
  2. package/dist/App.js +83 -0
  3. package/dist/AppHostProvider.d.ts +6 -0
  4. package/dist/AppHostProvider.js +4 -0
  5. package/dist/AppHostRoutes.d.ts +1 -0
  6. package/dist/AppHostRoutes.js +7 -0
  7. package/dist/api/image-api.d.ts +8 -0
  8. package/dist/api/image-api.js +45 -0
  9. package/dist/api/mapping-api.d.ts +80 -0
  10. package/dist/api/mapping-api.js +427 -0
  11. package/dist/bookingModule/components/AmenityForm.d.ts +3 -0
  12. package/dist/bookingModule/components/AmenityForm.js +19 -0
  13. package/dist/bookingModule/components/BillingManagement.d.ts +3 -0
  14. package/dist/bookingModule/components/BillingManagement.js +17 -0
  15. package/dist/bookingModule/components/CreateRoomForm.d.ts +3 -0
  16. package/dist/bookingModule/components/CreateRoomForm.js +19 -0
  17. package/dist/bookingModule/components/ExtraRequirementForm.d.ts +3 -0
  18. package/dist/bookingModule/components/ExtraRequirementForm.js +19 -0
  19. package/dist/bookingModule/components/ReservationForm.d.ts +3 -0
  20. package/dist/bookingModule/components/ReservationForm.js +18 -0
  21. package/dist/bookingModule/components/RoomCategoryForm.d.ts +3 -0
  22. package/dist/bookingModule/components/RoomCategoryForm.js +19 -0
  23. package/dist/bookingModule/components/RoomCategoryPriceForm.d.ts +3 -0
  24. package/dist/bookingModule/components/RoomCategoryPriceForm.js +20 -0
  25. package/dist/bookingModule/components/RoomExtraRequirementCapture.d.ts +3 -0
  26. package/dist/bookingModule/components/RoomExtraRequirementCapture.js +18 -0
  27. package/dist/bookingModule/components/RoomFacilityForm.d.ts +3 -0
  28. package/dist/bookingModule/components/RoomFacilityForm.js +19 -0
  29. package/dist/bookingModule/components/RoomReservationAction.d.ts +3 -0
  30. package/dist/bookingModule/components/RoomReservationAction.js +18 -0
  31. package/dist/components/Home/Home.d.ts +3 -0
  32. package/dist/components/Home/Home.js +14 -0
  33. package/dist/components/Loader/Loader.d.ts +2 -0
  34. package/dist/components/Loader/Loader.js +5 -0
  35. package/dist/components/Login/Login.d.ts +7 -0
  36. package/dist/components/Login/Login.js +149 -0
  37. package/dist/components/Login/loginSchema.d.ts +27 -0
  38. package/dist/components/Login/loginSchema.js +41 -0
  39. package/dist/components/Mappings/BranchMapping/Branch.d.ts +5 -0
  40. package/dist/components/Mappings/BranchMapping/Branch.js +135 -0
  41. package/dist/components/Mappings/BranchMapping/BranchTableColumns.d.ts +10 -0
  42. package/dist/components/Mappings/BranchMapping/BranchTableColumns.js +21 -0
  43. package/dist/components/Mappings/BranchMapping/MappingFormBranchUser.d.ts +3 -0
  44. package/dist/components/Mappings/BranchMapping/MappingFormBranchUser.js +150 -0
  45. package/dist/components/Mappings/BranchMapping/MappingTableColumns.d.ts +14 -0
  46. package/dist/components/Mappings/BranchMapping/MappingTableColumns.js +29 -0
  47. package/dist/components/Mappings/BranchMapping/branchSchema.d.ts +37 -0
  48. package/dist/components/Mappings/BranchMapping/branchSchema.js +34 -0
  49. package/dist/components/Mappings/ComponentMapping/ComponentRoleMapping.d.ts +3 -0
  50. package/dist/components/Mappings/ComponentMapping/ComponentRoleMapping.js +98 -0
  51. package/dist/components/Mappings/ComponentMapping/componentRoleColumns.d.ts +3 -0
  52. package/dist/components/Mappings/ComponentMapping/componentRoleColumns.js +29 -0
  53. package/dist/components/Mappings/MappingForm/MappingForm.d.ts +35 -0
  54. package/dist/components/Mappings/MappingForm/MappingForm.js +142 -0
  55. package/dist/components/Mappings/MappingForm/mappingSchema.d.ts +23 -0
  56. package/dist/components/Mappings/MappingForm/mappingSchema.js +32 -0
  57. package/dist/components/Mappings/RoleMapping/MappingFormUserRole.d.ts +5 -0
  58. package/dist/components/Mappings/RoleMapping/MappingFormUserRole.js +194 -0
  59. package/dist/components/Mappings/RoleMapping/UserRoleTableColumns.d.ts +3 -0
  60. package/dist/components/Mappings/RoleMapping/UserRoleTableColumns.js +33 -0
  61. package/dist/components/NavBar/Sidebar.d.ts +4 -0
  62. package/dist/components/NavBar/Sidebar.js +56 -0
  63. package/dist/components/ProfileForm/ProfileForm.d.ts +3 -0
  64. package/dist/components/ProfileForm/ProfileForm.js +190 -0
  65. package/dist/components/ProfileForm/ProfileList.d.ts +3 -0
  66. package/dist/components/ProfileForm/ProfileList.js +33 -0
  67. package/dist/components/ProfileForm/profileColumns.d.ts +3 -0
  68. package/dist/components/ProfileForm/profileColumns.js +67 -0
  69. package/dist/components/ProfileForm/profileSchema.d.ts +52 -0
  70. package/dist/components/ProfileForm/profileSchema.js +50 -0
  71. package/dist/components/SettingsPage/SettingsPage.d.ts +3 -0
  72. package/dist/components/SettingsPage/SettingsPage.js +240 -0
  73. package/dist/components/api/settings-api.d.ts +26 -0
  74. package/dist/components/api/settings-api.js +131 -0
  75. package/dist/components/common/Form/FormActionButtons.d.ts +11 -0
  76. package/dist/components/common/Form/FormActionButtons.js +6 -0
  77. package/dist/components/common/Form/FormLabel.d.ts +8 -0
  78. package/dist/components/common/Form/FormLabel.js +6 -0
  79. package/dist/components/common/ListTable/ListHeader.d.ts +8 -0
  80. package/dist/components/common/ListTable/ListHeader.js +5 -0
  81. package/dist/components/common/ListTable/ListTable.d.ts +17 -0
  82. package/dist/components/common/ListTable/ListTable.js +31 -0
  83. package/dist/components/common/Modal/Modal.d.ts +11 -0
  84. package/dist/components/common/Modal/Modal.js +6 -0
  85. package/dist/config/EnvConfig.d.ts +13 -0
  86. package/dist/config/EnvConfig.js +13 -0
  87. package/dist/config/amplifyConfig.d.ts +1 -0
  88. package/dist/config/amplifyConfig.js +45 -0
  89. package/dist/configureAppHost.d.ts +6 -0
  90. package/dist/configureAppHost.js +5 -0
  91. package/dist/customGraphQL/customMutations.d.ts +3 -0
  92. package/dist/customGraphQL/customMutations.js +53 -0
  93. package/dist/customGraphQL/customQueries.d.ts +7 -0
  94. package/dist/customGraphQL/customQueries.js +104 -0
  95. package/dist/domain/input/input-types.d.ts +47 -0
  96. package/dist/domain/input/input-types.js +1 -0
  97. package/dist/domain/model/BranchDto.d.ts +9 -0
  98. package/dist/domain/model/BranchDto.js +8 -0
  99. package/dist/domain/model/ComponentMappingDto.d.ts +24 -0
  100. package/dist/domain/model/ComponentMappingDto.js +19 -0
  101. package/dist/domain/model/MappingDto.d.ts +30 -0
  102. package/dist/domain/model/MappingDto.js +16 -0
  103. package/dist/domain/model/PrefixDescriptionDto.d.ts +16 -0
  104. package/dist/domain/model/PrefixDescriptionDto.js +13 -0
  105. package/dist/domain/model/ProfileDto.d.ts +21 -0
  106. package/dist/domain/model/ProfileDto.js +20 -0
  107. package/dist/domain/model/RoleMappingDto.d.ts +14 -0
  108. package/dist/domain/model/RoleMappingDto.js +19 -0
  109. package/dist/domain/model/SettingsDto.d.ts +8 -0
  110. package/dist/domain/model/SettingsDto.js +7 -0
  111. package/dist/domain/model/UserMappingDto.d.ts +14 -0
  112. package/dist/domain/model/UserMappingDto.js +28 -0
  113. package/dist/domain/model/imageDto.d.ts +4 -0
  114. package/dist/domain/model/imageDto.js +1 -0
  115. package/dist/domain/type/EntityTypes.d.ts +5 -0
  116. package/dist/domain/type/EntityTypes.js +6 -0
  117. package/dist/domain/type/MappingOptions.d.ts +5 -0
  118. package/dist/domain/type/MappingOptions.js +1 -0
  119. package/dist/domain/type/MappingTypes.d.ts +6 -0
  120. package/dist/domain/type/MappingTypes.js +7 -0
  121. package/dist/domain/type/Nullable.d.ts +13 -0
  122. package/dist/domain/type/Nullable.js +1 -0
  123. package/dist/domain/type/ResettingPeriodOptions.d.ts +2 -0
  124. package/dist/domain/type/ResettingPeriodOptions.js +8 -0
  125. package/dist/domain/type/RolesEnum.d.ts +6 -0
  126. package/dist/domain/type/RolesEnum.js +7 -0
  127. package/dist/domain/type/SelectType.d.ts +16 -0
  128. package/dist/domain/type/SelectType.js +1 -0
  129. package/dist/domain/type/StatusEnum.d.ts +5 -0
  130. package/dist/domain/type/StatusEnum.js +6 -0
  131. package/dist/domain/type/signUpOptions.d.ts +2 -0
  132. package/dist/domain/type/signUpOptions.js +4 -0
  133. package/dist/domain/type/statusOptions.d.ts +2 -0
  134. package/dist/domain/type/statusOptions.js +4 -0
  135. package/dist/graphql/profileQueries.d.ts +4 -0
  136. package/dist/graphql/profileQueries.js +89 -0
  137. package/dist/hoc/withSyzyAuth.d.ts +2 -0
  138. package/dist/hoc/withSyzyAuth.js +87 -0
  139. package/dist/hooks/useCurrentUser.d.ts +3 -0
  140. package/dist/hooks/useCurrentUser.js +6 -0
  141. package/dist/hooks/useDispatch.d.ts +3 -0
  142. package/dist/hooks/useDispatch.js +7 -0
  143. package/dist/hooks/usePermission.d.ts +1 -0
  144. package/dist/hooks/usePermission.js +7 -0
  145. package/dist/index.d.ts +3 -0
  146. package/dist/index.js +3 -15
  147. package/dist/main.d.ts +4 -0
  148. package/dist/main.js +60 -0
  149. package/dist/services/Client.Service.d.ts +12 -0
  150. package/dist/services/Client.Service.js +96 -0
  151. package/dist/services/Storage-service.d.ts +2 -0
  152. package/dist/services/Storage-service.js +26 -0
  153. package/dist/services/navigationMenu.d.ts +1 -0
  154. package/dist/services/navigationMenu.js +9 -0
  155. package/dist/static/constants.d.ts +34 -0
  156. package/dist/static/constants.js +34 -0
  157. package/dist/store/AppAction.d.ts +11 -0
  158. package/dist/store/AppAction.js +5 -0
  159. package/dist/store/AppContext.d.ts +3 -0
  160. package/dist/store/AppContext.js +3 -0
  161. package/dist/store/AppContextType.d.ts +12 -0
  162. package/dist/store/AppContextType.js +6 -0
  163. package/dist/store/AppProvider.d.ts +7 -0
  164. package/dist/store/AppProvider.js +32 -0
  165. package/dist/store/HostedInContainerContext.d.ts +5 -0
  166. package/dist/store/HostedInContainerContext.js +11 -0
  167. package/dist/store/SesssionReducer.d.ts +4 -0
  168. package/dist/store/SesssionReducer.js +16 -0
  169. package/dist/types.d.ts +26 -0
  170. package/dist/types.js +14 -0
  171. package/dist/util/AuthUtils.d.ts +1 -0
  172. package/dist/util/AuthUtils.js +10 -0
  173. package/dist/util/LogEnum.d.ts +6 -0
  174. package/dist/util/LogEnum.js +7 -0
  175. package/dist/util/Logger.d.ts +6 -0
  176. package/dist/util/Logger.js +18 -0
  177. package/dist/util/SyzyDate.d.ts +69 -0
  178. package/dist/util/SyzyDate.js +265 -0
  179. package/dist/util/dateUtils.d.ts +10 -0
  180. package/dist/util/dateUtils.js +24 -0
  181. package/dist/util/hostedinContainer.d.ts +1 -0
  182. package/dist/util/hostedinContainer.js +9 -0
  183. package/dist/util/model-types.d.ts +96 -0
  184. package/dist/util/model-types.js +18 -0
  185. package/dist/util/prefixAndResettingValidation.d.ts +9 -0
  186. package/dist/util/prefixAndResettingValidation.js +54 -0
  187. package/dist/util/transformToData.d.ts +1 -0
  188. package/dist/util/transformToData.js +9 -0
  189. package/package.json +14 -9
  190. package/dist/__federation_shared_@tanstack/react-query-DHuUsaNz.js +0 -2517
  191. package/dist/__federation_shared_react-CikWE6qG.js +0 -7
  192. package/dist/__federation_shared_react-bootstrap-BKlZRvMR.js +0 -7516
  193. package/dist/__federation_shared_react-dom-vrQ70Ay8.js +0 -372
  194. package/dist/__federation_shared_react-router-dom-BKminmS4.js +0 -10448
  195. package/dist/__federation_shared_react-select-B6kehBDI.js +0 -4056
  196. package/dist/__federation_shared_react-toastify-B0S0UGr3.js +0 -412
  197. package/dist/_commonjsHelpers-C6fGbg64.js +0 -6
  198. package/dist/_virtual___federation_fn_import-XZCKozko.js +0 -217
  199. package/dist/favicon.ico +0 -0
  200. package/dist/index-DgtWMtjZ.js +0 -184
  201. package/dist/index-eZknuYwc.js +0 -1219
  202. package/dist/jsx-runtime-D_t4bG-_.js +0 -264
  203. package/dist/manifest.webmanifest +0 -1
  204. package/dist/pwa/Hotel-icon.jpg +0 -0
  205. package/dist/pwa/apple-touch-icon-180x180.png +0 -0
  206. package/dist/pwa/favicon.ico +0 -0
  207. package/dist/pwa/maskable-icon-512x512.png +0 -0
  208. package/dist/pwa/pwa-192x192.png +0 -0
  209. package/dist/pwa/pwa-512x512.png +0 -0
  210. package/dist/pwa/pwa-64x64.png +0 -0
  211. package/dist/registerSW.js +0 -1
  212. package/dist/sw.js +0 -1
  213. package/dist/workbox-1ef09536.js +0 -1
@@ -0,0 +1,4 @@
1
+ export declare const createProfile = "\n mutation CreateProfile($input: ProfileInput!) {\n createProfile(input: $input) {\n pk\n sk\n name\n email\n phoneNumber\n address\n dob\n contactRelation\n contactPersonName\n contactPersonNumber\n aadhaarNumber\n aadhaarFile\n isAdmin\n status\n createdDt\n createdBy\n }\n }\n";
2
+ export declare const updateProfile = "\n mutation UpdateProfile($input: ProfileInput!) {\n updateProfile(input: $input) {\n pk\n sk\n name\n email\n phoneNumber\n address\n dob\n contactRelation\n contactPersonName\n contactPersonNumber\n aadhaarNumber\n aadhaarFile\n isAdmin\n status\n createdDt\n createdBy\n }\n }\n";
3
+ export declare const listProfiles = "\n query ListProfiles {\n listProfiles {\n pk\n sk\n name\n email\n phoneNumber\n address\n dob\n contactRelation\n contactPersonName\n contactPersonNumber\n aadhaarNumber\n aadhaarFile\n isAdmin\n status\n createdDt\n createdBy\n }\n }\n";
4
+ export declare const getProfile = "\n query GetProfile($pk: ID!) {\n getProfile(pk: $pk) {\n pk\n sk\n name\n email\n phoneNumber\n address\n dob\n contactRelation\n contactPersonName\n contactPersonNumber\n aadhaarNumber\n aadhaarFile\n isAdmin\n status\n createdDt\n createdBy\n }\n }\n";
@@ -0,0 +1,89 @@
1
+ // src/graphql/profileQueries.ts
2
+ export const createProfile = /* GraphQL */ `
3
+ mutation CreateProfile($input: ProfileInput!) {
4
+ createProfile(input: $input) {
5
+ pk
6
+ sk
7
+ name
8
+ email
9
+ phoneNumber
10
+ address
11
+ dob
12
+ contactRelation
13
+ contactPersonName
14
+ contactPersonNumber
15
+ aadhaarNumber
16
+ aadhaarFile
17
+ isAdmin
18
+ status
19
+ createdDt
20
+ createdBy
21
+ }
22
+ }
23
+ `;
24
+ export const updateProfile = /* GraphQL */ `
25
+ mutation UpdateProfile($input: ProfileInput!) {
26
+ updateProfile(input: $input) {
27
+ pk
28
+ sk
29
+ name
30
+ email
31
+ phoneNumber
32
+ address
33
+ dob
34
+ contactRelation
35
+ contactPersonName
36
+ contactPersonNumber
37
+ aadhaarNumber
38
+ aadhaarFile
39
+ isAdmin
40
+ status
41
+ createdDt
42
+ createdBy
43
+ }
44
+ }
45
+ `;
46
+ export const listProfiles = /* GraphQL */ `
47
+ query ListProfiles {
48
+ listProfiles {
49
+ pk
50
+ sk
51
+ name
52
+ email
53
+ phoneNumber
54
+ address
55
+ dob
56
+ contactRelation
57
+ contactPersonName
58
+ contactPersonNumber
59
+ aadhaarNumber
60
+ aadhaarFile
61
+ isAdmin
62
+ status
63
+ createdDt
64
+ createdBy
65
+ }
66
+ }
67
+ `;
68
+ export const getProfile = /* GraphQL */ `
69
+ query GetProfile($pk: ID!) {
70
+ getProfile(pk: $pk) {
71
+ pk
72
+ sk
73
+ name
74
+ email
75
+ phoneNumber
76
+ address
77
+ dob
78
+ contactRelation
79
+ contactPersonName
80
+ contactPersonNumber
81
+ aadhaarNumber
82
+ aadhaarFile
83
+ isAdmin
84
+ status
85
+ createdDt
86
+ createdBy
87
+ }
88
+ }
89
+ `;
@@ -0,0 +1,2 @@
1
+ import './withSyzyAuth.css';
2
+ export declare function withSyzyAuth<P extends object>(WrappedComponent: React.ComponentType<P>): (props: P) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,87 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useContext, useEffect, useState } from "react";
3
+ import AppContext from "../store/AppContext";
4
+ import LoginForm from "../components/Login/Login";
5
+ import { getCurrentUser } from "aws-amplify/auth";
6
+ import { AppActionEnum } from "../store/AppAction";
7
+ import './withSyzyAuth.css';
8
+ import { Client } from "../services/Client.Service";
9
+ import { fetchAuthSession } from 'aws-amplify/auth';
10
+ import { getComponentsByRoleOnly, getRolesMappingByUserIdAndEntityFun, useGetUserMappingByUserId } from "../api/mapping-api";
11
+ import { EntityTypes } from "../domain/type/EntityTypes";
12
+ import { Status } from "../domain/type/StatusEnum";
13
+ export function withSyzyAuth(WrappedComponent) {
14
+ const ComponentWithAuthenticator = (props) => {
15
+ const [currentUser, setCurrentUser] = useState();
16
+ const { user, dispatch } = useContext(AppContext) || { user: undefined, allowedComponents: undefined, dispatch: undefined };
17
+ const [_isLoggedIn, setIsLoggedIn] = useState(false);
18
+ const [_emailVerifiedStatus, setEmailVerifiedStatus] = useState("");
19
+ const [isSessionReady, setIsSessionReady] = useState(false);
20
+ useEffect(() => {
21
+ if (!user?.userName) {
22
+ setCurrentUser(null);
23
+ setIsSessionReady(false);
24
+ }
25
+ }, [user]);
26
+ const fetchSession = async () => {
27
+ try {
28
+ const session = await getCurrentUser();
29
+ const userInfo = await fetchAuthSession({ forceRefresh: true });
30
+ setEmailVerifiedStatus(userInfo.tokens?.idToken?.payload.email_verified?.toString() ?? "");
31
+ if (session) {
32
+ const userId = session.signInDetails?.loginId ?? session.username;
33
+ setCurrentUser(userId);
34
+ }
35
+ else {
36
+ setCurrentUser(null);
37
+ }
38
+ }
39
+ catch (err) {
40
+ setCurrentUser(null);
41
+ }
42
+ };
43
+ useEffect(() => {
44
+ fetchSession();
45
+ }, []);
46
+ useEffect(() => {
47
+ const stopResetScheduler = Client.startClientResetScheduler();
48
+ return () => stopResetScheduler();
49
+ }, []);
50
+ useEffect(() => {
51
+ setIsLoggedIn(!!user?.userName);
52
+ }, [user]);
53
+ const { userMappingByUserId } = useGetUserMappingByUserId(currentUser ?? "");
54
+ useEffect(() => {
55
+ const updateSession = async () => {
56
+ if (!currentUser)
57
+ return;
58
+ const branchId = userMappingByUserId?.pk ?? "";
59
+ // Fetch roles of this user
60
+ const roleData = await getRolesMappingByUserIdAndEntityFun(branchId, currentUser, EntityTypes.ROLE);
61
+ const activeRoles = roleData.filter(r => r.status === Status.Active);
62
+ const roleNames = activeRoles.map(r => r.roleName);
63
+ // Fetch components for each active role
64
+ const compData = await Promise.all(activeRoles.map(role => getComponentsByRoleOnly(role.roleId)));
65
+ const allowedComponents = compData.flat().map(c => c.componentTitle);
66
+ // Build and dispatch user session
67
+ const userSession = {
68
+ userName: currentUser,
69
+ branchId,
70
+ roles: roleNames,
71
+ allowedComponents: [...new Set(allowedComponents)],
72
+ };
73
+ dispatch?.({ session: userSession, type: AppActionEnum.SignIn });
74
+ setIsSessionReady(true);
75
+ };
76
+ updateSession();
77
+ }, [currentUser, userMappingByUserId]);
78
+ // Login handler
79
+ const login = (loggedIn) => {
80
+ setIsLoggedIn(loggedIn);
81
+ if (loggedIn)
82
+ fetchSession();
83
+ };
84
+ return (_jsx("div", { children: currentUser === null ? _jsx(LoginForm, { login: login }) : _jsx(WrappedComponent, { ...props, isSessionReady: isSessionReady }) }));
85
+ };
86
+ return ComponentWithAuthenticator;
87
+ }
@@ -0,0 +1,3 @@
1
+ export declare const useCurrentUser: () => {
2
+ user: import("../store/AppContextType").AppSession;
3
+ };
@@ -0,0 +1,6 @@
1
+ import { useContext } from "react";
2
+ import AppContext from "../store/AppContext";
3
+ export const useCurrentUser = () => {
4
+ const { user } = useContext(AppContext);
5
+ return { user };
6
+ };
@@ -0,0 +1,3 @@
1
+ export declare const useDispatch: () => {
2
+ dispatch: import("react").Dispatch<import("../store/AppAction").AppAction> | undefined;
3
+ };
@@ -0,0 +1,7 @@
1
+ import { useContext } from "react";
2
+ import AppContext from "../store/AppContext";
3
+ import { defaultSession } from "../store/AppContextType";
4
+ export const useDispatch = () => {
5
+ const { dispatch } = useContext(AppContext) || { user: defaultSession };
6
+ return { dispatch };
7
+ };
@@ -0,0 +1 @@
1
+ export declare function AmIPermitted(componentName: string): boolean;
@@ -0,0 +1,7 @@
1
+ // hooks/usePermissions.ts
2
+ import { useContext } from "react";
3
+ import AppContext from "../store/AppContext";
4
+ export function AmIPermitted(componentName) {
5
+ const { user } = useContext(AppContext) || {};
6
+ return user?.allowedComponents?.includes(componentName) ?? false;
7
+ }
@@ -0,0 +1,3 @@
1
+ export { AppHostProvider } from "./AppHostProvider";
2
+ export { AppHostRoutes } from "./AppHostRoutes";
3
+ export { configureAppHost } from "./configureAppHost";
package/dist/index.js CHANGED
@@ -1,15 +1,3 @@
1
- import { j as t } from "./jsx-runtime-D_t4bG-_.js";
2
- import { i as r } from "./_virtual___federation_fn_import-XZCKozko.js";
3
- const x = ({ children: s }) => /* @__PURE__ */ t.jsx(t.Fragment, { children: s }), { Routes: p, Route: o } = await r("react-router-dom"), n = () => /* @__PURE__ */ t.jsx("div", { children: "AppHost Dashboard" }), i = () => /* @__PURE__ */ t.jsx("div", { children: "AppHost Settings" }), d = () => /* @__PURE__ */ t.jsxs(p, { children: [
4
- /* @__PURE__ */ t.jsx(o, { path: "/apphost", element: /* @__PURE__ */ t.jsx(n, {}) }),
5
- /* @__PURE__ */ t.jsx(o, { path: "/apphost/settings", element: /* @__PURE__ */ t.jsx(i, {}) })
6
- ] });
7
- let e = {};
8
- const h = (s) => {
9
- e = { ...e, ...s };
10
- };
11
- export {
12
- x as AppHostProvider,
13
- d as AppHostRoutes,
14
- h as configureAppHost
15
- };
1
+ export { AppHostProvider } from "./AppHostProvider";
2
+ export { AppHostRoutes } from "./AppHostRoutes";
3
+ export { configureAppHost } from "./configureAppHost";
package/dist/main.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import './index.css';
2
+ import 'bootstrap/dist/css/bootstrap.min.css';
3
+ import 'react-toastify/dist/ReactToastify.css';
4
+ import './styles/typography.css';
package/dist/main.js ADDED
@@ -0,0 +1,60 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { StrictMode, useEffect, useState } from 'react';
3
+ import './index.css';
4
+ import 'bootstrap/dist/css/bootstrap.min.css';
5
+ import 'react-toastify/dist/ReactToastify.css';
6
+ // import AppProvider from './store/AppProvider.tsx';
7
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
8
+ // import { HostedInContainerProvider } from "./store/HostedInContainerContext.tsx";
9
+ import { ToastContainer } from 'react-toastify';
10
+ import { BrowserRouter as Router } from 'react-router-dom';
11
+ import './styles/typography.css';
12
+ import * as ReactDOM from 'react-dom/client';
13
+ import App from './App';
14
+ function registerValidSW(swUrl, config) {
15
+ navigator.serviceWorker
16
+ .register(swUrl)
17
+ .then((registration) => {
18
+ registration.onupdatefound = () => {
19
+ const installingWorker = registration.installing;
20
+ if (installingWorker == null) {
21
+ return;
22
+ }
23
+ installingWorker.onstatechange = () => {
24
+ if (installingWorker.state === 'installed') {
25
+ if (navigator.serviceWorker.controller) {
26
+ // Trigger the callback to notify that a new version is available
27
+ if (config && config.onUpdate) {
28
+ config.onUpdate(registration);
29
+ }
30
+ }
31
+ }
32
+ };
33
+ };
34
+ })
35
+ .catch((error) => {
36
+ console.error('Error during service worker registration:', error);
37
+ });
38
+ }
39
+ const root = ReactDOM.createRoot(document.getElementById('root'));
40
+ const queryClient = new QueryClient();
41
+ const AppWithServiceWorker = () => {
42
+ const [showUpdatePrompt, setShowUpdatePrompt] = useState(false);
43
+ const [swRegistration, setSwRegistration] = useState(null);
44
+ const handleUpdate = (registration) => {
45
+ setSwRegistration(registration); // Save the registration for later use
46
+ setShowUpdatePrompt(true); // Show the update prompt
47
+ };
48
+ // Register the service worker
49
+ useEffect(() => {
50
+ const swUrl = '/sw.js'; // Path to your service worker
51
+ registerValidSW(swUrl, {
52
+ onUpdate: handleUpdate,
53
+ });
54
+ }, []);
55
+ return (_jsxs(StrictMode, { children: [_jsxs(QueryClientProvider, { client: queryClient, children: [_jsx(ToastContainer, { position: "top-right", autoClose: 3000, hideProgressBar: false, newestOnTop: true, closeOnClick: true, pauseOnHover: true, theme: "light", limit: 1 }), _jsx(Router, { children: _jsx(App, {}) })] }), showUpdatePrompt && (_jsxs("div", { className: "update-prompt", children: [_jsx("p", { children: "A new version of the app is available. Please refresh to update." }), _jsx("button", { onClick: () => {
56
+ swRegistration?.waiting?.postMessage({ type: 'SKIP_WAITING' });
57
+ window.location.reload();
58
+ }, children: "Refresh" })] }))] }));
59
+ };
60
+ root.render(_jsx(AppWithServiceWorker, {}));
@@ -0,0 +1,12 @@
1
+ import { V6Client } from '@aws-amplify/api-graphql';
2
+ import { GraphQLClient } from "graphql-request";
3
+ type UndefinedString = string | undefined;
4
+ export declare class Client {
5
+ static client: any;
6
+ static subClient: any;
7
+ static getToken(): Promise<UndefinedString>;
8
+ static getClient(forceRefresh?: boolean): Promise<V6Client>;
9
+ static getCustomGraphqlClient(endPoint: string): Promise<GraphQLClient>;
10
+ static startClientResetScheduler(): () => void;
11
+ }
12
+ export {};
@@ -0,0 +1,96 @@
1
+ import { fetchAuthSession } from 'aws-amplify/auth';
2
+ import { generateClient } from 'aws-amplify/api';
3
+ import { GraphQLClient } from "graphql-request";
4
+ import { logger } from '../util/Logger';
5
+ import { EnvConfig } from '../config/EnvConfig';
6
+ import { SignatureV4 } from "@aws-sdk/signature-v4";
7
+ import { Sha256 } from "@aws-crypto/sha256-js";
8
+ import { HttpRequest } from "@aws-sdk/protocol-http";
9
+ export class Client {
10
+ static client = undefined;
11
+ static subClient = undefined;
12
+ static async getToken() {
13
+ const session = await fetchAuthSession();
14
+ const credentials = session.credentials;
15
+ const token = session.tokens?.accessToken;
16
+ sessionStorage.setItem('AccessToken', token ?? '');
17
+ sessionStorage.setItem('Credentials', JSON.stringify(credentials)); // for IAM access in payment micro-UI
18
+ return token;
19
+ }
20
+ static async getClient(forceRefresh = false) {
21
+ if (!this.client || forceRefresh) {
22
+ try {
23
+ const token = await this.getToken() ?? "";
24
+ logger.debug("token fetched", token);
25
+ this.client = generateClient({ authMode: 'userPool', headers: { 'Authorization': token } });
26
+ }
27
+ catch (error) {
28
+ logger.error("Get token error while retrieving new token", error);
29
+ }
30
+ }
31
+ return this.client;
32
+ }
33
+ static async getCustomGraphqlClient(endPoint) {
34
+ try {
35
+ const session = await fetchAuthSession();
36
+ const credentials = session.credentials;
37
+ const idToken = session.tokens?.accessToken;
38
+ sessionStorage.setItem('AccessToken', idToken ?? '');
39
+ sessionStorage.setItem('Credentials', JSON.stringify(credentials)); // for IAM access in payment micro-UI
40
+ if (idToken && idToken !== "") {
41
+ // ✅ User Pool auth
42
+ logger.debug("UserPool authentication");
43
+ this.subClient = new GraphQLClient(endPoint, {
44
+ headers: {
45
+ Authorization: idToken,
46
+ "Content-Type": "application/json",
47
+ },
48
+ });
49
+ }
50
+ else if (credentials) {
51
+ // ✅ IAM auth
52
+ logger.debug("IAM authentication");
53
+ const customFetch = async (url, options) => {
54
+ const signer = new SignatureV4({
55
+ service: "appsync",
56
+ region: EnvConfig.region,
57
+ credentials,
58
+ sha256: Sha256,
59
+ });
60
+ const urlObj = new URL(endPoint);
61
+ const request = new HttpRequest({
62
+ method: options.method ?? "POST",
63
+ headers: {
64
+ host: urlObj.hostname, // 👈 must be signed
65
+ "Content-Type": "application/json",
66
+ ...(options.headers || {}),
67
+ },
68
+ body: options.body,
69
+ hostname: urlObj.hostname,
70
+ path: urlObj.pathname,
71
+ protocol: urlObj.protocol,
72
+ });
73
+ const signed = await signer.sign(request);
74
+ return fetch(url, {
75
+ ...options,
76
+ headers: signed.headers,
77
+ });
78
+ };
79
+ this.subClient = new GraphQLClient(endPoint, { fetch: customFetch });
80
+ }
81
+ else {
82
+ throw new Error("No valid authentication method available (IAM or UserPool).");
83
+ }
84
+ return this.subClient;
85
+ }
86
+ catch (err) {
87
+ throw new Error("Error while creating GraphQL client");
88
+ }
89
+ }
90
+ static startClientResetScheduler() {
91
+ const intervalId = setInterval(() => {
92
+ this.client = null;
93
+ }, 2700000); // 45 minutes in milliseconds
94
+ return () => clearInterval(intervalId);
95
+ }
96
+ }
@@ -0,0 +1,2 @@
1
+ export declare const getImageUrl: (imageKey: string | undefined | null) => Promise<string | undefined>;
2
+ export declare const uploadImage: (imageKey: string, image: File) => Promise<void>;
@@ -0,0 +1,26 @@
1
+ import { uploadData } from 'aws-amplify/storage';
2
+ import { LogCategoryEnum } from '../util/LogEnum';
3
+ import { logger } from '../util/Logger';
4
+ import { EnvConfig } from '../config/EnvConfig';
5
+ export const getImageUrl = async (imageKey) => {
6
+ logger.debug(LogCategoryEnum.Info, "imageKey passed", imageKey);
7
+ let returnString = undefined;
8
+ if (imageKey) {
9
+ //Below for hms-ck-dev env image bucket url -------------
10
+ returnString = `${EnvConfig.imageStorageBucketUrl}/${imageKey}`;
11
+ }
12
+ return returnString;
13
+ };
14
+ export const uploadImage = async (imageKey, image) => {
15
+ logger.debug(LogCategoryEnum.Info, "inside upload image function", imageKey);
16
+ logger.debug(LogCategoryEnum.Info, "inside upload image function", image);
17
+ await uploadData({
18
+ key: imageKey,
19
+ data: image,
20
+ options: {
21
+ accessLevel: 'guest',
22
+ contentType: image.type,
23
+ }
24
+ });
25
+ logger.debug(LogCategoryEnum.Info, "image key", imageKey);
26
+ };
@@ -0,0 +1 @@
1
+ export declare const getSidebarMenu: () => Promise<unknown>;
@@ -0,0 +1,9 @@
1
+ import navMenuJson from "../config/routes.json";
2
+ export const getSidebarMenu = async () => {
3
+ // Simulated API call
4
+ return new Promise((resolve) => {
5
+ setTimeout(() => {
6
+ resolve(navMenuJson);
7
+ }, 200);
8
+ });
9
+ };
@@ -0,0 +1,34 @@
1
+ export declare const VITE_API_AUTHMODE = "userPool";
2
+ export declare const INVOICE_PREFIX_FORMAT = "invoice-prefix-format-settings";
3
+ export declare const INVOICE_RESETTING_PERIOD = "invoice-resetting-period";
4
+ export declare const INVOICE_SEQUENCE_PADDING = "invoice-sequence-padding";
5
+ export declare const INVOICE_SERIES_NUMBER = "invoice-series-number-setting";
6
+ export declare const BOOKING_RECEIPT_PREFIX_FORMAT = "booking-receipt-prefix-format-settings";
7
+ export declare const BOOKING_RECEIPT_RESETTING_PERIOD = "booking-receipt-resetting-period";
8
+ export declare const BOOKING_RECEIPT_SEQUENCE_PADDING = "booking-receipt-sequence-padding";
9
+ export declare const BOOKING_RECEIPT_SERIES_NUMBER = "booking-receipt-series-number-setting";
10
+ export declare const PURCHASE_ORDER_PREFIX_FORMAT = "purchase-order-prefix-format-settings";
11
+ export declare const PURCHASE_ORDER_RESETTING_PERIOD = "purchase-order-resetting-period";
12
+ export declare const PURCHASE_ORDER_SEQUENCE_PADDING = "purchase-order-sequence-padding";
13
+ export declare const PREFIX_CONSTANT_FY = "{FY}";
14
+ export declare const PREFIX_CONSTANT_fy = "{fy}";
15
+ export declare const PREFIX_CONSTANT_FYPLUS1 = "{FYPLUS1}";
16
+ export declare const PREFIX_CONSTANT_fyplus1 = "{fyplus1}";
17
+ export declare const PREFIX_CONSTANT_FYMINUS1 = "{FYMINUS1}";
18
+ export declare const PREFIX_CONSTANT_fyminus1 = "{fyminus1}";
19
+ export declare const PREFIX_CONSTANT_Y = "{Y}";
20
+ export declare const PREFIX_CONSTANT_y = "{y}";
21
+ export declare const PREFIX_CONSTANT_M = "{M}";
22
+ export declare const PREFIX_CONSTANT_D = "{D}";
23
+ export declare const FINANCIAL_YEARLY = "FINANCIAL YEARLY";
24
+ export declare const YEARLY = "YEARLY";
25
+ export declare const MONTHLY = "MONTHLY";
26
+ export declare const DAILY = "DAILY";
27
+ export declare const NEVER = "NEVER";
28
+ export declare const RESERVATION_PREFIX_FORMAT = "reservation-prefix-format";
29
+ export declare const RESERVATION_RESETTING_PERIOD = "reservation-resetting-period";
30
+ export declare const RESERVATION_SEQUENCE_PADDING = "reservation-sequence-padding";
31
+ export declare const ALL = "All";
32
+ export declare const HIDE_SIGN_UP = "hide-sign-up";
33
+ export declare const HIDE_SIGN_UP_IS_YES = "Yes";
34
+ export declare const HIDE_SIGN_UP_IS_NO = "No";
@@ -0,0 +1,34 @@
1
+ export const VITE_API_AUTHMODE = "userPool";
2
+ export const INVOICE_PREFIX_FORMAT = "invoice-prefix-format-settings";
3
+ export const INVOICE_RESETTING_PERIOD = 'invoice-resetting-period';
4
+ export const INVOICE_SEQUENCE_PADDING = 'invoice-sequence-padding';
5
+ export const INVOICE_SERIES_NUMBER = "invoice-series-number-setting";
6
+ export const BOOKING_RECEIPT_PREFIX_FORMAT = "booking-receipt-prefix-format-settings";
7
+ export const BOOKING_RECEIPT_RESETTING_PERIOD = "booking-receipt-resetting-period";
8
+ export const BOOKING_RECEIPT_SEQUENCE_PADDING = "booking-receipt-sequence-padding";
9
+ export const BOOKING_RECEIPT_SERIES_NUMBER = "booking-receipt-series-number-setting";
10
+ export const PURCHASE_ORDER_PREFIX_FORMAT = "purchase-order-prefix-format-settings";
11
+ export const PURCHASE_ORDER_RESETTING_PERIOD = 'purchase-order-resetting-period';
12
+ export const PURCHASE_ORDER_SEQUENCE_PADDING = 'purchase-order-sequence-padding';
13
+ export const PREFIX_CONSTANT_FY = '{FY}';
14
+ export const PREFIX_CONSTANT_fy = '{fy}';
15
+ export const PREFIX_CONSTANT_FYPLUS1 = '{FYPLUS1}';
16
+ export const PREFIX_CONSTANT_fyplus1 = "{fyplus1}";
17
+ export const PREFIX_CONSTANT_FYMINUS1 = "{FYMINUS1}";
18
+ export const PREFIX_CONSTANT_fyminus1 = "{fyminus1}";
19
+ export const PREFIX_CONSTANT_Y = '{Y}';
20
+ export const PREFIX_CONSTANT_y = '{y}';
21
+ export const PREFIX_CONSTANT_M = '{M}';
22
+ export const PREFIX_CONSTANT_D = '{D}';
23
+ export const FINANCIAL_YEARLY = "FINANCIAL YEARLY";
24
+ export const YEARLY = "YEARLY";
25
+ export const MONTHLY = "MONTHLY";
26
+ export const DAILY = "DAILY";
27
+ export const NEVER = "NEVER";
28
+ export const RESERVATION_PREFIX_FORMAT = "reservation-prefix-format";
29
+ export const RESERVATION_RESETTING_PERIOD = "reservation-resetting-period";
30
+ export const RESERVATION_SEQUENCE_PADDING = 'reservation-sequence-padding';
31
+ export const ALL = "All";
32
+ export const HIDE_SIGN_UP = 'hide-sign-up';
33
+ export const HIDE_SIGN_UP_IS_YES = 'Yes';
34
+ export const HIDE_SIGN_UP_IS_NO = 'No';
@@ -0,0 +1,11 @@
1
+ import { AppSession } from "./AppContextType";
2
+ export declare enum AppActionEnum {
3
+ SignIn = "SIGNIN",
4
+ SignOut = "SIGNOUT"
5
+ }
6
+ export type AppAction = {
7
+ type: AppActionEnum.SignIn;
8
+ session: AppSession;
9
+ } | {
10
+ type: AppActionEnum.SignOut;
11
+ };
@@ -0,0 +1,5 @@
1
+ export var AppActionEnum;
2
+ (function (AppActionEnum) {
3
+ AppActionEnum["SignIn"] = "SIGNIN";
4
+ AppActionEnum["SignOut"] = "SIGNOUT";
5
+ })(AppActionEnum || (AppActionEnum = {}));
@@ -0,0 +1,3 @@
1
+ import { AppContextProps } from './AppContextType';
2
+ declare const AppContext: import("react").Context<AppContextProps | undefined>;
3
+ export default AppContext;
@@ -0,0 +1,3 @@
1
+ import { createContext } from 'react';
2
+ const AppContext = createContext(undefined);
3
+ export default AppContext;
@@ -0,0 +1,12 @@
1
+ import { AppAction } from "./AppAction";
2
+ export interface AppSession {
3
+ userName: string;
4
+ branchId?: string;
5
+ roles: string[];
6
+ allowedComponents?: string[];
7
+ }
8
+ export declare const defaultSession: AppSession;
9
+ export interface AppContextProps {
10
+ user: AppSession;
11
+ dispatch: React.Dispatch<AppAction>;
12
+ }
@@ -0,0 +1,6 @@
1
+ export const defaultSession = {
2
+ userName: '',
3
+ branchId: undefined,
4
+ roles: [],
5
+ allowedComponents: [],
6
+ };
@@ -0,0 +1,7 @@
1
+ import React, { ReactNode } from "react";
2
+ import 'react-toastify/dist/ReactToastify.css';
3
+ interface AppProviderProps {
4
+ children: ReactNode;
5
+ }
6
+ declare const AppProvider: React.FC<AppProviderProps>;
7
+ export default AppProvider;
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { defaultSession } from "./AppContextType";
3
+ import AppContext from "./AppContext";
4
+ import { ToastContainer } from 'react-toastify';
5
+ import 'react-toastify/dist/ReactToastify.css';
6
+ import { AppActionEnum } from "./AppAction";
7
+ import { sessionStorage } from "aws-amplify/utils";
8
+ import { APPHOSTSESSION_KEY, useSessionReducer } from "./SesssionReducer";
9
+ import { logger } from "../util/Logger";
10
+ const appContextReducer = (state, action) => {
11
+ logger.debug("Action:", action);
12
+ let newState = state;
13
+ switch (action.type) {
14
+ case AppActionEnum.SignIn:
15
+ newState = {
16
+ ...action.session,
17
+ };
18
+ break;
19
+ case AppActionEnum.SignOut:
20
+ newState = { ...defaultSession };
21
+ sessionStorage.clear();
22
+ break;
23
+ default:
24
+ newState = state;
25
+ }
26
+ return newState;
27
+ };
28
+ const AppProvider = ({ children }) => {
29
+ const [state, dispatch] = useSessionReducer(appContextReducer, defaultSession, APPHOSTSESSION_KEY);
30
+ return (_jsxs(_Fragment, { children: [_jsx(ToastContainer, { position: "top-right", autoClose: 5000 }), _jsx(AppContext.Provider, { value: { user: state, dispatch }, children: children })] }));
31
+ };
32
+ export default AppProvider;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare const HostedInContainerProvider: React.FC<{
3
+ children: React.ReactNode;
4
+ }>;
5
+ export declare const useHostedInContainer: () => boolean;