@gen-epix/ui-client-common 4.4.0 → 4.4.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 (76) hide show
  1. package/dist/_chunks/OutageUtil.js +2 -2
  2. package/dist/_chunks/OutageUtil.js.map +1 -1
  3. package/dist/_chunks/TableUtil.js +2 -2
  4. package/dist/_chunks/TableUtil.js.map +1 -1
  5. package/dist/_chunks/UserInvitationsAdminPage.js +1 -1
  6. package/dist/_chunks/UserInvitationsAdminPage.js.map +1 -1
  7. package/dist/classes/services/LogService/index.js +1 -1
  8. package/dist/classes/services/LogService/index.js.map +1 -1
  9. package/dist/components/app/App/App.d.ts +2 -2
  10. package/dist/components/app/App/index.js +3 -3
  11. package/dist/components/app/App/index.js.map +1 -1
  12. package/dist/components/app/ApplicationBootstrapWithAuthentication/index.js +1 -1
  13. package/dist/components/app/ApplicationBootstrapWithAuthentication/index.js.map +1 -1
  14. package/dist/components/app/ApplicationBootstrapWithoutAuthorization/index.js +1 -1
  15. package/dist/components/app/ApplicationBootstrapWithoutAuthorization/index.js.map +1 -1
  16. package/dist/components/app/AuthorizationWrapper/index.js +1 -1
  17. package/dist/components/app/AuthorizationWrapper/index.js.map +1 -1
  18. package/dist/components/app/RouterRoot/index.js +1 -1
  19. package/dist/components/app/RouterRoot/index.js.map +1 -1
  20. package/dist/components/epi/EpiContactDetailsDialog/index.js +1 -1
  21. package/dist/components/epi/EpiContactDetailsDialog/index.js.map +1 -1
  22. package/dist/components/ui/ApplicationBar/index.js +1 -1
  23. package/dist/components/ui/ApplicationBar/index.js.map +1 -1
  24. package/dist/components/ui/LicensesDialog/index.js +1 -1
  25. package/dist/components/ui/LicensesDialog/index.js.map +1 -1
  26. package/dist/components/ui/OrganizationSwitcherDialog/index.js +1 -1
  27. package/dist/components/ui/OrganizationSwitcherDialog/index.js.map +1 -1
  28. package/dist/constants/api.constants.d.ts +8 -0
  29. package/dist/constants/api.constants.js +6 -0
  30. package/dist/constants/api.constants.js.map +1 -0
  31. package/dist/context/uiClientCommonConfigContext/UiClientCommonConfigContext.d.ts +2 -2
  32. package/dist/context/uiClientCommonConfigContext/UiClientCommonConfigContextProvider.d.ts +2 -2
  33. package/dist/context/uiClientCommonConfigContext/index.js +2 -2
  34. package/dist/context/uiClientCommonConfigContext/index.js.map +1 -1
  35. package/dist/dataHooks/useIdentifierIssuerOwnOrganizationQuery/index.js +1 -1
  36. package/dist/dataHooks/useIdentifierIssuerOwnOrganizationQuery/index.js.map +1 -1
  37. package/dist/dataHooks/useIdentifierIssuerQuery/index.js +1 -1
  38. package/dist/dataHooks/useIdentifierIssuerQuery/index.js.map +1 -1
  39. package/dist/dataHooks/useInviteUserConstraintsQuery/index.js +1 -1
  40. package/dist/dataHooks/useInviteUserConstraintsQuery/index.js.map +1 -1
  41. package/dist/dataHooks/useOrganizationAdminPoliciesQuery/index.js +1 -1
  42. package/dist/dataHooks/useOrganizationAdminPoliciesQuery/index.js.map +1 -1
  43. package/dist/dataHooks/useOrganizationIdentifierIssuerLinksQuery/index.js +1 -1
  44. package/dist/dataHooks/useOrganizationIdentifierIssuerLinksQuery/index.js.map +1 -1
  45. package/dist/dataHooks/useOrganizationsQuery/index.js +1 -1
  46. package/dist/dataHooks/useOrganizationsQuery/index.js.map +1 -1
  47. package/dist/dataHooks/useUsersQuery/index.js +1 -1
  48. package/dist/dataHooks/useUsersQuery/index.js.map +1 -1
  49. package/dist/models/api.models.d.ts +0 -7
  50. package/dist/models/api.models.js +0 -6
  51. package/dist/pages/AcceptInvitationPage/index.js +1 -1
  52. package/dist/pages/AcceptInvitationPage/index.js.map +1 -1
  53. package/dist/pages/IdentifierIssuersAdminPage/index.js +1 -1
  54. package/dist/pages/IdentifierIssuersAdminPage/index.js.map +1 -1
  55. package/dist/pages/OrganizationAdminPoliciesAdminPage/index.js +1 -1
  56. package/dist/pages/OrganizationAdminPoliciesAdminPage/index.js.map +1 -1
  57. package/dist/pages/OrganizationContactsAdminPage/index.js +1 -1
  58. package/dist/pages/OrganizationContactsAdminPage/index.js.map +1 -1
  59. package/dist/pages/OrganizationSitesAdminPage/index.js +1 -1
  60. package/dist/pages/OrganizationSitesAdminPage/index.js.map +1 -1
  61. package/dist/pages/OrganizationsAdminPage/index.js +1 -1
  62. package/dist/pages/OrganizationsAdminPage/index.js.map +1 -1
  63. package/dist/pages/OutagesAdminPage/index.js +1 -1
  64. package/dist/pages/OutagesAdminPage/index.js.map +1 -1
  65. package/dist/pages/UsersAdminPage/index.js +1 -1
  66. package/dist/pages/UsersAdminPage/index.js.map +1 -1
  67. package/dist/utils/DependencyContainerUtil/DependencyContainerUtil.d.ts +6 -0
  68. package/dist/utils/DependencyContainerUtil/index.d.ts +1 -0
  69. package/dist/utils/DependencyContainerUtil/index.js +22 -0
  70. package/dist/utils/DependencyContainerUtil/index.js.map +1 -0
  71. package/package.json +9 -5
  72. package/dist/classes/containers/UiClientCommonContainer/UiClientCommonContainer.d.ts +0 -5
  73. package/dist/classes/containers/UiClientCommonContainer/index.d.ts +0 -1
  74. package/dist/classes/containers/UiClientCommonContainer/index.js +0 -17
  75. package/dist/classes/containers/UiClientCommonContainer/index.js.map +0 -1
  76. package/dist/models/api.models.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["rootContainer","_Fragment","TableUtil","CrudPage","Fragment$1","PersonOffIcon","UsersAdminPage","useTranslation","anonymizeUserConfirmationRef","useRef","organizationOptionsQuery","useOrganizationOptionsQuery","inviteUserConstraintsQuery","useInviteUserConstraintsQuery","tableRoleOptions","setTableRoleOptions","useState","formRoleOptions","setFormRoleOptions","selectedUserRef","loadables","useArray","userRoles","container","AuthorizationService","onRowsChange","useCallback","roles","role","_tableRoleOptions","_formRoleOptions","CommonDbCommandName","CommonDbPermissionType","extraRolesFromUser","option","fetchAll","API_ORGANIZATION_TOKEN","updateOne","item","variables","deleteOne","getName","canEditItem","schema","useMemo","object","SchemaUtil","string","boolean","array","formFieldDefinitions","FORM_FIELD_DEFINITION_TYPE","t","tableColumns","getOptimisticUpdateIntermediateItem","previousItem","extraUpdateOnePermissions","extraDeleteOnePermissions","onAnonymizeUserConfirmationConfirm","userName","notificationId","NotificationService","QueryClientService","COMMON_QUERY_KEY","extraActionsFactory","menuItems","MenuItem","params","ListItemIcon","ListItemText","TestIdUtil","Confirmation"],"sources":["../../../src/pages/UsersAdminPage/UsersAdminPage.tsx"],"sourcesContent":["import { container as rootContainer } from 'tsyringe';\nimport type { ReactElement } from 'react';\nimport {\n useCallback,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport {\n array,\n boolean,\n object,\n string,\n} from 'yup';\nimport type {\n CommonDbApiPermission,\n CommonDbUser,\n} from '@gen-epix/api-commondb';\nimport {\n CommonDbCommandName,\n CommonDbPermissionType,\n} from '@gen-epix/api-commondb';\nimport {\n ListItemIcon,\n ListItemText,\n MenuItem,\n} from '@mui/material';\nimport PersonOffIcon from '@mui/icons-material/PersonOff';\nimport { TestIdUtil } from '@gen-epix/ui-core/utils/TestIdUtil';\nimport { useArray } from '@gen-epix/ui-core/hooks/useArray';\nimport type {\n FormFieldDefinition,\n OptionBase,\n} from '@gen-epix/ui-core-form/models/form.models';\nimport { FORM_FIELD_DEFINITION_TYPE } from '@gen-epix/ui-core-form/models/form.models';\nimport { SchemaUtil } from '@gen-epix/ui-core-form/utils/SchemaUtil';\nimport type { ConfirmationRefMethods } from '@gen-epix/ui-core-components/components/Confirmation';\nimport { Confirmation } from '@gen-epix/ui-core-components/components/Confirmation';\n\nimport { API_ORGANIZATION_TOKEN } from '../../models/api.models';\nimport { useOrganizationOptionsQuery } from '../../dataHooks/useOrganizationsQuery';\nimport type {\n TableColumn,\n TableRowParams,\n} from '../../models/table.models';\nimport { TableUtil } from '../../utils/TableUtil';\nimport type { CrudPageProps } from '../CrudPage';\nimport { CrudPage } from '../CrudPage';\nimport { AuthorizationService } from '../../classes/services/AuthorizationService';\nimport { useInviteUserConstraintsQuery } from '../../dataHooks/useInviteUserConstraintsQuery';\nimport type { OmitWithMetaData } from '../../models/data.models';\nimport { COMMON_QUERY_KEY } from '../../constants/query.constants';\nimport { NotificationService } from '../../classes/services/NotificationService';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\n\nexport type UsersAdminPageProps = {\n subPages?: CrudPageProps<OmitWithMetaData<CommonDbUser, 'organization_id' | 'organization'>, CommonDbUser>['subPages'];\n};\n\ntype FormFields = OmitWithMetaData<CommonDbUser, 'organization_id' | 'organization'>;\n\nexport const UsersAdminPage = ({\n subPages,\n}: UsersAdminPageProps) => {\n const { t } = useTranslation();\n const anonymizeUserConfirmationRef = useRef<ConfirmationRefMethods>(null);\n const organizationOptionsQuery = useOrganizationOptionsQuery();\n const inviteUserConstraintsQuery = useInviteUserConstraintsQuery();\n const [tableRoleOptions, setTableRoleOptions] = useState<OptionBase<string>[]>([]);\n const [formRoleOptions, setFormRoleOptions] = useState<OptionBase<string>[]>([]);\n const selectedUserRef = useRef<CommonDbUser | null>(null);\n\n const loadables = useArray([\n organizationOptionsQuery,\n inviteUserConstraintsQuery,\n ]);\n\n const userRoles = rootContainer.resolve(AuthorizationService).user.roles;\n\n const onRowsChange = useCallback((items: CommonDbUser[]) => {\n // Because roles are a string array (instead of an enum or similar), we need to dynamically determine the options for the roles column in the table and in the form.\n // The options for the form are determined by the invite user constraints endpoint, but if the user doesn't have access to that endpoint, we fall back to using the roles that are currently in use by users in the system.\n const roles = new Set<string>();\n items.forEach((user) => {\n user.roles.forEach((role) => roles.add(role));\n });\n const _tableRoleOptions = Array.from(roles).map((role) => ({\n label: role,\n value: role,\n }));\n setTableRoleOptions(_tableRoleOptions);\n let _formRoleOptions: OptionBase<string>[];\n if (rootContainer.resolve(AuthorizationService).doesUserHavePermission([\n { command_name: CommonDbCommandName.RetrieveInviteUserConstraintsCommand, permission_type: CommonDbPermissionType.EXECUTE },\n ])) {\n _formRoleOptions = inviteUserConstraintsQuery?.data ? inviteUserConstraintsQuery.data.roles.map(role => ({\n label: role,\n value: role,\n })) : _tableRoleOptions;\n } else {\n _formRoleOptions = _tableRoleOptions;\n }\n // The users own roles may not be included in the options from the invite user constraints endpoint (if they don't have permission to view that endpoint),\n // so we need to add those to the options as well, but disable them since the user doesn't have permission to assign those roles to other users.\n const extraRolesFromUser = userRoles.filter(role => !_formRoleOptions.some(option => option.value === role));\n _formRoleOptions.push(...extraRolesFromUser.map(role => ({\n disabled: true,\n label: role,\n value: role,\n })));\n setFormRoleOptions(_formRoleOptions);\n }, [inviteUserConstraintsQuery.data, userRoles]);\n\n const fetchAll = useCallback(async (signal: AbortSignal) => {\n const users = (await rootContainer.resolve(API_ORGANIZATION_TOKEN).usersGetAll(null, null, { signal }))?.data;\n\n return users;\n }, []);\n\n const updateOne = useCallback(async (variables: FormFields, item: CommonDbUser) => {\n return (await rootContainer.resolve(API_ORGANIZATION_TOKEN).updateUser(item.id, {\n is_active: variables.is_active,\n organization_id: item.organization_id,\n roles: variables.roles,\n })).data;\n }, []);\n\n const deleteOne = useCallback(async (item: CommonDbUser) => {\n return await rootContainer.resolve(API_ORGANIZATION_TOKEN).usersDeleteOne(item.id);\n }, []);\n\n const getName = useCallback((item: FormFields) => {\n return item.email;\n }, []);\n\n const canEditItem = useCallback((item: CommonDbUser) => {\n return rootContainer.resolve(AuthorizationService).user.email !== item.email;\n }, []);\n\n const schema = useMemo(() => {\n return object<FormFields>().shape({\n description: SchemaUtil.description,\n email: string().email().nullable(),\n is_active: boolean().required(),\n key: string().optional(),\n name: string().nullable(),\n roles: array().required().min(1),\n });\n }, []);\n\n const formFieldDefinitions = useMemo<FormFieldDefinition<FormFields>[]>(() => {\n return [\n {\n definition: FORM_FIELD_DEFINITION_TYPE.TEXTFIELD,\n disabled: true,\n label: t`Key`,\n name: 'key',\n } as const satisfies FormFieldDefinition<FormFields>,\n {\n definition: FORM_FIELD_DEFINITION_TYPE.TEXTFIELD,\n label: t`Email`,\n name: 'email',\n } as const satisfies FormFieldDefinition<FormFields>,\n {\n definition: FORM_FIELD_DEFINITION_TYPE.TEXTFIELD,\n label: t`Name`,\n name: 'name',\n } as const satisfies FormFieldDefinition<FormFields>,\n {\n definition: FORM_FIELD_DEFINITION_TYPE.AUTOCOMPLETE,\n label: t`Roles`,\n loading: inviteUserConstraintsQuery.isLoading,\n multiple: true,\n name: 'roles',\n options: formRoleOptions,\n } as const satisfies FormFieldDefinition<FormFields>,\n {\n definition: FORM_FIELD_DEFINITION_TYPE.BOOLEAN,\n label: t`Is active`,\n name: 'is_active',\n } as const satisfies FormFieldDefinition<FormFields>,\n {\n definition: FORM_FIELD_DEFINITION_TYPE.TEXTFIELD,\n label: t`Description`,\n name: 'description',\n } as const satisfies FormFieldDefinition<FormFields>,\n ] as const;\n }, [t, formRoleOptions, inviteUserConstraintsQuery.isLoading]);\n\n const tableColumns = useMemo((): TableColumn<CommonDbUser>[] => {\n return [\n TableUtil.createOptionsColumn<CommonDbUser>({ id: 'organization_id', name: t`Organization`, options: organizationOptionsQuery.options }),\n TableUtil.createTextColumn<CommonDbUser>({ id: 'key', name: t`Key` }),\n TableUtil.createTextColumn<CommonDbUser>({ id: 'email', name: t`E-Mail` }),\n TableUtil.createTextColumn<CommonDbUser>({ advancedSort: true, id: 'name', name: t`Name` }),\n TableUtil.createTextColumn<CommonDbUser>({ id: 'description', name: t`Description` }),\n TableUtil.createOptionsColumn<CommonDbUser>({ id: 'roles', name: t`Roles`, options: tableRoleOptions }),\n TableUtil.createBooleanColumn<CommonDbUser>({ id: 'is_active', name: t`Is active` }),\n ];\n }, [organizationOptionsQuery.options, tableRoleOptions, t]);\n\n const getOptimisticUpdateIntermediateItem = useCallback((variables: FormFields, previousItem: CommonDbUser): CommonDbUser => {\n return {\n email: previousItem.email,\n id: previousItem.id,\n is_active: previousItem.is_active,\n key: previousItem.email,\n name: previousItem.name,\n organization_id: previousItem.organization_id,\n ...variables,\n };\n }, []);\n\n const extraUpdateOnePermissions = useMemo<CommonDbApiPermission[]>(() => [\n { command_name: CommonDbCommandName.UpdateUserCommand, permission_type: CommonDbPermissionType.EXECUTE },\n ], []);\n const extraDeleteOnePermissions = useMemo<CommonDbApiPermission[]>(() => [\n { command_name: CommonDbCommandName.UserCrudCommand, permission_type: CommonDbPermissionType.DELETE },\n ], []);\n\n const onAnonymizeUserConfirmationConfirm = useCallback(async () => {\n const userName = selectedUserRef.current?.email ?? selectedUserRef.current?.key;\n const notificationId = rootContainer.resolve(NotificationService).showNotification({\n isLoading: true,\n message: t('Anonymizing user: {{userName}}', { userName }),\n severity: 'info',\n });\n try {\n // Anonymize the user\n await rootContainer.resolve(API_ORGANIZATION_TOKEN).anonymizeUser(selectedUserRef.current.id);\n // Invalidate the users query key so that the users list is refreshed and the anonymized user is no longer visible in the list.\n await rootContainer.resolve(QueryClientService).invalidateQueryKeys(\n rootContainer.resolve(QueryClientService).getQueryKeyDependencies([COMMON_QUERY_KEY.USERS], true),\n );\n rootContainer.resolve(NotificationService).fulfillNotification(notificationId, t('User anonymized successfully: {{userName}}', { userName }), 'success');\n } catch (_error) {\n rootContainer.resolve(NotificationService).fulfillNotification(notificationId, t('Error anonymizing user: {{userName}}', { userName }), 'error');\n }\n }, [t]);\n\n const extraActionsFactory = useCallback((params: TableRowParams<CommonDbUser, null>) => {\n const menuItems: ReactElement[] = [];\n\n if (rootContainer.resolve(AuthorizationService).doesUserHavePermission([\n { command_name: CommonDbCommandName.AnonymizeUserCommand, permission_type: CommonDbPermissionType.EXECUTE },\n ])) {\n menuItems.push(\n <MenuItem\n key={'custom-action-1'}\n // eslint-disable-next-line @eslint-react/kit/jsx-no-bind\n onClick={() => {\n selectedUserRef.current = params.row;\n anonymizeUserConfirmationRef.current.open();\n }}\n >\n <ListItemIcon>\n <PersonOffIcon fontSize={'small'} />\n </ListItemIcon>\n <ListItemText>\n {t`Anonymize user`}\n </ListItemText>\n </MenuItem>,\n );\n }\n\n return menuItems;\n }, [t]);\n\n return (\n <>\n <CrudPage<FormFields, CommonDbUser>\n canEditItem={canEditItem}\n createItemDialogTitle={t`Create new user`}\n defaultSortByField={'name'}\n defaultSortDirection={'asc'}\n deleteOne={deleteOne}\n extraActionsFactory={extraActionsFactory}\n extraDeleteOnePermissions={extraDeleteOnePermissions}\n extraUpdateOnePermissions={extraUpdateOnePermissions}\n fetchAll={fetchAll}\n formFieldDefinitions={formFieldDefinitions}\n getName={getName}\n getOptimisticUpdateIntermediateItem={getOptimisticUpdateIntermediateItem}\n itemName={t`User`}\n loadables={loadables}\n onRowsChange={onRowsChange}\n resourceQueryKeyBase={COMMON_QUERY_KEY.USERS}\n schema={schema}\n subPages={subPages}\n tableColumns={tableColumns}\n testIdAttributes={TestIdUtil.createAttributes('UsersAdminPage')}\n title={t`Users`}\n updateOne={updateOne}\n />\n <Confirmation\n body={t`Click the anonymize button to anonymize the user`}\n cancelLabel={t`Cancel`}\n confirmLabel={t`Anonymize`}\n onConfirm={onAnonymizeUserConfirmationConfirm}\n ref={anonymizeUserConfirmationRef}\n title={t`Are you sure you want to anonymize this user?`}\n />\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8DA,IAAaM,KAAkB,EAC7B,kBACyB;CACzB,IAAM,EAAE,SAAMC,EAAe,GACvBC,IAA+BC,EAA+B,IAAI,GAClEC,IAA2BC,EAA4B,GACvDC,IAA6BC,EAA8B,GAC3D,CAACC,GAAkBC,KAAuBC,EAA+B,CAAC,CAAC,GAC3E,CAACC,GAAiBC,KAAsBF,EAA+B,CAAC,CAAC,GACzEG,IAAkBV,EAA4B,IAAI,GAElDW,IAAYC,EAAS,CACzBX,GACAE,CACF,CAAC,GAEKU,IAAYtB,EAAc,QAAQwB,CAAoB,CAAC,CAAC,KAAK,OAE7DC,IAAeC,GAAa,MAA0B;EAG1D,IAAMC,oBAAQ,IAAI,IAAY;EAC9B,EAAM,SAAS,MAAS;GACtB,EAAK,MAAM,SAAS,MAASA,EAAM,IAAIC,CAAI,CAAC;EAC9C,CAAC;EACD,IAAMC,IAAoB,MA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C,CAAC,GAEAY,KAAsBtC,GAAa,MAA+C;EACtF,IAAMuC,IAA4B,CAAC;EAwBnC,OAtBIjE,EAAc,QAAQwB,CAAoB,CAAC,CAAC,uBAAuB,CACrE;GAAE,cAAcO,EAAoB;GAAsB,iBAAiBC,EAAuB;EAAQ,CAC5G,CAAC,KACCiC,EAAU,KACR,kBAACC,GAAD;GAGE,eAAe;IAEb,AADA,EAAgB,UAAUC,EAAO,KACjC3D,EAA6B,QAAQ,KAAK;GAC5C;GANF,UAAA,CAQE,kBAAC4D,GAAD,EAAA,UACE,kBAAC/D,GAAD,EAAe,UAAU,QAAU,CAAA,EACvB,CAAA,GACd,kBAACgE,GAAD,EAAA,UACG,CAAC,iBACU,CAAA,CACN;EAbH,GAAA,iBAaG,CACZ,GAGKJ;CACT,GAAG,CAACb,CAAC,CAAC;CAEN,OACE,kBAAAnD,GAAA,EAAA,UAAA,CACE,kBAACE,GAAD;EACe;EACb,uBAAuB,CAAC;EACxB,oBAAoB;EACpB,sBAAsB;EACX;EACU;EACM;EACA;EACjB;EACY;EACb;EAC4B;EACrC,UAAU,CAAC;EACA;EACG;EACd,sBAAsB4D,EAAiB;EAC/B;EACE;EACI;EACd,kBAAkBO,EAAW,iBAAiB,gBAAgB;EAC9D,OAAO,CAAC;EACG;CACZ,CAAA,GACD,kBAACC,GAAD;EACE,MAAM,CAAC;EACP,aAAa,CAAC;EACd,cAAc,CAAC;EACf,WAAWb;EACX,KAAKlD;EACL,OAAO,CAAC;CACT,CAAA,CACD,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"index.js","names":["rootContainer","_Fragment","TableUtil","CrudPage","Fragment$1","PersonOffIcon","UsersAdminPage","useTranslation","anonymizeUserConfirmationRef","useRef","organizationOptionsQuery","useOrganizationOptionsQuery","inviteUserConstraintsQuery","useInviteUserConstraintsQuery","tableRoleOptions","setTableRoleOptions","useState","formRoleOptions","setFormRoleOptions","selectedUserRef","loadables","useArray","userRoles","container","AuthorizationService","onRowsChange","useCallback","roles","role","_tableRoleOptions","_formRoleOptions","CommonDbCommandName","CommonDbPermissionType","extraRolesFromUser","option","fetchAll","API_ORGANIZATION_TOKEN","updateOne","item","variables","deleteOne","getName","canEditItem","schema","useMemo","object","SchemaUtil","string","boolean","array","formFieldDefinitions","FORM_FIELD_DEFINITION_TYPE","t","tableColumns","getOptimisticUpdateIntermediateItem","previousItem","extraUpdateOnePermissions","extraDeleteOnePermissions","onAnonymizeUserConfirmationConfirm","userName","notificationId","NotificationService","QueryClientService","COMMON_QUERY_KEY","extraActionsFactory","menuItems","MenuItem","params","ListItemIcon","ListItemText","TestIdUtil","Confirmation"],"sources":["../../../src/pages/UsersAdminPage/UsersAdminPage.tsx"],"sourcesContent":["import { container as rootContainer } from 'tsyringe';\nimport type { ReactElement } from 'react';\nimport {\n useCallback,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport {\n array,\n boolean,\n object,\n string,\n} from 'yup';\nimport type {\n CommonDbApiPermission,\n CommonDbUser,\n} from '@gen-epix/api-commondb';\nimport {\n CommonDbCommandName,\n CommonDbPermissionType,\n} from '@gen-epix/api-commondb';\nimport {\n ListItemIcon,\n ListItemText,\n MenuItem,\n} from '@mui/material';\nimport PersonOffIcon from '@mui/icons-material/PersonOff';\nimport { TestIdUtil } from '@gen-epix/ui-core/utils/TestIdUtil';\nimport { useArray } from '@gen-epix/ui-core/hooks/useArray';\nimport type {\n FormFieldDefinition,\n OptionBase,\n} from '@gen-epix/ui-core-form/models/form.models';\nimport { FORM_FIELD_DEFINITION_TYPE } from '@gen-epix/ui-core-form/models/form.models';\nimport { SchemaUtil } from '@gen-epix/ui-core-form/utils/SchemaUtil';\nimport type { ConfirmationRefMethods } from '@gen-epix/ui-core-components/components/Confirmation';\nimport { Confirmation } from '@gen-epix/ui-core-components/components/Confirmation';\n\nimport { API_ORGANIZATION_TOKEN } from '../../constants/api.constants';\nimport { useOrganizationOptionsQuery } from '../../dataHooks/useOrganizationsQuery';\nimport type {\n TableColumn,\n TableRowParams,\n} from '../../models/table.models';\nimport { TableUtil } from '../../utils/TableUtil';\nimport type { CrudPageProps } from '../CrudPage';\nimport { CrudPage } from '../CrudPage';\nimport { AuthorizationService } from '../../classes/services/AuthorizationService';\nimport { useInviteUserConstraintsQuery } from '../../dataHooks/useInviteUserConstraintsQuery';\nimport type { OmitWithMetaData } from '../../models/data.models';\nimport { COMMON_QUERY_KEY } from '../../constants/query.constants';\nimport { NotificationService } from '../../classes/services/NotificationService';\nimport { QueryClientService } from '../../classes/services/QueryClientService';\n\nexport type UsersAdminPageProps = {\n subPages?: CrudPageProps<OmitWithMetaData<CommonDbUser, 'organization_id' | 'organization'>, CommonDbUser>['subPages'];\n};\n\ntype FormFields = OmitWithMetaData<CommonDbUser, 'organization_id' | 'organization'>;\n\nexport const UsersAdminPage = ({\n subPages,\n}: UsersAdminPageProps) => {\n const { t } = useTranslation();\n const anonymizeUserConfirmationRef = useRef<ConfirmationRefMethods>(null);\n const organizationOptionsQuery = useOrganizationOptionsQuery();\n const inviteUserConstraintsQuery = useInviteUserConstraintsQuery();\n const [tableRoleOptions, setTableRoleOptions] = useState<OptionBase<string>[]>([]);\n const [formRoleOptions, setFormRoleOptions] = useState<OptionBase<string>[]>([]);\n const selectedUserRef = useRef<CommonDbUser | null>(null);\n\n const loadables = useArray([\n organizationOptionsQuery,\n inviteUserConstraintsQuery,\n ]);\n\n const userRoles = rootContainer.resolve(AuthorizationService).user.roles;\n\n const onRowsChange = useCallback((items: CommonDbUser[]) => {\n // Because roles are a string array (instead of an enum or similar), we need to dynamically determine the options for the roles column in the table and in the form.\n // The options for the form are determined by the invite user constraints endpoint, but if the user doesn't have access to that endpoint, we fall back to using the roles that are currently in use by users in the system.\n const roles = new Set<string>();\n items.forEach((user) => {\n user.roles.forEach((role) => roles.add(role));\n });\n const _tableRoleOptions = Array.from(roles).map((role) => ({\n label: role,\n value: role,\n }));\n setTableRoleOptions(_tableRoleOptions);\n let _formRoleOptions: OptionBase<string>[];\n if (rootContainer.resolve(AuthorizationService).doesUserHavePermission([\n { command_name: CommonDbCommandName.RetrieveInviteUserConstraintsCommand, permission_type: CommonDbPermissionType.EXECUTE },\n ])) {\n _formRoleOptions = inviteUserConstraintsQuery?.data ? inviteUserConstraintsQuery.data.roles.map(role => ({\n label: role,\n value: role,\n })) : _tableRoleOptions;\n } else {\n _formRoleOptions = _tableRoleOptions;\n }\n // The users own roles may not be included in the options from the invite user constraints endpoint (if they don't have permission to view that endpoint),\n // so we need to add those to the options as well, but disable them since the user doesn't have permission to assign those roles to other users.\n const extraRolesFromUser = userRoles.filter(role => !_formRoleOptions.some(option => option.value === role));\n _formRoleOptions.push(...extraRolesFromUser.map(role => ({\n disabled: true,\n label: role,\n value: role,\n })));\n setFormRoleOptions(_formRoleOptions);\n }, [inviteUserConstraintsQuery.data, userRoles]);\n\n const fetchAll = useCallback(async (signal: AbortSignal) => {\n const users = (await rootContainer.resolve(API_ORGANIZATION_TOKEN).usersGetAll(null, null, { signal }))?.data;\n\n return users;\n }, []);\n\n const updateOne = useCallback(async (variables: FormFields, item: CommonDbUser) => {\n return (await rootContainer.resolve(API_ORGANIZATION_TOKEN).updateUser(item.id, {\n is_active: variables.is_active,\n organization_id: item.organization_id,\n roles: variables.roles,\n })).data;\n }, []);\n\n const deleteOne = useCallback(async (item: CommonDbUser) => {\n return await rootContainer.resolve(API_ORGANIZATION_TOKEN).usersDeleteOne(item.id);\n }, []);\n\n const getName = useCallback((item: FormFields) => {\n return item.email;\n }, []);\n\n const canEditItem = useCallback((item: CommonDbUser) => {\n return rootContainer.resolve(AuthorizationService).user.email !== item.email;\n }, []);\n\n const schema = useMemo(() => {\n return object<FormFields>().shape({\n description: SchemaUtil.description,\n email: string().email().nullable(),\n is_active: boolean().required(),\n key: string().optional(),\n name: string().nullable(),\n roles: array().required().min(1),\n });\n }, []);\n\n const formFieldDefinitions = useMemo<FormFieldDefinition<FormFields>[]>(() => {\n return [\n {\n definition: FORM_FIELD_DEFINITION_TYPE.TEXTFIELD,\n disabled: true,\n label: t`Key`,\n name: 'key',\n } as const satisfies FormFieldDefinition<FormFields>,\n {\n definition: FORM_FIELD_DEFINITION_TYPE.TEXTFIELD,\n label: t`Email`,\n name: 'email',\n } as const satisfies FormFieldDefinition<FormFields>,\n {\n definition: FORM_FIELD_DEFINITION_TYPE.TEXTFIELD,\n label: t`Name`,\n name: 'name',\n } as const satisfies FormFieldDefinition<FormFields>,\n {\n definition: FORM_FIELD_DEFINITION_TYPE.AUTOCOMPLETE,\n label: t`Roles`,\n loading: inviteUserConstraintsQuery.isLoading,\n multiple: true,\n name: 'roles',\n options: formRoleOptions,\n } as const satisfies FormFieldDefinition<FormFields>,\n {\n definition: FORM_FIELD_DEFINITION_TYPE.BOOLEAN,\n label: t`Is active`,\n name: 'is_active',\n } as const satisfies FormFieldDefinition<FormFields>,\n {\n definition: FORM_FIELD_DEFINITION_TYPE.TEXTFIELD,\n label: t`Description`,\n name: 'description',\n } as const satisfies FormFieldDefinition<FormFields>,\n ] as const;\n }, [t, formRoleOptions, inviteUserConstraintsQuery.isLoading]);\n\n const tableColumns = useMemo((): TableColumn<CommonDbUser>[] => {\n return [\n TableUtil.createOptionsColumn<CommonDbUser>({ id: 'organization_id', name: t`Organization`, options: organizationOptionsQuery.options }),\n TableUtil.createTextColumn<CommonDbUser>({ id: 'key', name: t`Key` }),\n TableUtil.createTextColumn<CommonDbUser>({ id: 'email', name: t`E-Mail` }),\n TableUtil.createTextColumn<CommonDbUser>({ advancedSort: true, id: 'name', name: t`Name` }),\n TableUtil.createTextColumn<CommonDbUser>({ id: 'description', name: t`Description` }),\n TableUtil.createOptionsColumn<CommonDbUser>({ id: 'roles', name: t`Roles`, options: tableRoleOptions }),\n TableUtil.createBooleanColumn<CommonDbUser>({ id: 'is_active', name: t`Is active` }),\n ];\n }, [organizationOptionsQuery.options, tableRoleOptions, t]);\n\n const getOptimisticUpdateIntermediateItem = useCallback((variables: FormFields, previousItem: CommonDbUser): CommonDbUser => {\n return {\n email: previousItem.email,\n id: previousItem.id,\n is_active: previousItem.is_active,\n key: previousItem.email,\n name: previousItem.name,\n organization_id: previousItem.organization_id,\n ...variables,\n };\n }, []);\n\n const extraUpdateOnePermissions = useMemo<CommonDbApiPermission[]>(() => [\n { command_name: CommonDbCommandName.UpdateUserCommand, permission_type: CommonDbPermissionType.EXECUTE },\n ], []);\n const extraDeleteOnePermissions = useMemo<CommonDbApiPermission[]>(() => [\n { command_name: CommonDbCommandName.UserCrudCommand, permission_type: CommonDbPermissionType.DELETE },\n ], []);\n\n const onAnonymizeUserConfirmationConfirm = useCallback(async () => {\n const userName = selectedUserRef.current?.email ?? selectedUserRef.current?.key;\n const notificationId = rootContainer.resolve(NotificationService).showNotification({\n isLoading: true,\n message: t('Anonymizing user: {{userName}}', { userName }),\n severity: 'info',\n });\n try {\n // Anonymize the user\n await rootContainer.resolve(API_ORGANIZATION_TOKEN).anonymizeUser(selectedUserRef.current.id);\n // Invalidate the users query key so that the users list is refreshed and the anonymized user is no longer visible in the list.\n await rootContainer.resolve(QueryClientService).invalidateQueryKeys(\n rootContainer.resolve(QueryClientService).getQueryKeyDependencies([COMMON_QUERY_KEY.USERS], true),\n );\n rootContainer.resolve(NotificationService).fulfillNotification(notificationId, t('User anonymized successfully: {{userName}}', { userName }), 'success');\n } catch (_error) {\n rootContainer.resolve(NotificationService).fulfillNotification(notificationId, t('Error anonymizing user: {{userName}}', { userName }), 'error');\n }\n }, [t]);\n\n const extraActionsFactory = useCallback((params: TableRowParams<CommonDbUser, null>) => {\n const menuItems: ReactElement[] = [];\n\n if (rootContainer.resolve(AuthorizationService).doesUserHavePermission([\n { command_name: CommonDbCommandName.AnonymizeUserCommand, permission_type: CommonDbPermissionType.EXECUTE },\n ])) {\n menuItems.push(\n <MenuItem\n key={'custom-action-1'}\n // eslint-disable-next-line @eslint-react/kit/jsx-no-bind\n onClick={() => {\n selectedUserRef.current = params.row;\n anonymizeUserConfirmationRef.current.open();\n }}\n >\n <ListItemIcon>\n <PersonOffIcon fontSize={'small'} />\n </ListItemIcon>\n <ListItemText>\n {t`Anonymize user`}\n </ListItemText>\n </MenuItem>,\n );\n }\n\n return menuItems;\n }, [t]);\n\n return (\n <>\n <CrudPage<FormFields, CommonDbUser>\n canEditItem={canEditItem}\n createItemDialogTitle={t`Create new user`}\n defaultSortByField={'name'}\n defaultSortDirection={'asc'}\n deleteOne={deleteOne}\n extraActionsFactory={extraActionsFactory}\n extraDeleteOnePermissions={extraDeleteOnePermissions}\n extraUpdateOnePermissions={extraUpdateOnePermissions}\n fetchAll={fetchAll}\n formFieldDefinitions={formFieldDefinitions}\n getName={getName}\n getOptimisticUpdateIntermediateItem={getOptimisticUpdateIntermediateItem}\n itemName={t`User`}\n loadables={loadables}\n onRowsChange={onRowsChange}\n resourceQueryKeyBase={COMMON_QUERY_KEY.USERS}\n schema={schema}\n subPages={subPages}\n tableColumns={tableColumns}\n testIdAttributes={TestIdUtil.createAttributes('UsersAdminPage')}\n title={t`Users`}\n updateOne={updateOne}\n />\n <Confirmation\n body={t`Click the anonymize button to anonymize the user`}\n cancelLabel={t`Cancel`}\n confirmLabel={t`Anonymize`}\n onConfirm={onAnonymizeUserConfirmationConfirm}\n ref={anonymizeUserConfirmationRef}\n title={t`Are you sure you want to anonymize this user?`}\n />\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8DA,IAAaM,KAAkB,EAC7B,kBACyB;CACzB,IAAM,EAAE,SAAMC,EAAe,GACvBC,IAA+BC,EAA+B,IAAI,GAClEC,IAA2BC,EAA4B,GACvDC,IAA6BC,EAA8B,GAC3D,CAACC,GAAkBC,KAAuBC,EAA+B,CAAC,CAAC,GAC3E,CAACC,GAAiBC,KAAsBF,EAA+B,CAAC,CAAC,GACzEG,IAAkBV,EAA4B,IAAI,GAElDW,IAAYC,EAAS,CACzBX,GACAE,CACF,CAAC,GAEKU,IAAYtB,EAAc,QAAQwB,CAAoB,CAAC,CAAC,KA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E,8CAA8C,EAAE,YAAS,CAAC,GAAG,SAAS;EACzJ,QAAiB;GACf,EAAc,QAAQS,CAAmB,CAAC,CAAC,oBAAoBD,GAAgBR,EAAE,wCAAwC,EAAE,YAAS,CAAC,GAAG,OAAO;EACjJ;CACF,GAAG,CAACA,CAAC,CAAC,GAEAY,KAAsBtC,GAAa,MAA+C;EACtF,IAAMuC,IAA4B,CAAC;EAwBnC,OAtBIjE,EAAc,QAAQwB,CAAoB,CAAC,CAAC,uBAAuB,CACrE;GAAE,cAAcO,EAAoB;GAAsB,iBAAiBC,EAAuB;EAAQ,CAC5G,CAAC,KACCiC,EAAU,KACR,kBAACC,GAAD;GAGE,eAAe;IAEb,AADA,EAAgB,UAAUC,EAAO,KACjC3D,EAA6B,QAAQ,KAAK;GAC5C;GANF,UAAA,CAQE,kBAAC4D,GAAD,EAAA,UACE,kBAAC/D,GAAD,EAAe,UAAU,QAAU,CAAA,EACvB,CAAA,GACd,kBAACgE,GAAD,EAAA,UACG,CAAC,iBACU,CAAA,CACN;EAbH,GAAA,iBAaG,CACZ,GAGKJ;CACT,GAAG,CAACb,CAAC,CAAC;CAEN,OACE,kBAAAnD,GAAA,EAAA,UAAA,CACE,kBAACE,GAAD;EACe;EACb,uBAAuB,CAAC;EACxB,oBAAoB;EACpB,sBAAsB;EACX;EACU;EACM;EACA;EACjB;EACY;EACb;EAC4B;EACrC,UAAU,CAAC;EACA;EACG;EACd,sBAAsB4D,EAAiB;EAC/B;EACE;EACI;EACd,kBAAkBO,EAAW,iBAAiB,gBAAgB;EAC9D,OAAO,CAAC;EACG;CACZ,CAAA,GACD,kBAACC,GAAD;EACE,MAAM,CAAC;EACP,aAAa,CAAC;EACd,cAAc,CAAC;EACf,WAAWb;EACX,KAAKlD;EACL,OAAO,CAAC;CACT,CAAA,CACD,EAAA,CAAA;AAEN"}
@@ -0,0 +1,6 @@
1
+ import { DependencyContainer } from 'tsyringe';
2
+ import { ConfigBase } from '../../models/config.models';
3
+ export declare class DependencyContainerUtil {
4
+ static createUiClientCommonContainer<TConfig extends ConfigBase>(config: TConfig): DependencyContainer;
5
+ static resolveConfig<TConfig extends ConfigBase = ConfigBase>(container?: DependencyContainer): TConfig;
6
+ }
@@ -0,0 +1 @@
1
+ export * from './DependencyContainerUtil';
@@ -0,0 +1,22 @@
1
+ import { t as e } from "../../_chunks/QueryClientService.js";
2
+ import { t } from "../../_chunks/Reflect.js";
3
+ import { CONFIG_TOKEN as n, WINDOW_SERVICE_TOKEN as r } from "../../constants/config.constants.js";
4
+ import { WindowService as i } from "@gen-epix/ui-core/classes/services/WindowService";
5
+ import { container as a } from "tsyringe";
6
+ t();
7
+ var o = class {
8
+ static createUiClientCommonContainer(t) {
9
+ let o = a;
10
+ return o.register(n, { useValue: t }), o.registerInstance(r, i.getInstance()), o.register(e, { useFactory: () => new e({
11
+ config: t,
12
+ queryKeyDependencies: []
13
+ }) }), o;
14
+ }
15
+ static resolveConfig(e = a) {
16
+ return e.resolve(n);
17
+ }
18
+ };
19
+ //#endregion
20
+ export { o as DependencyContainerUtil };
21
+
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["container","rootContainer","QueryClientService","require_Reflect","DependencyContainerUtil","container$1","container","CONFIG_TOKEN","config","WINDOW_SERVICE_TOKEN","WindowService","container$2"],"sources":["../../../src/utils/DependencyContainerUtil/DependencyContainerUtil.ts"],"sourcesContent":["import 'reflect-metadata';\nimport { container as rootContainer } from 'tsyringe';\nimport type { DependencyContainer } from 'tsyringe';\nimport { WindowService } from '@gen-epix/ui-core/classes/services/WindowService';\n\nimport { QueryClientService } from '../../classes/services/QueryClientService';\nimport {\n CONFIG_TOKEN,\n WINDOW_SERVICE_TOKEN,\n} from '../../constants/config.constants';\nimport type { ConfigBase } from '../../models/config.models';\n\nexport class DependencyContainerUtil {\n public static createUiClientCommonContainer<TConfig extends ConfigBase>(config: TConfig): DependencyContainer {\n const container = rootContainer;\n container.register(CONFIG_TOKEN, { useValue: config });\n container.registerInstance(WINDOW_SERVICE_TOKEN, WindowService.getInstance());\n container.register(QueryClientService, {\n // eslint-disable-next-line @eslint-react/no-unnecessary-use-prefix\n useFactory: () => new QueryClientService({\n config,\n queryKeyDependencies: [],\n }),\n });\n return container;\n }\n\n public static resolveConfig<TConfig extends ConfigBase = ConfigBase>(container: DependencyContainer = rootContainer): TConfig {\n return container.resolve(CONFIG_TOKEN) as TConfig;\n }\n}\n"],"mappings":";;;;;;AAYA,IAAaI,IAAb,MAAqC;CACnC,OAAc,8BAA0D,GAAsC;EAC5G,IAAMJ,IAAYC;EAUlB,OATAI,EAAU,SAASE,GAAc,EAAE,UAAUC,EAAO,CAAC,GACrDH,EAAU,iBAAiBI,GAAsBC,EAAc,YAAY,CAAC,GAC5EL,EAAU,SAASH,GAAoB,EAErC,kBAAkB,IAAIA,EAAmB;GACvC;GACA,sBAAsB,CAAC;EACzB,CAAC,EACH,CAAC,GACMF;CACT;CAEA,OAAc,cAAuD,IAAiCC,GAAwB;EAC5H,OAAOD,EAAU,QAAQO,CAAY;CACvC;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gen-epix/ui-client-common",
3
- "version": "4.4.0",
3
+ "version": "4.4.1",
4
4
  "homepage": "https://github.com/RIVM-bioinformatics/gen-epix",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,10 +22,6 @@
22
22
  "types": "./dist/classes/abstracts/FilterAbstract/index.d.ts",
23
23
  "import": "./dist/classes/abstracts/FilterAbstract/index.js"
24
24
  },
25
- "./classes/containers/UiClientCommonContainer": {
26
- "types": "./dist/classes/containers/UiClientCommonContainer/index.d.ts",
27
- "import": "./dist/classes/containers/UiClientCommonContainer/index.js"
28
- },
29
25
  "./classes/filters": {
30
26
  "types": "./dist/classes/filters/index.d.ts",
31
27
  "import": "./dist/classes/filters/index.js"
@@ -214,6 +210,10 @@
214
210
  "types": "./dist/components/ui/UserInactivityConfirmation/index.d.ts",
215
211
  "import": "./dist/components/ui/UserInactivityConfirmation/index.js"
216
212
  },
213
+ "./constants/api.constants": {
214
+ "types": "./dist/constants/api.constants.d.ts",
215
+ "import": "./dist/constants/api.constants.js"
216
+ },
217
217
  "./constants/config.constants": {
218
218
  "types": "./dist/constants/config.constants.d.ts",
219
219
  "import": "./dist/constants/config.constants.js"
@@ -442,6 +442,10 @@
442
442
  "types": "./dist/utils/DataHookUtil/index.d.ts",
443
443
  "import": "./dist/utils/DataHookUtil/index.js"
444
444
  },
445
+ "./utils/DependencyContainerUtil": {
446
+ "types": "./dist/utils/DependencyContainerUtil/index.d.ts",
447
+ "import": "./dist/utils/DependencyContainerUtil/index.js"
448
+ },
445
449
  "./utils/LoadableUtil": {
446
450
  "types": "./dist/utils/LoadableUtil/index.d.ts",
447
451
  "import": "./dist/utils/LoadableUtil/index.js"
@@ -1,5 +0,0 @@
1
- import { DependencyContainer } from 'tsyringe';
2
- import { ConfigBase } from '../../../models/config.models';
3
- export type UiClientCommonContainer = DependencyContainer;
4
- export declare const createUiClientCommonContainer: <TConfig extends ConfigBase>(config: TConfig) => UiClientCommonContainer;
5
- export declare const resolveConfig: <TConfig extends ConfigBase = ConfigBase>(container?: UiClientCommonContainer) => TConfig;
@@ -1 +0,0 @@
1
- export * from './UiClientCommonContainer';
@@ -1,17 +0,0 @@
1
- import { t as e } from "../../../_chunks/QueryClientService.js";
2
- import { t } from "../../../_chunks/Reflect.js";
3
- import { CONFIG_TOKEN as n, WINDOW_SERVICE_TOKEN as r } from "../../../constants/config.constants.js";
4
- import { WindowService as i } from "@gen-epix/ui-core/classes/services/WindowService";
5
- import { container as a } from "tsyringe";
6
- t();
7
- var o = (t) => {
8
- let o = a;
9
- return o.register(n, { useValue: t }), o.registerInstance(r, i.getInstance()), o.register(e, { useFactory: () => new e({
10
- config: t,
11
- queryKeyDependencies: []
12
- }) }), o;
13
- }, s = (e = a) => e.resolve(n);
14
- //#endregion
15
- export { o as createUiClientCommonContainer, s as resolveConfig };
16
-
17
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["container","rootContainer","QueryClientService","require_Reflect","createUiClientCommonContainer","container$1","container","CONFIG_TOKEN","config","WINDOW_SERVICE_TOKEN","WindowService","resolveConfig","container$2"],"sources":["../../../../src/classes/containers/UiClientCommonContainer/UiClientCommonContainer.ts"],"sourcesContent":["import 'reflect-metadata';\nimport { container as rootContainer } from 'tsyringe';\nimport type { DependencyContainer } from 'tsyringe';\nimport { WindowService } from '@gen-epix/ui-core/classes/services/WindowService';\n\nimport { QueryClientService } from '../../services/QueryClientService';\nimport {\n CONFIG_TOKEN,\n WINDOW_SERVICE_TOKEN,\n} from '../../../constants/config.constants';\nimport type { ConfigBase } from '../../../models/config.models';\n\nexport type UiClientCommonContainer = DependencyContainer;\n\nexport const createUiClientCommonContainer = <TConfig extends ConfigBase>(config: TConfig): UiClientCommonContainer => {\n const container = rootContainer;\n container.register(CONFIG_TOKEN, { useValue: config });\n container.registerInstance(WINDOW_SERVICE_TOKEN, WindowService.getInstance());\n container.register(QueryClientService, {\n // tsyringe uses this option name; it is not a React hook.\n // eslint-disable-next-line @eslint-react/no-unnecessary-use-prefix\n useFactory: () => new QueryClientService({\n config,\n queryKeyDependencies: [],\n }),\n });\n return container;\n};\n\nexport const resolveConfig = <TConfig extends ConfigBase = ConfigBase>(container: UiClientCommonContainer = rootContainer): TConfig => {\n return container.resolve(CONFIG_TOKEN) as TConfig;\n};\n"],"mappings":";;;;;;AAcA,IAAaI,KAA6D,MAA6C;CACrH,IAAMJ,IAAYC;CAWlB,OAVAI,EAAU,SAASE,GAAc,EAAE,UAAUC,EAAO,CAAC,GACrDH,EAAU,iBAAiBI,GAAsBC,EAAc,YAAY,CAAC,GAC5EL,EAAU,SAASH,GAAoB,EAGrC,kBAAkB,IAAIA,EAAmB;EACvC;EACA,sBAAsB,CAAC;CACzB,CAAC,EACH,CAAC,GACMF;AACT,GAEaW,KAA0D,IAAqCV,MACnGD,EAAU,QAAQO,CAAY"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.models.js","names":["API_BASE_TOKEN","API_ABAC_TOKEN","API_AUTH_TOKEN","API_ORGANIZATION_TOKEN","API_SYSTEM_TOKEN"],"sources":["../../src/models/api.models.ts"],"sourcesContent":["import type {\n AxiosResponse,\n InternalAxiosRequestConfig,\n} from 'axios';\nimport type {\n CommonDbAbacApi,\n CommonDbAuthApi,\n CommonDbOrganizationApi,\n CommonDbSystemApi,\n} from '@gen-epix/api-commondb';\nimport type { InjectionToken } from 'tsyringe';\n\nexport interface BaseApi {\n accessToken: string;\n baseUrl: string;\n defaultRequestTimeout: number;\n onRequest: Array<(request: InternalAxiosRequestConfig) => InternalAxiosRequestConfig<unknown>>;\n onResponseFulfilled: Array<(response: AxiosResponse) => AxiosResponse>;\n onResponseRejected: Array<(error: unknown) => void>;\n}\n\nexport const API_BASE_TOKEN: InjectionToken<BaseApi> = Symbol('API_BASE_TOKEN');\nexport const API_ABAC_TOKEN: InjectionToken<CommonDbAbacApi> = Symbol('API_ABAC_TOKEN');\nexport const API_AUTH_TOKEN: InjectionToken<CommonDbAuthApi> = Symbol('API_AUTH_TOKEN');\nexport const API_ORGANIZATION_TOKEN: InjectionToken<CommonDbOrganizationApi> = Symbol('API_ORGANIZATION_TOKEN');\nexport const API_SYSTEM_TOKEN: InjectionToken<CommonDbSystemApi> = Symbol('API_SYSTEM_TOKEN');\n"],"mappings":";AAqBA,IAAaA,IAA0C,OAAO,gBAAgB,GACjEC,IAAkD,OAAO,gBAAgB,GACzEC,IAAkD,OAAO,gBAAgB,GACzEC,IAAkE,OAAO,wBAAwB,GACjGC,IAAsD,OAAO,kBAAkB"}