@ynput/ayon-frontend-shared 0.2.39 → 0.2.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DetailsPanel.cjs.js +1 -1
- package/dist/DetailsPanel.es.js +24 -22
- package/dist/DetailsPanel.es.js.map +1 -1
- package/dist/api.cjs.js +1 -1
- package/dist/api.es.js +256 -248
- package/dist/api.es.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +11 -9
- package/dist/index.es.js.map +1 -1
- package/dist/shared/src/api/queries/activities/util/activityRealtimeHandler.cjs.js +1 -1
- package/dist/shared/src/api/queries/activities/util/activityRealtimeHandler.cjs.js.map +1 -1
- package/dist/shared/src/api/queries/activities/util/activityRealtimeHandler.es.js +16 -16
- package/dist/shared/src/api/queries/activities/util/activityRealtimeHandler.es.js.map +1 -1
- package/dist/shared/src/api/queries/config/getConfig.cjs.js +2 -0
- package/dist/shared/src/api/queries/config/getConfig.cjs.js.map +1 -0
- package/dist/shared/src/api/queries/config/getConfig.es.js +111 -0
- package/dist/shared/src/api/queries/config/getConfig.es.js.map +1 -0
- package/dist/shared/src/api/queries/config/updateConfig.cjs.js +2 -0
- package/dist/shared/src/api/queries/config/updateConfig.cjs.js.map +1 -0
- package/dist/shared/src/api/queries/config/updateConfig.es.js +13 -0
- package/dist/shared/src/api/queries/config/updateConfig.es.js.map +1 -0
- package/dist/shared/src/api/queries/entities/transformDetailsPanelData.cjs.js +1 -1
- package/dist/shared/src/api/queries/entities/transformDetailsPanelData.cjs.js.map +1 -1
- package/dist/shared/src/api/queries/entities/transformDetailsPanelData.es.js +5 -3
- package/dist/shared/src/api/queries/entities/transformDetailsPanelData.es.js.map +1 -1
- package/dist/shared/src/api/queries/entities/updateEntity.cjs.js +1 -1
- package/dist/shared/src/api/queries/entities/updateEntity.cjs.js.map +1 -1
- package/dist/shared/src/api/queries/entities/updateEntity.es.js +5 -3
- package/dist/shared/src/api/queries/entities/updateEntity.es.js.map +1 -1
- package/dist/shared/src/api/queries/links/getEntityLinks.cjs.js +1 -1
- package/dist/shared/src/api/queries/links/getEntityLinks.cjs.js.map +1 -1
- package/dist/shared/src/api/queries/links/getEntityLinks.es.js +106 -86
- package/dist/shared/src/api/queries/links/getEntityLinks.es.js.map +1 -1
- package/dist/shared/src/api/queries/overview/updateOverview.cjs.js +1 -1
- package/dist/shared/src/api/queries/overview/updateOverview.cjs.js.map +1 -1
- package/dist/shared/src/api/queries/overview/updateOverview.es.js +68 -66
- package/dist/shared/src/api/queries/overview/updateOverview.es.js.map +1 -1
- package/dist/shared/src/api/queries/users/getUsers.cjs.js +2 -2
- package/dist/shared/src/api/queries/users/getUsers.cjs.js.map +1 -1
- package/dist/shared/src/api/queries/users/getUsers.es.js +34 -32
- package/dist/shared/src/api/queries/users/getUsers.es.js.map +1 -1
- package/dist/shared/src/components/AddonLoadingScreen/AddonLoadingScreen.cjs.js +8 -7
- package/dist/shared/src/components/AddonLoadingScreen/AddonLoadingScreen.cjs.js.map +1 -1
- package/dist/shared/src/components/AddonLoadingScreen/AddonLoadingScreen.es.js +24 -20
- package/dist/shared/src/components/AddonLoadingScreen/AddonLoadingScreen.es.js.map +1 -1
- package/dist/shared/src/components/Chips/Chips.cjs.js +10 -6
- package/dist/shared/src/components/Chips/Chips.cjs.js.map +1 -1
- package/dist/shared/src/components/Chips/Chips.es.js +44 -38
- package/dist/shared/src/components/Chips/Chips.es.js.map +1 -1
- package/dist/shared/src/components/DetailsDialog/DetailsDialog.cjs.js +1 -1
- package/dist/shared/src/components/DetailsDialog/DetailsDialog.cjs.js.map +1 -1
- package/dist/shared/src/components/DetailsDialog/DetailsDialog.es.js +4 -2
- package/dist/shared/src/components/DetailsDialog/DetailsDialog.es.js.map +1 -1
- package/dist/shared/src/components/DetailsPanelAttributes/components/RenderFieldWidget.cjs.js +1 -1
- package/dist/shared/src/components/DetailsPanelAttributes/components/RenderFieldWidget.cjs.js.map +1 -1
- package/dist/shared/src/components/DetailsPanelAttributes/components/RenderFieldWidget.es.js +4 -2
- package/dist/shared/src/components/DetailsPanelAttributes/components/RenderFieldWidget.es.js.map +1 -1
- package/dist/shared/src/components/DetailsPanelDetails/DescriptionSection.cjs.js +1 -1
- package/dist/shared/src/components/DetailsPanelDetails/DescriptionSection.cjs.js.map +1 -1
- package/dist/shared/src/components/DetailsPanelDetails/DescriptionSection.es.js +4 -2
- package/dist/shared/src/components/DetailsPanelDetails/DescriptionSection.es.js.map +1 -1
- package/dist/shared/src/components/DetailsPanelDetails/DetailsPanelDetails.cjs.js +1 -1
- package/dist/shared/src/components/DetailsPanelDetails/DetailsPanelDetails.cjs.js.map +1 -1
- package/dist/shared/src/components/DetailsPanelDetails/DetailsPanelDetails.es.js +4 -2
- package/dist/shared/src/components/DetailsPanelDetails/DetailsPanelDetails.es.js.map +1 -1
- package/dist/shared/src/components/DetailsPanelDetails/hooks/useEntityEditing.cjs.js +1 -1
- package/dist/shared/src/components/DetailsPanelDetails/hooks/useEntityEditing.cjs.js.map +1 -1
- package/dist/shared/src/components/DetailsPanelDetails/hooks/useEntityEditing.es.js +4 -2
- package/dist/shared/src/components/DetailsPanelDetails/hooks/useEntityEditing.es.js.map +1 -1
- package/dist/shared/src/components/EntityPanelUploader/EntityPanelUploader.cjs.js +1 -1
- package/dist/shared/src/components/EntityPanelUploader/EntityPanelUploader.cjs.js.map +1 -1
- package/dist/shared/src/components/EntityPanelUploader/EntityPanelUploader.es.js +4 -2
- package/dist/shared/src/components/EntityPanelUploader/EntityPanelUploader.es.js.map +1 -1
- package/dist/shared/src/components/Feedback/FeedbackContext.cjs.js +1 -1
- package/dist/shared/src/components/Feedback/FeedbackContext.cjs.js.map +1 -1
- package/dist/shared/src/components/Feedback/FeedbackContext.es.js +6 -4
- package/dist/shared/src/components/Feedback/FeedbackContext.es.js.map +1 -1
- package/dist/shared/src/components/LinksManager/AddNewLinks.cjs.js +1 -1
- package/dist/shared/src/components/LinksManager/AddNewLinks.cjs.js.map +1 -1
- package/dist/shared/src/components/LinksManager/AddNewLinks.es.js +4 -2
- package/dist/shared/src/components/LinksManager/AddNewLinks.es.js.map +1 -1
- package/dist/shared/src/components/LinksManager/LinkManagerItem.cjs.js +1 -1
- package/dist/shared/src/components/LinksManager/LinkManagerItem.cjs.js.map +1 -1
- package/dist/shared/src/components/LinksManager/LinkManagerItem.es.js +28 -25
- package/dist/shared/src/components/LinksManager/LinkManagerItem.es.js.map +1 -1
- package/dist/shared/src/components/LinksManager/LinksManager.cjs.js.map +1 -1
- package/dist/shared/src/components/LinksManager/LinksManager.es.js.map +1 -1
- package/dist/shared/src/components/LinksManager/LinksManager.styled.cjs.js +5 -0
- package/dist/shared/src/components/LinksManager/LinksManager.styled.cjs.js.map +1 -1
- package/dist/shared/src/components/LinksManager/LinksManager.styled.es.js +5 -0
- package/dist/shared/src/components/LinksManager/LinksManager.styled.es.js.map +1 -1
- package/dist/shared/src/components/LinksManager/hooks/useUpdateLinks.cjs.js +1 -1
- package/dist/shared/src/components/LinksManager/hooks/useUpdateLinks.cjs.js.map +1 -1
- package/dist/shared/src/components/LinksManager/hooks/useUpdateLinks.es.js +4 -2
- package/dist/shared/src/components/LinksManager/hooks/useUpdateLinks.es.js.map +1 -1
- package/dist/shared/src/components/ListAttributeForm/ListAttributeForm.cjs.js +1 -1
- package/dist/shared/src/components/ListAttributeForm/ListAttributeForm.cjs.js.map +1 -1
- package/dist/shared/src/components/ListAttributeForm/ListAttributeForm.es.js +4 -2
- package/dist/shared/src/components/ListAttributeForm/ListAttributeForm.es.js.map +1 -1
- package/dist/shared/src/components/Powerpack/PowerpackDialog.cjs.js +1 -1
- package/dist/shared/src/components/Powerpack/PowerpackDialog.cjs.js.map +1 -1
- package/dist/shared/src/components/Powerpack/PowerpackDialog.es.js +4 -2
- package/dist/shared/src/components/Powerpack/PowerpackDialog.es.js.map +1 -1
- package/dist/shared/src/components/ProjectTableSettings/ProjectTableSettings.cjs.js +1 -1
- package/dist/shared/src/components/ProjectTableSettings/ProjectTableSettings.cjs.js.map +1 -1
- package/dist/shared/src/components/ProjectTableSettings/ProjectTableSettings.es.js +6 -4
- package/dist/shared/src/components/ProjectTableSettings/ProjectTableSettings.es.js.map +1 -1
- package/dist/shared/src/components/ProjectTableSettings/TableSettingsFallback.cjs.js +1 -1
- package/dist/shared/src/components/ProjectTableSettings/TableSettingsFallback.cjs.js.map +1 -1
- package/dist/shared/src/components/ProjectTableSettings/TableSettingsFallback.es.js +4 -2
- package/dist/shared/src/components/ProjectTableSettings/TableSettingsFallback.es.js.map +1 -1
- package/dist/shared/src/components/RenameForm/RenameForm.cjs.js +1 -1
- package/dist/shared/src/components/RenameForm/RenameForm.cjs.js.map +1 -1
- package/dist/shared/src/components/RenameForm/RenameForm.es.js +4 -2
- package/dist/shared/src/components/RenameForm/RenameForm.es.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/EditReviewableDialog.cjs.js +1 -1
- package/dist/shared/src/components/ReviewablesList/EditReviewableDialog.cjs.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/EditReviewableDialog.es.js +4 -2
- package/dist/shared/src/components/ReviewablesList/EditReviewableDialog.es.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/ReviewablesList.cjs.js +1 -1
- package/dist/shared/src/components/ReviewablesList/ReviewablesList.cjs.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/ReviewablesList.es.js +4 -2
- package/dist/shared/src/components/ReviewablesList/ReviewablesList.es.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/ReviewablesUpload.cjs.js +1 -1
- package/dist/shared/src/components/ReviewablesList/ReviewablesUpload.cjs.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/ReviewablesUpload.es.js +5 -3
- package/dist/shared/src/components/ReviewablesList/ReviewablesUpload.es.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/SortableReviewableCard.cjs.js +1 -1
- package/dist/shared/src/components/ReviewablesList/SortableReviewableCard.cjs.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/SortableReviewableCard.es.js +4 -2
- package/dist/shared/src/components/ReviewablesList/SortableReviewableCard.es.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/useReviewablesUpload.cjs.js +1 -1
- package/dist/shared/src/components/ReviewablesList/useReviewablesUpload.cjs.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/useReviewablesUpload.es.js +4 -2
- package/dist/shared/src/components/ReviewablesList/useReviewablesUpload.es.js.map +1 -1
- package/dist/shared/src/components/SearchFilter/useBuildFilterOptions.cjs.js +1 -1
- package/dist/shared/src/components/SearchFilter/useBuildFilterOptions.cjs.js.map +1 -1
- package/dist/shared/src/components/SearchFilter/useBuildFilterOptions.es.js +8 -6
- package/dist/shared/src/components/SearchFilter/useBuildFilterOptions.es.js.map +1 -1
- package/dist/shared/src/components/SimpleFormDialog/SimpleFormDialog.cjs.js +1 -1
- package/dist/shared/src/components/SimpleFormDialog/SimpleFormDialog.cjs.js.map +1 -1
- package/dist/shared/src/components/SimpleFormDialog/SimpleFormDialog.es.js +4 -2
- package/dist/shared/src/components/SimpleFormDialog/SimpleFormDialog.es.js.map +1 -1
- package/dist/shared/src/components/VersionUploader/components/UploadVersionForm.cjs.js +1 -1
- package/dist/shared/src/components/VersionUploader/components/UploadVersionForm.cjs.js.map +1 -1
- package/dist/shared/src/components/VersionUploader/components/UploadVersionForm.es.js +4 -2
- package/dist/shared/src/components/VersionUploader/components/UploadVersionForm.es.js.map +1 -1
- package/dist/shared/src/components/VersionUploader/context/VersionUploadContext.cjs.js +1 -1
- package/dist/shared/src/components/VersionUploader/context/VersionUploadContext.cjs.js.map +1 -1
- package/dist/shared/src/components/VersionUploader/context/VersionUploadContext.es.js +6 -4
- package/dist/shared/src/components/VersionUploader/context/VersionUploadContext.es.js.map +1 -1
- package/dist/shared/src/components/Watchers/Watchers.cjs.js +1 -1
- package/dist/shared/src/components/Watchers/Watchers.cjs.js.map +1 -1
- package/dist/shared/src/components/Watchers/Watchers.es.js +4 -2
- package/dist/shared/src/components/Watchers/Watchers.es.js.map +1 -1
- package/dist/shared/src/containers/Actions/ActionConfigDialog.cjs.js +1 -1
- package/dist/shared/src/containers/Actions/ActionConfigDialog.cjs.js.map +1 -1
- package/dist/shared/src/containers/Actions/ActionConfigDialog.es.js +4 -2
- package/dist/shared/src/containers/Actions/ActionConfigDialog.es.js.map +1 -1
- package/dist/shared/src/containers/Actions/Actions.cjs.js +1 -1
- package/dist/shared/src/containers/Actions/Actions.cjs.js.map +1 -1
- package/dist/shared/src/containers/Actions/Actions.es.js +4 -2
- package/dist/shared/src/containers/Actions/Actions.es.js.map +1 -1
- package/dist/shared/src/containers/Actions/InteractiveActionDialog.cjs.js +1 -1
- package/dist/shared/src/containers/Actions/InteractiveActionDialog.cjs.js.map +1 -1
- package/dist/shared/src/containers/Actions/InteractiveActionDialog.es.js +4 -2
- package/dist/shared/src/containers/Actions/InteractiveActionDialog.es.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanel.cjs.js +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanel.cjs.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanel.es.js +4 -2
- package/dist/shared/src/containers/DetailsPanel/DetailsPanel.es.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFiles/DetailsPanelFiles.cjs.js +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFiles/DetailsPanelFiles.cjs.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFiles/DetailsPanelFiles.es.js +4 -2
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFiles/DetailsPanelFiles.es.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFloating/DetailsPanelFloating.cjs.js +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFloating/DetailsPanelFloating.cjs.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFloating/DetailsPanelFloating.es.js +5 -3
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFloating/DetailsPanelFloating.es.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelHeader/DetailsPanelHeader.cjs.js +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelHeader/DetailsPanelHeader.cjs.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelHeader/DetailsPanelHeader.es.js +4 -2
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelHeader/DetailsPanelHeader.es.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelSlideOut/DetailsPanelSlideOut.cjs.js +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelSlideOut/DetailsPanelSlideOut.cjs.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelSlideOut/DetailsPanelSlideOut.es.js +4 -2
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelSlideOut/DetailsPanelSlideOut.es.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/FeedContextWrapper.cjs.js +1 -1
- package/dist/shared/src/containers/DetailsPanel/FeedContextWrapper.cjs.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/FeedContextWrapper.es.js +4 -2
- package/dist/shared/src/containers/DetailsPanel/FeedContextWrapper.es.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/hooks/useGetEntityPath.cjs.js +1 -1
- package/dist/shared/src/containers/DetailsPanel/hooks/useGetEntityPath.cjs.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/hooks/useGetEntityPath.es.js +4 -2
- package/dist/shared/src/containers/DetailsPanel/hooks/useGetEntityPath.es.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/EntityPickerDialog.cjs.js +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/EntityPickerDialog.cjs.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/EntityPickerDialog.es.js +4 -2
- package/dist/shared/src/containers/EntityPickerDialog/EntityPickerDialog.es.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTable.cjs.js +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTable.cjs.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTable.es.js +4 -2
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTable.es.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTableHeader.cjs.js +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTableHeader.cjs.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTableHeader.es.js +4 -2
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTableHeader.es.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTableSearch.cjs.js +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTableSearch.cjs.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTableSearch.es.js +4 -2
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTableSearch.es.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/hooks/useGetEntityPickerData.cjs.js +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/hooks/useGetEntityPickerData.cjs.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/hooks/useGetEntityPickerData.es.js +4 -2
- package/dist/shared/src/containers/EntityPickerDialog/hooks/useGetEntityPickerData.es.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/ActivityComment/ActivityComment.cjs.js +1 -1
- package/dist/shared/src/containers/Feed/components/ActivityComment/ActivityComment.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/ActivityComment/ActivityComment.es.js +4 -2
- package/dist/shared/src/containers/Feed/components/ActivityComment/ActivityComment.es.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/ActivityComment/ActivityCommentMenu.cjs.js +1 -1
- package/dist/shared/src/containers/Feed/components/ActivityComment/ActivityCommentMenu.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/ActivityComment/ActivityCommentMenu.es.js +4 -2
- package/dist/shared/src/containers/Feed/components/ActivityComment/ActivityCommentMenu.es.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/CommentInput/CommentInput.cjs.js +1 -1
- package/dist/shared/src/containers/Feed/components/CommentInput/CommentInput.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/CommentInput/CommentInput.es.js +4 -2
- package/dist/shared/src/containers/Feed/components/CommentInput/CommentInput.es.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/Tooltips/EntityTooltip/EntityTooltip.cjs.js +1 -1
- package/dist/shared/src/containers/Feed/components/Tooltips/EntityTooltip/EntityTooltip.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/components/Tooltips/EntityTooltip/EntityTooltip.es.js +4 -2
- package/dist/shared/src/containers/Feed/components/Tooltips/EntityTooltip/EntityTooltip.es.js.map +1 -1
- package/dist/shared/src/containers/Feed/context/FeedContext.cjs.js +1 -1
- package/dist/shared/src/containers/Feed/context/FeedContext.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/context/FeedContext.es.js +7 -5
- package/dist/shared/src/containers/Feed/context/FeedContext.es.js.map +1 -1
- package/dist/shared/src/containers/Feed/hooks/useGetFeedActivitiesData.cjs.js +1 -1
- package/dist/shared/src/containers/Feed/hooks/useGetFeedActivitiesData.cjs.js.map +1 -1
- package/dist/shared/src/containers/Feed/hooks/useGetFeedActivitiesData.es.js +4 -2
- package/dist/shared/src/containers/Feed/hooks/useGetFeedActivitiesData.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/buildTreeTableColumns.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/buildTreeTableColumns.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/buildTreeTableColumns.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/buildTreeTableColumns.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/components/ColumnHeaderMenu.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/components/ColumnHeaderMenu.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/components/ColumnHeaderMenu.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/components/ColumnHeaderMenu.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/components/GroupSettingsFallback.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/components/GroupSettingsFallback.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/components/GroupSettingsFallback.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/components/GroupSettingsFallback.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/CellEditingProvider.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/CellEditingProvider.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/CellEditingProvider.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/context/CellEditingProvider.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectDataContext.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectDataContext.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectDataContext.es.js +6 -4
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectDataContext.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsProvider.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsProvider.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsProvider.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsProvider.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildGroupByTableData.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildGroupByTableData.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildGroupByTableData.es.js +7 -5
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildGroupByTableData.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildProjectDataTable.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildProjectDataTable.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildProjectDataTable.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildProjectDataTable.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useCellContextMenu.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useCellContextMenu.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useCellContextMenu.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useCellContextMenu.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useCheckSelectedCellsVisible.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useCheckSelectedCellsVisible.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useCheckSelectedCellsVisible.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useCheckSelectedCellsVisible.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useColumnGroupBy.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useColumnGroupBy.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useColumnGroupBy.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useColumnGroupBy.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useFetchOverviewData.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useFetchOverviewData.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useFetchOverviewData.es.js +30 -28
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useFetchOverviewData.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useGetGroupedFields.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useGetGroupedFields.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useGetGroupedFields.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useGetGroupedFields.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useGroupBySettings.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useGroupBySettings.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useGroupBySettings.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useGroupBySettings.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useKeyboardNavigation.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useKeyboardNavigation.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useKeyboardNavigation.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useKeyboardNavigation.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useMoveEntities.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useMoveEntities.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useMoveEntities.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useMoveEntities.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/usePasteLinks.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/usePasteLinks.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/usePasteLinks.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/usePasteLinks.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useQueryFilters.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useQueryFilters.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useQueryFilters.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useQueryFilters.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/utils/cellUtils.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/utils/cellUtils.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/utils/cellUtils.es.js +15 -13
- package/dist/shared/src/containers/ProjectTreeTable/utils/cellUtils.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/utils/linksToTableData.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/utils/linksToTableData.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/utils/linksToTableData.es.js +34 -21
- package/dist/shared/src/containers/ProjectTreeTable/utils/linksToTableData.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/LinksWidget.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/LinksWidget.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/LinksWidget.es.js +31 -28
- package/dist/shared/src/containers/ProjectTreeTable/widgets/LinksWidget.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/NameWidget.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/NameWidget.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/NameWidget.es.js +4 -2
- package/dist/shared/src/containers/ProjectTreeTable/widgets/NameWidget.es.js.map +1 -1
- package/dist/shared/src/containers/RepresentationsList/RepresentationsList.cjs.js +1 -1
- package/dist/shared/src/containers/RepresentationsList/RepresentationsList.cjs.js.map +1 -1
- package/dist/shared/src/containers/RepresentationsList/RepresentationsList.es.js +4 -2
- package/dist/shared/src/containers/RepresentationsList/RepresentationsList.es.js.map +1 -1
- package/dist/shared/src/containers/SimpleTable/SimpleTable.cjs.js +1 -1
- package/dist/shared/src/containers/SimpleTable/SimpleTable.cjs.js.map +1 -1
- package/dist/shared/src/containers/SimpleTable/SimpleTable.es.js +4 -2
- package/dist/shared/src/containers/SimpleTable/SimpleTable.es.js.map +1 -1
- package/dist/shared/src/containers/Views/ViewsDialogContainer/ViewsDialogContainer.cjs.js +1 -1
- package/dist/shared/src/containers/Views/ViewsDialogContainer/ViewsDialogContainer.cjs.js.map +1 -1
- package/dist/shared/src/containers/Views/ViewsDialogContainer/ViewsDialogContainer.es.js +4 -2
- package/dist/shared/src/containers/Views/ViewsDialogContainer/ViewsDialogContainer.es.js.map +1 -1
- package/dist/shared/src/containers/Views/context/ViewsContext.cjs.js +1 -1
- package/dist/shared/src/containers/Views/context/ViewsContext.cjs.js.map +1 -1
- package/dist/shared/src/containers/Views/context/ViewsContext.es.js +6 -4
- package/dist/shared/src/containers/Views/context/ViewsContext.es.js.map +1 -1
- package/dist/shared/src/containers/Views/hooks/useBuildViewMenuItems.cjs.js +1 -1
- package/dist/shared/src/containers/Views/hooks/useBuildViewMenuItems.cjs.js.map +1 -1
- package/dist/shared/src/containers/Views/hooks/useBuildViewMenuItems.es.js +4 -2
- package/dist/shared/src/containers/Views/hooks/useBuildViewMenuItems.es.js.map +1 -1
- package/dist/shared/src/containers/Views/hooks/useSaveViewFromCurrent.cjs.js +1 -1
- package/dist/shared/src/containers/Views/hooks/useSaveViewFromCurrent.cjs.js.map +1 -1
- package/dist/shared/src/containers/Views/hooks/useSaveViewFromCurrent.es.js +4 -2
- package/dist/shared/src/containers/Views/hooks/useSaveViewFromCurrent.es.js.map +1 -1
- package/dist/shared/src/containers/Views/hooks/useSelectedView.cjs.js +1 -1
- package/dist/shared/src/containers/Views/hooks/useSelectedView.cjs.js.map +1 -1
- package/dist/shared/src/containers/Views/hooks/useSelectedView.es.js +4 -2
- package/dist/shared/src/containers/Views/hooks/useSelectedView.es.js.map +1 -1
- package/dist/shared/src/containers/Views/hooks/useViewsMutations.cjs.js +1 -1
- package/dist/shared/src/containers/Views/hooks/useViewsMutations.cjs.js.map +1 -1
- package/dist/shared/src/containers/Views/hooks/useViewsMutations.es.js +4 -2
- package/dist/shared/src/containers/Views/hooks/useViewsMutations.es.js.map +1 -1
- package/dist/shared/src/containers/Views/utils/viewUpdateHelper.cjs.js +1 -1
- package/dist/shared/src/containers/Views/utils/viewUpdateHelper.cjs.js.map +1 -1
- package/dist/shared/src/containers/Views/utils/viewUpdateHelper.es.js +4 -2
- package/dist/shared/src/containers/Views/utils/viewUpdateHelper.es.js.map +1 -1
- package/dist/shared/src/context/AddonProjectContext.cjs.js +1 -1
- package/dist/shared/src/context/AddonProjectContext.cjs.js.map +1 -1
- package/dist/shared/src/context/AddonProjectContext.es.js +6 -4
- package/dist/shared/src/context/AddonProjectContext.es.js.map +1 -1
- package/dist/shared/src/context/DetailsPanelContext.cjs.js +1 -1
- package/dist/shared/src/context/DetailsPanelContext.cjs.js.map +1 -1
- package/dist/shared/src/context/DetailsPanelContext.es.js +6 -4
- package/dist/shared/src/context/DetailsPanelContext.es.js.map +1 -1
- package/dist/shared/src/context/GlobalContext.cjs.js +1 -1
- package/dist/shared/src/context/GlobalContext.cjs.js.map +1 -1
- package/dist/shared/src/context/GlobalContext.es.js +6 -4
- package/dist/shared/src/context/GlobalContext.es.js.map +1 -1
- package/dist/shared/src/context/PowerpackContext.cjs.js +1 -1
- package/dist/shared/src/context/PowerpackContext.cjs.js.map +1 -1
- package/dist/shared/src/context/PowerpackContext.es.js +8 -6
- package/dist/shared/src/context/PowerpackContext.es.js.map +1 -1
- package/dist/shared/src/context/ProjectContext.cjs.js +1 -1
- package/dist/shared/src/context/ProjectContext.cjs.js.map +1 -1
- package/dist/shared/src/context/ProjectContext.es.js +44 -38
- package/dist/shared/src/context/ProjectContext.es.js.map +1 -1
- package/dist/shared/src/context/ProjectFoldersContext.cjs.js +1 -1
- package/dist/shared/src/context/ProjectFoldersContext.cjs.js.map +1 -1
- package/dist/shared/src/context/ProjectFoldersContext.es.js +6 -4
- package/dist/shared/src/context/ProjectFoldersContext.es.js.map +1 -1
- package/dist/shared/src/context/RemoteModulesContext.cjs.js +1 -1
- package/dist/shared/src/context/RemoteModulesContext.cjs.js.map +1 -1
- package/dist/shared/src/context/RemoteModulesContext.es.js +6 -4
- package/dist/shared/src/context/RemoteModulesContext.es.js.map +1 -1
- package/dist/shared/src/context/UriContext.cjs.js +1 -1
- package/dist/shared/src/context/UriContext.cjs.js.map +1 -1
- package/dist/shared/src/context/UriContext.es.js +7 -5
- package/dist/shared/src/context/UriContext.es.js.map +1 -1
- package/dist/shared/src/context/WebsocketContext.cjs.js +1 -1
- package/dist/shared/src/context/WebsocketContext.cjs.js.map +1 -1
- package/dist/shared/src/context/WebsocketContext.es.js +6 -4
- package/dist/shared/src/context/WebsocketContext.es.js.map +1 -1
- package/dist/shared/src/hooks/useActionTriggers.cjs.js +1 -1
- package/dist/shared/src/hooks/useActionTriggers.cjs.js.map +1 -1
- package/dist/shared/src/hooks/useActionTriggers.es.js +4 -2
- package/dist/shared/src/hooks/useActionTriggers.es.js.map +1 -1
- package/dist/shared/src/hooks/useEntityUpdate.cjs.js +1 -1
- package/dist/shared/src/hooks/useEntityUpdate.cjs.js.map +1 -1
- package/dist/shared/src/hooks/useEntityUpdate.es.js +4 -2
- package/dist/shared/src/hooks/useEntityUpdate.es.js.map +1 -1
- package/dist/shared/src/hooks/useGetEntityGroups.cjs.js +1 -1
- package/dist/shared/src/hooks/useGetEntityGroups.cjs.js.map +1 -1
- package/dist/shared/src/hooks/useGetEntityGroups.es.js +4 -2
- package/dist/shared/src/hooks/useGetEntityGroups.es.js.map +1 -1
- package/dist/shared/src/hooks/useGroupByRemoteModules.cjs.js +1 -1
- package/dist/shared/src/hooks/useGroupByRemoteModules.cjs.js.map +1 -1
- package/dist/shared/src/hooks/useGroupByRemoteModules.es.js +4 -2
- package/dist/shared/src/hooks/useGroupByRemoteModules.es.js.map +1 -1
- package/dist/shared/src/hooks/useScopedStatuses.cjs.js +1 -1
- package/dist/shared/src/hooks/useScopedStatuses.cjs.js.map +1 -1
- package/dist/shared/src/hooks/useScopedStatuses.es.js +6 -4
- package/dist/shared/src/hooks/useScopedStatuses.es.js.map +1 -1
- package/dist/shared/src/hooks/useUserProjectConfig.cjs.js +1 -1
- package/dist/shared/src/hooks/useUserProjectConfig.cjs.js.map +1 -1
- package/dist/shared/src/hooks/useUserProjectConfig.es.js +4 -2
- package/dist/shared/src/hooks/useUserProjectConfig.es.js.map +1 -1
- package/dist/types/api/queries/config/getConfig.d.ts +747 -0
- package/dist/types/api/queries/config/index.d.ts +2 -0
- package/dist/types/api/queries/config/updateConfig.d.ts +171 -0
- package/dist/types/api/queries/index.d.ts +1 -0
- package/dist/types/api/queries/links/getEntityLinks.d.ts +2 -1
- package/dist/types/components/AddonLoadingScreen/AddonLoadingScreen.d.ts +7 -2
- package/dist/types/components/Chips/Chips.d.ts +1 -0
- package/dist/types/components/LinksManager/LinksManager.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEntityLinks.cjs.js","sources":["../../../../../../src/api/queries/links/getEntityLinks.ts"],"sourcesContent":["import { FetchBaseQueryError } from '@reduxjs/toolkit/query'\nimport {\n GetFoldersLinksQuery,\n GetTasksLinksQuery,\n GetProductsLinksQuery,\n GetVersionsLinksQuery,\n GetRepresentationsLinksQuery,\n GetWorkfilesLinksQuery,\n gqlLinksApi,\n foldersApi,\n} from '@shared/api/generated'\nimport { formatEntityLabel } from './utils/formatEntityLinks'\nimport { toast } from 'react-toastify'\nimport { PubSub } from '@shared/util'\n\n/**\n * Custom queryFn for fetching entity links with optimized caching behavior.\n *\n * Key features:\n * 1. Single cache per project and entity type - different entityIds combinations don't create new caches\n * 2. Skips fetching entities that are already cached\n * 3. Force refetch when entityIds change\n * 4. Merges new entities into cache without duplicates\n * 5. Supports all entity types: folders, tasks, products, versions, representations, workfiles\n */\n\n// Define the arguments for the query\nexport type GetEntityLinksArgs = {\n projectName: string\n entityIds: string[]\n entityType: 'folder' | 'task' | 'product' | 'version' | 'representation' | 'workfile'\n}\n\n// Define link types for each entity\nexport type FolderLink =\n GetFoldersLinksQuery['project']['folders']['edges'][0]['node']['links']['edges'][0]\nexport type TaskLink =\n GetTasksLinksQuery['project']['tasks']['edges'][0]['node']['links']['edges'][0]\nexport type ProductLink =\n GetProductsLinksQuery['project']['products']['edges'][0]['node']['links']['edges'][0]\nexport type VersionLink =\n GetVersionsLinksQuery['project']['versions']['edges'][0]['node']['links']['edges'][0]\nexport type RepresentationLink =\n GetRepresentationsLinksQuery['project']['representations']['edges'][0]['node']['links']['edges'][0]\nexport type WorkfileLink =\n GetWorkfilesLinksQuery['project']['workfiles']['edges'][0]['node']['links']['edges'][0]\n\nexport type EntityLinkQuery =\n | FolderLink\n | TaskLink\n | ProductLink\n | VersionLink\n | RepresentationLink\n | WorkfileLink\nexport type EntityLink = Pick<EntityLinkQuery, 'direction' | 'entityType' | 'id' | 'linkType'> & {\n node: Pick<EntityLinkQuery['node'], 'name' | 'id'> & {\n label?: string | null\n parents: string[]\n subType: string | undefined\n }\n}\n\n// Define the result type for the query - simplified without edges wrapper\nexport type EntityWithLinks = {\n id: string\n links: EntityLink[]\n}\n\nexport type GetEntityLinksResult = EntityWithLinks[]\n\n// Map entity types to their corresponding GraphQL endpoints\nconst entityEndpoints = {\n folder: 'GetFoldersLinks',\n task: 'GetTasksLinks',\n product: 'GetProductsLinks',\n version: 'GetVersionsLinks',\n representation: 'GetRepresentationsLinks',\n workfile: 'GetWorkfilesLinks',\n} as const\n\n// Map entity types to their result path in the GraphQL response\nconst entityResultPaths = {\n folder: 'folders',\n task: 'tasks',\n product: 'products',\n version: 'versions',\n representation: 'representations',\n workfile: 'workfiles',\n} as const\n\nconst injectedQueries = foldersApi.injectEndpoints({\n endpoints: (build) => ({\n getEntityLinks: build.query<GetEntityLinksResult, GetEntityLinksArgs>({\n queryFn: async (\n { projectName, entityIds, entityType },\n { getState, dispatch, queryCacheKey, forced },\n ) => {\n try {\n // Get current state to access cached data\n const state = getState() as any\n const cacheKey = JSON.stringify({ projectName, entityType })\n\n // Access the cache entry for this project and entity type\n const cacheEntry =\n state.restApi?.queries?.[queryCacheKey || `getEntityLinks(${cacheKey})`]\n const cachedData = cacheEntry?.data || []\n\n // 1. When fetching new data for entityIds, we should skip entities that are already in the cache.\n const cachedEntityIds = new Set(cachedData.map((entity: EntityWithLinks) => entity.id))\n const entityIdsToFetch = entityIds.filter((id) => !cachedEntityIds?.has(id) || forced)\n\n // If all entities are already cached, return the cached data\n if (entityIdsToFetch.length === 0) {\n return { data: cachedData }\n }\n\n // Get the appropriate endpoint and parameter names\n const endpoint = entityEndpoints[entityType]\n const resultPath = entityResultPaths[entityType]\n\n // Fetch only the entities that aren't already cached\n const result = await dispatch(\n (gqlLinksApi.endpoints as any)[endpoint].initiate(\n { projectName, entityIds: entityIdsToFetch },\n { forceRefetch: true },\n ),\n ).unwrap()\n\n const newEntities =\n result.project?.[resultPath]?.edges?.map(({ node }: { node: any }) => ({\n id: node.id,\n links:\n node.links.edges\n ?.filter((e: EntityLinkQuery | null) => !!e?.node)\n ?.map((linkEdge: EntityLinkQuery) => ({\n ...linkEdge,\n node: {\n id: linkEdge.node.id,\n name: linkEdge.node.name,\n label: formatEntityLabel(linkEdge.node),\n parents: linkEdge.node.parents || [],\n subType: 'subType' in linkEdge.node ? linkEdge.node.subType : undefined,\n },\n })) || [], // Flatten the edges structure\n })) || []\n\n // Return the new entities - the merge function will handle combining with existing cache\n return { data: newEntities }\n } catch (error: any) {\n console.error(`Error in getEntityLinks queryFn for ${entityType}:`, error)\n toast.error(`Error fetching ${entityType} links`)\n return { error: { status: 'FETCH_ERROR', error: error.message } as FetchBaseQueryError }\n }\n },\n // 2. We should not create new caches when the entityIds argument changes.\n serializeQueryArgs: ({ queryArgs }) => {\n // Use only projectName and entityType for the cache key, ignoring entityIds\n return { projectName: queryArgs.projectName, entityType: queryArgs.entityType }\n },\n // 3. We should force a refetch every time the entityIds changes.\n forceRefetch: ({ currentArg, previousArg }) => {\n // Force refetch if entityIds array is different\n if (!currentArg || !previousArg) return true\n\n // Compare arrays by converting to sets\n const currentIds = new Set(currentArg.entityIds)\n const previousIds = new Set(previousArg.entityIds)\n\n if (currentIds.size !== previousIds.size) return true\n\n // Check if any IDs are different\n for (const id of currentIds) {\n if (!previousIds.has(id)) return true\n }\n\n return false\n },\n // 4. We should merge new entities into the cache ensuring there are no duplicates.\n merge: (currentCache, newItems) => {\n if (!currentCache) return newItems\n\n const cacheMap = new Map(currentCache.map((item) => [item.id, item]))\n for (const newItem of newItems) {\n cacheMap.set(newItem.id, newItem) // Overwrite if exists, add if not\n }\n // Update currentCache in-place\n currentCache.length = 0\n currentCache.push(...cacheMap.values())\n },\n // Provide tags for potential invalidation\n providesTags: (result, error, arg) =>\n result\n ? [\n ...result.flatMap((entity) =>\n entity.links.map((link) => ({ type: 'link', id: link.node.id })),\n ),\n { type: 'link', id: `${arg.projectName}-${arg.entityType}` },\n ]\n : [{ type: 'link', id: `${arg.projectName}-${arg.entityType}` }],\n // Subscribe to link.created and link.deleted WebSocket events\n async onCacheEntryAdded(\n { projectName, entityIds, entityType },\n { cacheDataLoaded, cacheEntryRemoved, updateCachedData, dispatch },\n ) {\n let token: any\n const pendingEntityIds = new Set<string>()\n const MAX_BATCH = 100\n const INTERVAL = 500\n let scheduled = false\n\n const schedule = () => {\n if (scheduled) return\n scheduled = true\n setTimeout(flush, INTERVAL)\n }\n\n const flush = async () => {\n scheduled = false\n if (!pendingEntityIds.size) return\n const batchIds = Array.from(pendingEntityIds).slice(0, MAX_BATCH)\n batchIds.forEach((id) => pendingEntityIds.delete(id))\n\n try {\n // Get the appropriate endpoint and parameter names\n const endpoint = entityEndpoints[entityType]\n const resultPath = entityResultPaths[entityType]\n\n // Fetch fresh data for the affected entities\n const result = await dispatch(\n (gqlLinksApi.endpoints as any)[endpoint].initiate(\n { projectName, entityIds: batchIds },\n { forceRefetch: true },\n ),\n ).unwrap()\n\n const updatedEntities =\n result.project?.[resultPath]?.edges?.map(({ node }: { node: any }) => ({\n id: node.id,\n links:\n node.links.edges\n ?.filter((e: EntityLinkQuery | null) => !!e?.node)\n ?.map((linkEdge: EntityLinkQuery) => ({\n ...linkEdge,\n node: {\n id: linkEdge.node.id,\n name: linkEdge.node.name,\n label: formatEntityLabel(linkEdge.node),\n parents: linkEdge.node.parents || [],\n subType: 'subType' in linkEdge.node ? linkEdge.node.subType : undefined,\n },\n })) || [],\n })) || []\n\n updateCachedData((draft: EntityWithLinks[]) => {\n for (const updatedEntity of updatedEntities) {\n const idx = draft.findIndex((entity) => entity.id === updatedEntity.id)\n if (idx > -1) {\n // Update existing entity's links\n draft[idx] = updatedEntity\n } else {\n // Add new entity if not in cache\n draft.push(updatedEntity)\n }\n }\n })\n } catch (err) {\n console.error('Realtime link batch update failed', err)\n } finally {\n if (pendingEntityIds.size) schedule()\n }\n }\n\n try {\n await cacheDataLoaded\n\n const handlePubSub = async (_topic: string, message: any) => {\n // Only react to link.created and link.deleted events for this project\n if (!_topic.startsWith('link.created') && !_topic.startsWith('link.deleted')) return\n if (message?.project !== projectName) return\n\n // Link events have inputId and outputId in the summary (both entities affected by the link)\n const inputId = message?.summary?.inputId\n const outputId = message?.summary?.outputId\n if (!inputId && !outputId) return\n\n // Add both entities to pending list since both are affected by the link change\n if (inputId) pendingEntityIds.add(inputId)\n if (outputId) pendingEntityIds.add(outputId)\n schedule()\n }\n\n // Subscribe to link events\n // NOTE: backend emits topics like 'link.created' and 'link.deleted'.\n // PubSub supports prefix matching when subscribing.\n token = PubSub.subscribe('link', handlePubSub)\n } catch (e) {\n // cache entry removed before loaded - ignore\n }\n\n await cacheEntryRemoved\n if (token) PubSub.unsubscribe(token)\n },\n }),\n }),\n})\n\nexport const { useGetEntityLinksQuery } = injectedQueries\nexport { injectedQueries as entityLinksApi }\n"],"names":["entityEndpoints","entityResultPaths","injectedQueries","foldersApi","build","projectName","entityIds","entityType","getState","dispatch","queryCacheKey","forced","state","cacheKey","cacheEntry","_b","_a","cachedData","cachedEntityIds","entity","entityIdsToFetch","id","endpoint","resultPath","_e","_d","_c","gqlLinksApi","node","linkEdge","formatEntityLabel","error","toast","queryArgs","currentArg","previousArg","currentIds","previousIds","currentCache","newItems","cacheMap","item","newItem","result","arg","link","cacheDataLoaded","cacheEntryRemoved","updateCachedData","token","pendingEntityIds","MAX_BATCH","INTERVAL","scheduled","schedule","flush","batchIds","updatedEntities","draft","updatedEntity","idx","err","handlePubSub","_topic","message","inputId","outputId","PubSub","useGetEntityLinksQuery"],"mappings":"+1DAuEMA,EAAkB,CACtB,OAAQ,kBACR,KAAM,gBACN,QAAS,mBACT,QAAS,mBACT,eAAgB,0BAChB,SAAU,mBACZ,EAGMC,EAAoB,CACxB,OAAQ,UACR,KAAM,QACN,QAAS,WACT,QAAS,WACT,eAAgB,kBAChB,SAAU,WACZ,EAEMC,EAAkBC,MAAW,gBAAgB,CACjD,UAAYC,IAAW,CACrB,eAAgBA,EAAM,MAAgD,CACpE,QAAS,MACP,CAAE,YAAAC,EAAa,UAAAC,EAAW,WAAAC,CAAA,EAC1B,CAAE,SAAAC,EAAU,SAAAC,EAAU,cAAAC,EAAe,OAAAC,KAClC,eACC,GAAA,CAEF,MAAMC,EAAQJ,EAAS,EACjBK,EAA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EAAE,EAClEC,EAAM,GAERF,EAAME,CAAG,EAAID,EAGbD,EAAM,KAAKC,CAAa,CAC1B,CACF,CACD,QACME,EAAK,CACJ,QAAA,MAAM,oCAAqCA,CAAG,CAAA,QACtD,CACIX,EAAiB,MAAeI,EAAA,CAAA,CAExC,EAEI,GAAA,CACI,MAAAR,EAEA,MAAAgB,EAAe,MAAOC,EAAgBC,IAAiB,SAGvD,GADA,CAACD,EAAO,WAAW,cAAc,GAAK,CAACA,EAAO,WAAW,cAAc,IACvEC,GAAA,YAAAA,EAAS,WAAY3D,EAAa,OAGhC,MAAA4D,GAAUjD,EAAAgD,GAAA,YAAAA,EAAS,UAAT,YAAAhD,EAAkB,QAC5BkD,GAAWnD,EAAAiD,GAAA,YAAAA,EAAS,UAAT,YAAAjD,EAAkB,SAC/B,CAACkD,GAAW,CAACC,IAGbD,GAA0Bf,EAAA,IAAIe,CAAO,EACrCC,GAA2BhB,EAAA,IAAIgB,CAAQ,EAClCZ,EAAA,EACX,EAKQL,EAAAkB,EAAO,UAAU,OAAQL,CAAY,OACnC,CAAA,CAIN,MAAAf,EACFE,GAAckB,EAAA,YAAYlB,CAAK,CAAA,CAEtC,CAAA,CACH,EACF,CAAC,EAEY,CAAE,uBAAAmB,GAA2BlE"}
|
|
1
|
+
{"version":3,"file":"getEntityLinks.cjs.js","sources":["../../../../../../src/api/queries/links/getEntityLinks.ts"],"sourcesContent":["import { FetchBaseQueryError } from '@reduxjs/toolkit/query'\nimport {\n GetFoldersLinksQuery,\n GetTasksLinksQuery,\n GetProductsLinksQuery,\n GetVersionsLinksQuery,\n GetRepresentationsLinksQuery,\n GetWorkfilesLinksQuery,\n gqlLinksApi,\n foldersApi,\n} from '@shared/api/generated'\nimport { formatEntityLabel } from './utils/formatEntityLinks'\nimport { toast } from 'react-toastify'\nimport { PubSub } from '@shared/util'\n\n/**\n * Custom queryFn for fetching entity links with optimized caching behavior.\n *\n * Key features:\n * 1. Single cache per project and entity type - different entityIds combinations don't create new caches\n * 2. Skips fetching entities that are already cached\n * 3. Force refetch when entityIds change\n * 4. Merges new entities into cache without duplicates\n * 5. Supports all entity types: folders, tasks, products, versions, representations, workfiles\n */\n\n// Define the arguments for the query\nexport type GetEntityLinksArgs = {\n projectName: string\n entityIds: string[]\n entityType: 'folder' | 'task' | 'product' | 'version' | 'representation' | 'workfile'\n}\n\n// Define link types for each entity\nexport type FolderLink =\n GetFoldersLinksQuery['project']['folders']['edges'][0]['node']['links']['edges'][0]\nexport type TaskLink =\n GetTasksLinksQuery['project']['tasks']['edges'][0]['node']['links']['edges'][0]\nexport type ProductLink =\n GetProductsLinksQuery['project']['products']['edges'][0]['node']['links']['edges'][0]\nexport type VersionLink =\n GetVersionsLinksQuery['project']['versions']['edges'][0]['node']['links']['edges'][0]\nexport type RepresentationLink =\n GetRepresentationsLinksQuery['project']['representations']['edges'][0]['node']['links']['edges'][0]\nexport type WorkfileLink =\n GetWorkfilesLinksQuery['project']['workfiles']['edges'][0]['node']['links']['edges'][0]\n\nexport type EntityLinkQuery =\n | FolderLink\n | TaskLink\n | ProductLink\n | VersionLink\n | RepresentationLink\n | WorkfileLink\nexport type EntityLink = Pick<EntityLinkQuery, 'direction' | 'entityType' | 'id' | 'linkType'> & {\n node: Pick<EntityLinkQuery['node'], 'name' | 'id'> & {\n label?: string | null\n parents: string[]\n subType: string | undefined\n } | null\n isRestricted?: boolean // flag to indicate if this link is restricted\n}\n\n// Define the result type for the query - simplified without edges wrapper\nexport type EntityWithLinks = {\n id: string\n links: EntityLink[]\n}\n\nexport type GetEntityLinksResult = EntityWithLinks[]\n\n// Map entity types to their corresponding GraphQL endpoints\nconst entityEndpoints = {\n folder: 'GetFoldersLinks',\n task: 'GetTasksLinks',\n product: 'GetProductsLinks',\n version: 'GetVersionsLinks',\n representation: 'GetRepresentationsLinks',\n workfile: 'GetWorkfilesLinks',\n} as const\n\n// Map entity types to their result path in the GraphQL response\nconst entityResultPaths = {\n folder: 'folders',\n task: 'tasks',\n product: 'products',\n version: 'versions',\n representation: 'representations',\n workfile: 'workfiles',\n} as const\n\nconst injectedQueries = foldersApi.injectEndpoints({\n endpoints: (build) => ({\n getEntityLinks: build.query<GetEntityLinksResult, GetEntityLinksArgs>({\n queryFn: async (\n { projectName, entityIds, entityType },\n { getState, dispatch, queryCacheKey, forced },\n ) => {\n try {\n // Get current state to access cached data\n const state = getState() as any\n const cacheKey = JSON.stringify({ projectName, entityType })\n\n // Access the cache entry for this project and entity type\n const cacheEntry =\n state.restApi?.queries?.[queryCacheKey || `getEntityLinks(${cacheKey})`]\n const cachedData = cacheEntry?.data || []\n\n // 1. When fetching new data for entityIds, we should skip entities that are already in the cache.\n const cachedEntityIds = new Set(cachedData.map((entity: EntityWithLinks) => entity.id))\n const entityIdsToFetch = entityIds.filter((id) => !cachedEntityIds?.has(id) || forced)\n\n // If all entities are already cached, return the cached data\n if (entityIdsToFetch.length === 0) {\n return { data: cachedData }\n }\n\n // Get the appropriate endpoint and parameter names\n const endpoint = entityEndpoints[entityType]\n const resultPath = entityResultPaths[entityType]\n\n // Fetch only the entities that aren't already cached\n const result = await dispatch(\n (gqlLinksApi.endpoints as any)[endpoint].initiate(\n { projectName, entityIds: entityIdsToFetch },\n { forceRefetch: true },\n ),\n ).unwrap()\n\n const newEntities =\n result.project?.[resultPath]?.edges?.map(({ node }: { node: any }) => {\n // Log restricted links\n const restrictedLinks = node.links.edges?.filter((e: EntityLinkQuery | null) => !e?.node) || []\n if (restrictedLinks.length > 0) {\n console.log(`[RESTRICTED LINKS] Entity ${node.id} (${node.name}) has ${restrictedLinks.length} restricted link(s):`,\n restrictedLinks.map((link: any) => ({\n linkId: link?.id,\n linkType: link?.linkType,\n direction: link?.direction,\n entityType: link?.entityType,\n nodeIsNull: !link?.node\n }))\n )\n }\n\n return {\n id: node.id,\n links:\n node.links.edges\n ?.map((linkEdge: EntityLinkQuery | null) => {\n if (!linkEdge?.node) {\n // Restricted link - node is null\n return {\n ...linkEdge,\n node: null,\n isRestricted: true,\n } as EntityLink\n }\n // Normal link\n return {\n ...linkEdge,\n node: {\n id: linkEdge.node.id,\n name: linkEdge.node.name,\n label: formatEntityLabel(linkEdge.node),\n parents: linkEdge.node.parents || [],\n subType: 'subType' in linkEdge.node ? linkEdge.node.subType : undefined,\n },\n isRestricted: false,\n } as EntityLink\n }) || [], // Flatten the edges structure\n }\n }) || []\n\n // Return the new entities - the merge function will handle combining with existing cache\n return { data: newEntities }\n } catch (error: any) {\n console.error(`Error in getEntityLinks queryFn for ${entityType}:`, error)\n toast.error(`Error fetching ${entityType} links`)\n return { error: { status: 'FETCH_ERROR', error: error.message } as FetchBaseQueryError }\n }\n },\n // 2. We should not create new caches when the entityIds argument changes.\n serializeQueryArgs: ({ queryArgs }) => {\n // Use only projectName and entityType for the cache key, ignoring entityIds\n return { projectName: queryArgs.projectName, entityType: queryArgs.entityType }\n },\n // 3. We should force a refetch every time the entityIds changes.\n forceRefetch: ({ currentArg, previousArg }) => {\n // Force refetch if entityIds array is different\n if (!currentArg || !previousArg) return true\n\n // Compare arrays by converting to sets\n const currentIds = new Set(currentArg.entityIds)\n const previousIds = new Set(previousArg.entityIds)\n\n if (currentIds.size !== previousIds.size) return true\n\n // Check if any IDs are different\n for (const id of currentIds) {\n if (!previousIds.has(id)) return true\n }\n\n return false\n },\n // 4. We should merge new entities into the cache ensuring there are no duplicates.\n merge: (currentCache, newItems) => {\n if (!currentCache) return newItems\n\n const cacheMap = new Map(currentCache.map((item) => [item.id, item]))\n for (const newItem of newItems) {\n cacheMap.set(newItem.id, newItem) // Overwrite if exists, add if not\n }\n // Update currentCache in-place\n currentCache.length = 0\n currentCache.push(...cacheMap.values())\n },\n // Provide tags for potential invalidation\n providesTags: (result, error, arg) =>\n result\n ? [\n ...result.flatMap((entity) =>\n entity.links\n .filter((link) => link.node !== null)\n .map((link) => ({ type: 'link', id: link.node!.id })),\n ),\n { type: 'link', id: `${arg.projectName}-${arg.entityType}` },\n ]\n : [{ type: 'link', id: `${arg.projectName}-${arg.entityType}` }],\n // Subscribe to link.created and link.deleted WebSocket events\n async onCacheEntryAdded(\n { projectName, entityIds, entityType },\n { cacheDataLoaded, cacheEntryRemoved, updateCachedData, dispatch },\n ) {\n let token: any\n const pendingEntityIds = new Set<string>()\n const MAX_BATCH = 100\n const INTERVAL = 500\n let scheduled = false\n\n const schedule = () => {\n if (scheduled) return\n scheduled = true\n setTimeout(flush, INTERVAL)\n }\n\n const flush = async () => {\n scheduled = false\n if (!pendingEntityIds.size) return\n const batchIds = Array.from(pendingEntityIds).slice(0, MAX_BATCH)\n batchIds.forEach((id) => pendingEntityIds.delete(id))\n\n try {\n // Get the appropriate endpoint and parameter names\n const endpoint = entityEndpoints[entityType]\n const resultPath = entityResultPaths[entityType]\n\n // Fetch fresh data for the affected entities\n const result = await dispatch(\n (gqlLinksApi.endpoints as any)[endpoint].initiate(\n { projectName, entityIds: batchIds },\n { forceRefetch: true },\n ),\n ).unwrap()\n\n const updatedEntities =\n result.project?.[resultPath]?.edges?.map(({ node }: { node: any }) => {\n\n return {\n id: node.id,\n links:\n node.links.edges\n ?.map((linkEdge: EntityLinkQuery | null) => {\n if (!linkEdge?.node) {\n // Restricted link - node is null\n return {\n ...linkEdge,\n node: null,\n isRestricted: true,\n } as EntityLink\n }\n // Normal link\n return {\n ...linkEdge,\n node: {\n id: linkEdge.node.id,\n name: linkEdge.node.name,\n label: formatEntityLabel(linkEdge.node),\n parents: linkEdge.node.parents || [],\n subType: 'subType' in linkEdge.node ? linkEdge.node.subType : undefined,\n },\n isRestricted: false,\n } as EntityLink\n }) || [],\n }\n }) || []\n\n updateCachedData((draft: EntityWithLinks[]) => {\n for (const updatedEntity of updatedEntities) {\n const idx = draft.findIndex((entity) => entity.id === updatedEntity.id)\n if (idx > -1) {\n // Update existing entity's links\n draft[idx] = updatedEntity\n } else {\n // Add new entity if not in cache\n draft.push(updatedEntity)\n }\n }\n })\n } catch (err) {\n console.error('Realtime link batch update failed', err)\n } finally {\n if (pendingEntityIds.size) schedule()\n }\n }\n\n try {\n await cacheDataLoaded\n\n const handlePubSub = async (_topic: string, message: any) => {\n // Only react to link.created and link.deleted events for this project\n if (!_topic.startsWith('link.created') && !_topic.startsWith('link.deleted')) return\n if (message?.project !== projectName) return\n\n // Link events have inputId and outputId in the summary (both entities affected by the link)\n const inputId = message?.summary?.inputId\n const outputId = message?.summary?.outputId\n if (!inputId && !outputId) return\n\n // Add both entities to pending list since both are affected by the link change\n if (inputId) pendingEntityIds.add(inputId)\n if (outputId) pendingEntityIds.add(outputId)\n schedule()\n }\n\n // Subscribe to link events\n // NOTE: backend emits topics like 'link.created' and 'link.deleted'.\n // PubSub supports prefix matching when subscribing.\n token = PubSub.subscribe('link', handlePubSub)\n } catch (e) {\n // cache entry removed before loaded - ignore\n }\n\n await cacheEntryRemoved\n if (token) PubSub.unsubscribe(token)\n },\n }),\n }),\n})\n\nexport const { useGetEntityLinksQuery } = injectedQueries\nexport { injectedQueries as entityLinksApi }\n"],"names":["entityEndpoints","entityResultPaths","injectedQueries","foldersApi","build","projectName","entityIds","entityType","getState","dispatch","queryCacheKey","forced","state","cacheKey","cacheEntry","_b","_a","cachedData","cachedEntityIds","entity","entityIdsToFetch","id","endpoint","resultPath","_e","_d","_c","gqlLinksApi","node","restrictedLinks","link","linkEdge","formatEntityLabel","error","toast","queryArgs","currentArg","previousArg","currentIds","previousIds","currentCache","newItems","cacheMap","item","newItem","result","arg","cacheDataLoaded","cacheEntryRemoved","updateCachedData","token","pendingEntityIds","MAX_BATCH","INTERVAL","scheduled","schedule","flush","batchIds","updatedEntities","draft","updatedEntity","idx","err","handlePubSub","_topic","message","inputId","outputId","PubSub","useGetEntityLinksQuery"],"mappings":"+1DAwEMA,EAAkB,CACtB,OAAQ,kBACR,KAAM,gBACN,QAAS,mBACT,QAAS,mBACT,eAAgB,0BAChB,SAAU,mBACZ,EAGMC,EAAoB,CACxB,OAAQ,UACR,KAAM,QACN,QAAS,WACT,QAAS,WACT,eAAgB,kBAChB,SAAU,WACZ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AA,YAAAA,EAAS,UAAT,YAAAlD,EAAkB,SAC/B,CAACmD,GAAW,CAACC,IAGbD,GAA0Bf,EAAA,IAAIe,CAAO,EACrCC,GAA2BhB,EAAA,IAAIgB,CAAQ,EAClCZ,EAAA,EACX,EAKQL,EAAAkB,EAAO,UAAU,OAAQL,CAAY,OACnC,CAAA,CAIN,MAAAf,EACFE,GAAckB,EAAA,YAAYlB,CAAK,CAAA,CAEtC,CAAA,CACH,EACF,CAAC,EAEY,CAAE,uBAAAmB,GAA2BnE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../../base/client.es.js";
|
|
2
2
|
import "../../generated/graphql.es.js";
|
|
3
|
-
import { api as
|
|
3
|
+
import { api as A } from "../../generated/graphqlLinks.es.js";
|
|
4
4
|
import "../../generated/access.es.js";
|
|
5
5
|
import "../../generated/actions.es.js";
|
|
6
6
|
import "../../generated/activityFeed.es.js";
|
|
@@ -14,7 +14,7 @@ import "../../generated/desktop.es.js";
|
|
|
14
14
|
import "../../generated/entityLists.es.js";
|
|
15
15
|
import "../../generated/events.es.js";
|
|
16
16
|
import "../../generated/files.es.js";
|
|
17
|
-
import { api as
|
|
17
|
+
import { api as M } from "../../generated/folders.es.js";
|
|
18
18
|
import "../../generated/inbox.es.js";
|
|
19
19
|
import "../../generated/links.es.js";
|
|
20
20
|
import "../../generated/market.es.js";
|
|
@@ -36,151 +36,171 @@ import "../../generated/workfiles.es.js";
|
|
|
36
36
|
import "../../generated/ynputCloud.es.js";
|
|
37
37
|
import "../../generated/grouping.es.js";
|
|
38
38
|
import "../../generated/views.es.js";
|
|
39
|
-
import { formatEntityLabel as
|
|
40
|
-
import { toast as
|
|
39
|
+
import { formatEntityLabel as G } from "./utils/formatEntityLinks.es.js";
|
|
40
|
+
import { toast as q } from "react-toastify";
|
|
41
41
|
import "lodash";
|
|
42
42
|
import "uuid";
|
|
43
|
-
import
|
|
44
|
-
const
|
|
43
|
+
import N from "../../../util/pubsub.es.js";
|
|
44
|
+
const P = {
|
|
45
45
|
folder: "GetFoldersLinks",
|
|
46
46
|
task: "GetTasksLinks",
|
|
47
47
|
product: "GetProductsLinks",
|
|
48
48
|
version: "GetVersionsLinks",
|
|
49
49
|
representation: "GetRepresentationsLinks",
|
|
50
50
|
workfile: "GetWorkfilesLinks"
|
|
51
|
-
},
|
|
51
|
+
}, z = {
|
|
52
52
|
folder: "folders",
|
|
53
53
|
task: "tasks",
|
|
54
54
|
product: "products",
|
|
55
55
|
version: "versions",
|
|
56
56
|
representation: "representations",
|
|
57
57
|
workfile: "workfiles"
|
|
58
|
-
},
|
|
59
|
-
endpoints: (
|
|
60
|
-
getEntityLinks:
|
|
61
|
-
queryFn: async ({ projectName: e, entityIds:
|
|
62
|
-
var h,
|
|
58
|
+
}, x = M.injectEndpoints({
|
|
59
|
+
endpoints: (F) => ({
|
|
60
|
+
getEntityLinks: F.query({
|
|
61
|
+
queryFn: async ({ projectName: e, entityIds: a, entityType: r }, { getState: s, dispatch: c, queryCacheKey: $, forced: j }) => {
|
|
62
|
+
var h, u, R, T, b;
|
|
63
63
|
try {
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
return { data:
|
|
67
|
-
const
|
|
68
|
-
return { data: ((
|
|
69
|
-
|
|
70
|
-
{ projectName: e, entityIds:
|
|
64
|
+
const l = s(), S = JSON.stringify({ projectName: e, entityType: r }), f = (u = (h = l.restApi) == null ? void 0 : h.queries) == null ? void 0 : u[$ || `getEntityLinks(${S})`], y = (f == null ? void 0 : f.data) || [], i = new Set(y.map((n) => n.id)), m = a.filter((n) => !(i != null && i.has(n)) || j);
|
|
65
|
+
if (m.length === 0)
|
|
66
|
+
return { data: y };
|
|
67
|
+
const p = P[r], I = z[r];
|
|
68
|
+
return { data: ((b = (T = (R = (await c(
|
|
69
|
+
A.endpoints[p].initiate(
|
|
70
|
+
{ projectName: e, entityIds: m },
|
|
71
71
|
{ forceRefetch: !0 }
|
|
72
72
|
)
|
|
73
|
-
).unwrap()).project) == null ? void 0 :
|
|
74
|
-
var
|
|
75
|
-
|
|
73
|
+
).unwrap()).project) == null ? void 0 : R[I]) == null ? void 0 : T.edges) == null ? void 0 : b.map(({ node: n }) => {
|
|
74
|
+
var o, L;
|
|
75
|
+
const d = ((o = n.links.edges) == null ? void 0 : o.filter((t) => !(t != null && t.node))) || [];
|
|
76
|
+
return d.length > 0 && console.log(
|
|
77
|
+
`[RESTRICTED LINKS] Entity ${n.id} (${n.name}) has ${d.length} restricted link(s):`,
|
|
78
|
+
d.map((t) => ({
|
|
79
|
+
linkId: t == null ? void 0 : t.id,
|
|
80
|
+
linkType: t == null ? void 0 : t.linkType,
|
|
81
|
+
direction: t == null ? void 0 : t.direction,
|
|
82
|
+
entityType: t == null ? void 0 : t.entityType,
|
|
83
|
+
nodeIsNull: !(t != null && t.node)
|
|
84
|
+
}))
|
|
85
|
+
), {
|
|
76
86
|
id: n.id,
|
|
77
|
-
links: ((
|
|
87
|
+
links: ((L = n.links.edges) == null ? void 0 : L.map((t) => t != null && t.node ? {
|
|
78
88
|
...t,
|
|
79
89
|
node: {
|
|
80
90
|
id: t.node.id,
|
|
81
91
|
name: t.node.name,
|
|
82
|
-
label:
|
|
92
|
+
label: G(t.node),
|
|
83
93
|
parents: t.node.parents || [],
|
|
84
94
|
subType: "subType" in t.node ? t.node.subType : void 0
|
|
85
|
-
}
|
|
86
|
-
|
|
95
|
+
},
|
|
96
|
+
isRestricted: !1
|
|
97
|
+
} : {
|
|
98
|
+
...t,
|
|
99
|
+
node: null,
|
|
100
|
+
isRestricted: !0
|
|
101
|
+
})) || []
|
|
87
102
|
// Flatten the edges structure
|
|
88
103
|
};
|
|
89
104
|
})) || [] };
|
|
90
|
-
} catch (
|
|
91
|
-
return console.error(`Error in getEntityLinks queryFn for ${
|
|
105
|
+
} catch (l) {
|
|
106
|
+
return console.error(`Error in getEntityLinks queryFn for ${r}:`, l), q.error(`Error fetching ${r} links`), { error: { status: "FETCH_ERROR", error: l.message } };
|
|
92
107
|
}
|
|
93
108
|
},
|
|
94
109
|
// 2. We should not create new caches when the entityIds argument changes.
|
|
95
110
|
serializeQueryArgs: ({ queryArgs: e }) => ({ projectName: e.projectName, entityType: e.entityType }),
|
|
96
111
|
// 3. We should force a refetch every time the entityIds changes.
|
|
97
|
-
forceRefetch: ({ currentArg: e, previousArg:
|
|
98
|
-
if (!e || !
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
101
|
-
for (const
|
|
102
|
-
if (!
|
|
112
|
+
forceRefetch: ({ currentArg: e, previousArg: a }) => {
|
|
113
|
+
if (!e || !a) return !0;
|
|
114
|
+
const r = new Set(e.entityIds), s = new Set(a.entityIds);
|
|
115
|
+
if (r.size !== s.size) return !0;
|
|
116
|
+
for (const c of r)
|
|
117
|
+
if (!s.has(c)) return !0;
|
|
103
118
|
return !1;
|
|
104
119
|
},
|
|
105
120
|
// 4. We should merge new entities into the cache ensuring there are no duplicates.
|
|
106
|
-
merge: (e,
|
|
107
|
-
if (!e) return
|
|
108
|
-
const
|
|
109
|
-
for (const
|
|
110
|
-
|
|
111
|
-
e.length = 0, e.push(...
|
|
121
|
+
merge: (e, a) => {
|
|
122
|
+
if (!e) return a;
|
|
123
|
+
const r = new Map(e.map((s) => [s.id, s]));
|
|
124
|
+
for (const s of a)
|
|
125
|
+
r.set(s.id, s);
|
|
126
|
+
e.length = 0, e.push(...r.values());
|
|
112
127
|
},
|
|
113
128
|
// Provide tags for potential invalidation
|
|
114
|
-
providesTags: (e,
|
|
129
|
+
providesTags: (e, a, r) => e ? [
|
|
115
130
|
...e.flatMap(
|
|
116
|
-
(
|
|
131
|
+
(s) => s.links.filter((c) => c.node !== null).map((c) => ({ type: "link", id: c.node.id }))
|
|
117
132
|
),
|
|
118
|
-
{ type: "link", id: `${
|
|
119
|
-
] : [{ type: "link", id: `${
|
|
133
|
+
{ type: "link", id: `${r.projectName}-${r.entityType}` }
|
|
134
|
+
] : [{ type: "link", id: `${r.projectName}-${r.entityType}` }],
|
|
120
135
|
// Subscribe to link.created and link.deleted WebSocket events
|
|
121
|
-
async onCacheEntryAdded({ projectName: e, entityIds:
|
|
136
|
+
async onCacheEntryAdded({ projectName: e, entityIds: a, entityType: r }, { cacheDataLoaded: s, cacheEntryRemoved: c, updateCachedData: $, dispatch: j }) {
|
|
122
137
|
let h;
|
|
123
|
-
const
|
|
124
|
-
let
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
},
|
|
128
|
-
var
|
|
129
|
-
if (
|
|
130
|
-
const
|
|
131
|
-
|
|
138
|
+
const u = /* @__PURE__ */ new Set(), R = 100, T = 500;
|
|
139
|
+
let b = !1;
|
|
140
|
+
const l = () => {
|
|
141
|
+
b || (b = !0, setTimeout(S, T));
|
|
142
|
+
}, S = async () => {
|
|
143
|
+
var y, i, m;
|
|
144
|
+
if (b = !1, !u.size) return;
|
|
145
|
+
const f = Array.from(u).slice(0, R);
|
|
146
|
+
f.forEach((p) => u.delete(p));
|
|
132
147
|
try {
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
{ projectName: e, entityIds:
|
|
148
|
+
const p = P[r], I = z[r], v = ((m = (i = (y = (await j(
|
|
149
|
+
A.endpoints[p].initiate(
|
|
150
|
+
{ projectName: e, entityIds: f },
|
|
136
151
|
{ forceRefetch: !0 }
|
|
137
152
|
)
|
|
138
|
-
).unwrap()).project) == null ? void 0 :
|
|
139
|
-
var
|
|
153
|
+
).unwrap()).project) == null ? void 0 : y[I]) == null ? void 0 : i.edges) == null ? void 0 : m.map(({ node: n }) => {
|
|
154
|
+
var d;
|
|
140
155
|
return {
|
|
141
156
|
id: n.id,
|
|
142
|
-
links: ((
|
|
143
|
-
...
|
|
157
|
+
links: ((d = n.links.edges) == null ? void 0 : d.map((o) => o != null && o.node ? {
|
|
158
|
+
...o,
|
|
144
159
|
node: {
|
|
145
|
-
id:
|
|
146
|
-
name:
|
|
147
|
-
label:
|
|
148
|
-
parents:
|
|
149
|
-
subType: "subType" in
|
|
150
|
-
}
|
|
151
|
-
|
|
160
|
+
id: o.node.id,
|
|
161
|
+
name: o.node.name,
|
|
162
|
+
label: G(o.node),
|
|
163
|
+
parents: o.node.parents || [],
|
|
164
|
+
subType: "subType" in o.node ? o.node.subType : void 0
|
|
165
|
+
},
|
|
166
|
+
isRestricted: !1
|
|
167
|
+
} : {
|
|
168
|
+
...o,
|
|
169
|
+
node: null,
|
|
170
|
+
isRestricted: !0
|
|
171
|
+
})) || []
|
|
152
172
|
};
|
|
153
173
|
})) || [];
|
|
154
|
-
|
|
155
|
-
for (const
|
|
156
|
-
const
|
|
157
|
-
|
|
174
|
+
$((n) => {
|
|
175
|
+
for (const d of v) {
|
|
176
|
+
const o = n.findIndex((L) => L.id === d.id);
|
|
177
|
+
o > -1 ? n[o] = d : n.push(d);
|
|
158
178
|
}
|
|
159
179
|
});
|
|
160
|
-
} catch (
|
|
161
|
-
console.error("Realtime link batch update failed",
|
|
180
|
+
} catch (p) {
|
|
181
|
+
console.error("Realtime link batch update failed", p);
|
|
162
182
|
} finally {
|
|
163
|
-
|
|
183
|
+
u.size && l();
|
|
164
184
|
}
|
|
165
185
|
};
|
|
166
186
|
try {
|
|
167
|
-
await
|
|
168
|
-
const
|
|
169
|
-
var
|
|
170
|
-
if (!
|
|
171
|
-
const
|
|
172
|
-
!
|
|
187
|
+
await s;
|
|
188
|
+
const f = async (y, i) => {
|
|
189
|
+
var I, w;
|
|
190
|
+
if (!y.startsWith("link.created") && !y.startsWith("link.deleted") || (i == null ? void 0 : i.project) !== e) return;
|
|
191
|
+
const m = (I = i == null ? void 0 : i.summary) == null ? void 0 : I.inputId, p = (w = i == null ? void 0 : i.summary) == null ? void 0 : w.outputId;
|
|
192
|
+
!m && !p || (m && u.add(m), p && u.add(p), l());
|
|
173
193
|
};
|
|
174
|
-
h =
|
|
194
|
+
h = N.subscribe("link", f);
|
|
175
195
|
} catch {
|
|
176
196
|
}
|
|
177
|
-
await
|
|
197
|
+
await c, h && N.unsubscribe(h);
|
|
178
198
|
}
|
|
179
199
|
})
|
|
180
200
|
})
|
|
181
|
-
}), { useGetEntityLinksQuery:
|
|
201
|
+
}), { useGetEntityLinksQuery: St } = x;
|
|
182
202
|
export {
|
|
183
|
-
|
|
184
|
-
|
|
203
|
+
x as entityLinksApi,
|
|
204
|
+
St as useGetEntityLinksQuery
|
|
185
205
|
};
|
|
186
206
|
//# sourceMappingURL=getEntityLinks.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEntityLinks.es.js","sources":["../../../../../../src/api/queries/links/getEntityLinks.ts"],"sourcesContent":["import { FetchBaseQueryError } from '@reduxjs/toolkit/query'\nimport {\n GetFoldersLinksQuery,\n GetTasksLinksQuery,\n GetProductsLinksQuery,\n GetVersionsLinksQuery,\n GetRepresentationsLinksQuery,\n GetWorkfilesLinksQuery,\n gqlLinksApi,\n foldersApi,\n} from '@shared/api/generated'\nimport { formatEntityLabel } from './utils/formatEntityLinks'\nimport { toast } from 'react-toastify'\nimport { PubSub } from '@shared/util'\n\n/**\n * Custom queryFn for fetching entity links with optimized caching behavior.\n *\n * Key features:\n * 1. Single cache per project and entity type - different entityIds combinations don't create new caches\n * 2. Skips fetching entities that are already cached\n * 3. Force refetch when entityIds change\n * 4. Merges new entities into cache without duplicates\n * 5. Supports all entity types: folders, tasks, products, versions, representations, workfiles\n */\n\n// Define the arguments for the query\nexport type GetEntityLinksArgs = {\n projectName: string\n entityIds: string[]\n entityType: 'folder' | 'task' | 'product' | 'version' | 'representation' | 'workfile'\n}\n\n// Define link types for each entity\nexport type FolderLink =\n GetFoldersLinksQuery['project']['folders']['edges'][0]['node']['links']['edges'][0]\nexport type TaskLink =\n GetTasksLinksQuery['project']['tasks']['edges'][0]['node']['links']['edges'][0]\nexport type ProductLink =\n GetProductsLinksQuery['project']['products']['edges'][0]['node']['links']['edges'][0]\nexport type VersionLink =\n GetVersionsLinksQuery['project']['versions']['edges'][0]['node']['links']['edges'][0]\nexport type RepresentationLink =\n GetRepresentationsLinksQuery['project']['representations']['edges'][0]['node']['links']['edges'][0]\nexport type WorkfileLink =\n GetWorkfilesLinksQuery['project']['workfiles']['edges'][0]['node']['links']['edges'][0]\n\nexport type EntityLinkQuery =\n | FolderLink\n | TaskLink\n | ProductLink\n | VersionLink\n | RepresentationLink\n | WorkfileLink\nexport type EntityLink = Pick<EntityLinkQuery, 'direction' | 'entityType' | 'id' | 'linkType'> & {\n node: Pick<EntityLinkQuery['node'], 'name' | 'id'> & {\n label?: string | null\n parents: string[]\n subType: string | undefined\n }\n}\n\n// Define the result type for the query - simplified without edges wrapper\nexport type EntityWithLinks = {\n id: string\n links: EntityLink[]\n}\n\nexport type GetEntityLinksResult = EntityWithLinks[]\n\n// Map entity types to their corresponding GraphQL endpoints\nconst entityEndpoints = {\n folder: 'GetFoldersLinks',\n task: 'GetTasksLinks',\n product: 'GetProductsLinks',\n version: 'GetVersionsLinks',\n representation: 'GetRepresentationsLinks',\n workfile: 'GetWorkfilesLinks',\n} as const\n\n// Map entity types to their result path in the GraphQL response\nconst entityResultPaths = {\n folder: 'folders',\n task: 'tasks',\n product: 'products',\n version: 'versions',\n representation: 'representations',\n workfile: 'workfiles',\n} as const\n\nconst injectedQueries = foldersApi.injectEndpoints({\n endpoints: (build) => ({\n getEntityLinks: build.query<GetEntityLinksResult, GetEntityLinksArgs>({\n queryFn: async (\n { projectName, entityIds, entityType },\n { getState, dispatch, queryCacheKey, forced },\n ) => {\n try {\n // Get current state to access cached data\n const state = getState() as any\n const cacheKey = JSON.stringify({ projectName, entityType })\n\n // Access the cache entry for this project and entity type\n const cacheEntry =\n state.restApi?.queries?.[queryCacheKey || `getEntityLinks(${cacheKey})`]\n const cachedData = cacheEntry?.data || []\n\n // 1. When fetching new data for entityIds, we should skip entities that are already in the cache.\n const cachedEntityIds = new Set(cachedData.map((entity: EntityWithLinks) => entity.id))\n const entityIdsToFetch = entityIds.filter((id) => !cachedEntityIds?.has(id) || forced)\n\n // If all entities are already cached, return the cached data\n if (entityIdsToFetch.length === 0) {\n return { data: cachedData }\n }\n\n // Get the appropriate endpoint and parameter names\n const endpoint = entityEndpoints[entityType]\n const resultPath = entityResultPaths[entityType]\n\n // Fetch only the entities that aren't already cached\n const result = await dispatch(\n (gqlLinksApi.endpoints as any)[endpoint].initiate(\n { projectName, entityIds: entityIdsToFetch },\n { forceRefetch: true },\n ),\n ).unwrap()\n\n const newEntities =\n result.project?.[resultPath]?.edges?.map(({ node }: { node: any }) => ({\n id: node.id,\n links:\n node.links.edges\n ?.filter((e: EntityLinkQuery | null) => !!e?.node)\n ?.map((linkEdge: EntityLinkQuery) => ({\n ...linkEdge,\n node: {\n id: linkEdge.node.id,\n name: linkEdge.node.name,\n label: formatEntityLabel(linkEdge.node),\n parents: linkEdge.node.parents || [],\n subType: 'subType' in linkEdge.node ? linkEdge.node.subType : undefined,\n },\n })) || [], // Flatten the edges structure\n })) || []\n\n // Return the new entities - the merge function will handle combining with existing cache\n return { data: newEntities }\n } catch (error: any) {\n console.error(`Error in getEntityLinks queryFn for ${entityType}:`, error)\n toast.error(`Error fetching ${entityType} links`)\n return { error: { status: 'FETCH_ERROR', error: error.message } as FetchBaseQueryError }\n }\n },\n // 2. We should not create new caches when the entityIds argument changes.\n serializeQueryArgs: ({ queryArgs }) => {\n // Use only projectName and entityType for the cache key, ignoring entityIds\n return { projectName: queryArgs.projectName, entityType: queryArgs.entityType }\n },\n // 3. We should force a refetch every time the entityIds changes.\n forceRefetch: ({ currentArg, previousArg }) => {\n // Force refetch if entityIds array is different\n if (!currentArg || !previousArg) return true\n\n // Compare arrays by converting to sets\n const currentIds = new Set(currentArg.entityIds)\n const previousIds = new Set(previousArg.entityIds)\n\n if (currentIds.size !== previousIds.size) return true\n\n // Check if any IDs are different\n for (const id of currentIds) {\n if (!previousIds.has(id)) return true\n }\n\n return false\n },\n // 4. We should merge new entities into the cache ensuring there are no duplicates.\n merge: (currentCache, newItems) => {\n if (!currentCache) return newItems\n\n const cacheMap = new Map(currentCache.map((item) => [item.id, item]))\n for (const newItem of newItems) {\n cacheMap.set(newItem.id, newItem) // Overwrite if exists, add if not\n }\n // Update currentCache in-place\n currentCache.length = 0\n currentCache.push(...cacheMap.values())\n },\n // Provide tags for potential invalidation\n providesTags: (result, error, arg) =>\n result\n ? [\n ...result.flatMap((entity) =>\n entity.links.map((link) => ({ type: 'link', id: link.node.id })),\n ),\n { type: 'link', id: `${arg.projectName}-${arg.entityType}` },\n ]\n : [{ type: 'link', id: `${arg.projectName}-${arg.entityType}` }],\n // Subscribe to link.created and link.deleted WebSocket events\n async onCacheEntryAdded(\n { projectName, entityIds, entityType },\n { cacheDataLoaded, cacheEntryRemoved, updateCachedData, dispatch },\n ) {\n let token: any\n const pendingEntityIds = new Set<string>()\n const MAX_BATCH = 100\n const INTERVAL = 500\n let scheduled = false\n\n const schedule = () => {\n if (scheduled) return\n scheduled = true\n setTimeout(flush, INTERVAL)\n }\n\n const flush = async () => {\n scheduled = false\n if (!pendingEntityIds.size) return\n const batchIds = Array.from(pendingEntityIds).slice(0, MAX_BATCH)\n batchIds.forEach((id) => pendingEntityIds.delete(id))\n\n try {\n // Get the appropriate endpoint and parameter names\n const endpoint = entityEndpoints[entityType]\n const resultPath = entityResultPaths[entityType]\n\n // Fetch fresh data for the affected entities\n const result = await dispatch(\n (gqlLinksApi.endpoints as any)[endpoint].initiate(\n { projectName, entityIds: batchIds },\n { forceRefetch: true },\n ),\n ).unwrap()\n\n const updatedEntities =\n result.project?.[resultPath]?.edges?.map(({ node }: { node: any }) => ({\n id: node.id,\n links:\n node.links.edges\n ?.filter((e: EntityLinkQuery | null) => !!e?.node)\n ?.map((linkEdge: EntityLinkQuery) => ({\n ...linkEdge,\n node: {\n id: linkEdge.node.id,\n name: linkEdge.node.name,\n label: formatEntityLabel(linkEdge.node),\n parents: linkEdge.node.parents || [],\n subType: 'subType' in linkEdge.node ? linkEdge.node.subType : undefined,\n },\n })) || [],\n })) || []\n\n updateCachedData((draft: EntityWithLinks[]) => {\n for (const updatedEntity of updatedEntities) {\n const idx = draft.findIndex((entity) => entity.id === updatedEntity.id)\n if (idx > -1) {\n // Update existing entity's links\n draft[idx] = updatedEntity\n } else {\n // Add new entity if not in cache\n draft.push(updatedEntity)\n }\n }\n })\n } catch (err) {\n console.error('Realtime link batch update failed', err)\n } finally {\n if (pendingEntityIds.size) schedule()\n }\n }\n\n try {\n await cacheDataLoaded\n\n const handlePubSub = async (_topic: string, message: any) => {\n // Only react to link.created and link.deleted events for this project\n if (!_topic.startsWith('link.created') && !_topic.startsWith('link.deleted')) return\n if (message?.project !== projectName) return\n\n // Link events have inputId and outputId in the summary (both entities affected by the link)\n const inputId = message?.summary?.inputId\n const outputId = message?.summary?.outputId\n if (!inputId && !outputId) return\n\n // Add both entities to pending list since both are affected by the link change\n if (inputId) pendingEntityIds.add(inputId)\n if (outputId) pendingEntityIds.add(outputId)\n schedule()\n }\n\n // Subscribe to link events\n // NOTE: backend emits topics like 'link.created' and 'link.deleted'.\n // PubSub supports prefix matching when subscribing.\n token = PubSub.subscribe('link', handlePubSub)\n } catch (e) {\n // cache entry removed before loaded - ignore\n }\n\n await cacheEntryRemoved\n if (token) PubSub.unsubscribe(token)\n },\n }),\n }),\n})\n\nexport const { useGetEntityLinksQuery } = injectedQueries\nexport { injectedQueries as entityLinksApi }\n"],"names":["entityEndpoints","entityResultPaths","injectedQueries","foldersApi","build","projectName","entityIds","entityType","getState","dispatch","queryCacheKey","forced","state","cacheKey","cacheEntry","_b","_a","cachedData","cachedEntityIds","entity","entityIdsToFetch","id","endpoint","resultPath","_e","_d","_c","gqlLinksApi","node","e","linkEdge","formatEntityLabel","error","toast","queryArgs","currentArg","previousArg","currentIds","previousIds","currentCache","newItems","cacheMap","item","newItem","result","arg","link","cacheDataLoaded","cacheEntryRemoved","updateCachedData","token","pendingEntityIds","MAX_BATCH","INTERVAL","scheduled","schedule","flush","batchIds","updatedEntities","draft","updatedEntity","idx","err","handlePubSub","_topic","message","inputId","outputId","PubSub","useGetEntityLinksQuery"],"mappings":";;;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,oBAAA,MAAM,qCAAqCA,CAAG;AAAA,UAAA,UACtD;AACI,YAAAX,EAAiB,QAAeI,EAAA;AAAA,UAAA;AAAA,QAExC;AAEI,YAAA;AACI,gBAAAR;AAEA,gBAAAgB,IAAe,OAAOC,GAAgBC,MAAiB;;AAGvD,gBADA,CAACD,EAAO,WAAW,cAAc,KAAK,CAACA,EAAO,WAAW,cAAc,MACvEC,KAAA,gBAAAA,EAAS,aAAY5D,EAAa;AAGhC,kBAAA6D,KAAUlD,IAAAiD,KAAA,gBAAAA,EAAS,YAAT,gBAAAjD,EAAkB,SAC5BmD,KAAWpD,IAAAkD,KAAA,gBAAAA,EAAS,YAAT,gBAAAlD,EAAkB;AAC/B,YAAA,CAACmD,KAAW,CAACC,MAGbD,KAA0Bf,EAAA,IAAIe,CAAO,GACrCC,KAA2BhB,EAAA,IAAIgB,CAAQ,GAClCZ,EAAA;AAAA,UACX;AAKQ,UAAAL,IAAAkB,EAAO,UAAU,QAAQL,CAAY;AAAA,gBACnC;AAAA,QAAA;AAIN,cAAAf,GACFE,KAAckB,EAAA,YAAYlB,CAAK;AAAA,MAAA;AAAA,IAEtC,CAAA;AAAA,EACH;AACF,CAAC,GAEY,EAAE,wBAAAmB,OAA2BnE;"}
|
|
1
|
+
{"version":3,"file":"getEntityLinks.es.js","sources":["../../../../../../src/api/queries/links/getEntityLinks.ts"],"sourcesContent":["import { FetchBaseQueryError } from '@reduxjs/toolkit/query'\nimport {\n GetFoldersLinksQuery,\n GetTasksLinksQuery,\n GetProductsLinksQuery,\n GetVersionsLinksQuery,\n GetRepresentationsLinksQuery,\n GetWorkfilesLinksQuery,\n gqlLinksApi,\n foldersApi,\n} from '@shared/api/generated'\nimport { formatEntityLabel } from './utils/formatEntityLinks'\nimport { toast } from 'react-toastify'\nimport { PubSub } from '@shared/util'\n\n/**\n * Custom queryFn for fetching entity links with optimized caching behavior.\n *\n * Key features:\n * 1. Single cache per project and entity type - different entityIds combinations don't create new caches\n * 2. Skips fetching entities that are already cached\n * 3. Force refetch when entityIds change\n * 4. Merges new entities into cache without duplicates\n * 5. Supports all entity types: folders, tasks, products, versions, representations, workfiles\n */\n\n// Define the arguments for the query\nexport type GetEntityLinksArgs = {\n projectName: string\n entityIds: string[]\n entityType: 'folder' | 'task' | 'product' | 'version' | 'representation' | 'workfile'\n}\n\n// Define link types for each entity\nexport type FolderLink =\n GetFoldersLinksQuery['project']['folders']['edges'][0]['node']['links']['edges'][0]\nexport type TaskLink =\n GetTasksLinksQuery['project']['tasks']['edges'][0]['node']['links']['edges'][0]\nexport type ProductLink =\n GetProductsLinksQuery['project']['products']['edges'][0]['node']['links']['edges'][0]\nexport type VersionLink =\n GetVersionsLinksQuery['project']['versions']['edges'][0]['node']['links']['edges'][0]\nexport type RepresentationLink =\n GetRepresentationsLinksQuery['project']['representations']['edges'][0]['node']['links']['edges'][0]\nexport type WorkfileLink =\n GetWorkfilesLinksQuery['project']['workfiles']['edges'][0]['node']['links']['edges'][0]\n\nexport type EntityLinkQuery =\n | FolderLink\n | TaskLink\n | ProductLink\n | VersionLink\n | RepresentationLink\n | WorkfileLink\nexport type EntityLink = Pick<EntityLinkQuery, 'direction' | 'entityType' | 'id' | 'linkType'> & {\n node: Pick<EntityLinkQuery['node'], 'name' | 'id'> & {\n label?: string | null\n parents: string[]\n subType: string | undefined\n } | null\n isRestricted?: boolean // flag to indicate if this link is restricted\n}\n\n// Define the result type for the query - simplified without edges wrapper\nexport type EntityWithLinks = {\n id: string\n links: EntityLink[]\n}\n\nexport type GetEntityLinksResult = EntityWithLinks[]\n\n// Map entity types to their corresponding GraphQL endpoints\nconst entityEndpoints = {\n folder: 'GetFoldersLinks',\n task: 'GetTasksLinks',\n product: 'GetProductsLinks',\n version: 'GetVersionsLinks',\n representation: 'GetRepresentationsLinks',\n workfile: 'GetWorkfilesLinks',\n} as const\n\n// Map entity types to their result path in the GraphQL response\nconst entityResultPaths = {\n folder: 'folders',\n task: 'tasks',\n product: 'products',\n version: 'versions',\n representation: 'representations',\n workfile: 'workfiles',\n} as const\n\nconst injectedQueries = foldersApi.injectEndpoints({\n endpoints: (build) => ({\n getEntityLinks: build.query<GetEntityLinksResult, GetEntityLinksArgs>({\n queryFn: async (\n { projectName, entityIds, entityType },\n { getState, dispatch, queryCacheKey, forced },\n ) => {\n try {\n // Get current state to access cached data\n const state = getState() as any\n const cacheKey = JSON.stringify({ projectName, entityType })\n\n // Access the cache entry for this project and entity type\n const cacheEntry =\n state.restApi?.queries?.[queryCacheKey || `getEntityLinks(${cacheKey})`]\n const cachedData = cacheEntry?.data || []\n\n // 1. When fetching new data for entityIds, we should skip entities that are already in the cache.\n const cachedEntityIds = new Set(cachedData.map((entity: EntityWithLinks) => entity.id))\n const entityIdsToFetch = entityIds.filter((id) => !cachedEntityIds?.has(id) || forced)\n\n // If all entities are already cached, return the cached data\n if (entityIdsToFetch.length === 0) {\n return { data: cachedData }\n }\n\n // Get the appropriate endpoint and parameter names\n const endpoint = entityEndpoints[entityType]\n const resultPath = entityResultPaths[entityType]\n\n // Fetch only the entities that aren't already cached\n const result = await dispatch(\n (gqlLinksApi.endpoints as any)[endpoint].initiate(\n { projectName, entityIds: entityIdsToFetch },\n { forceRefetch: true },\n ),\n ).unwrap()\n\n const newEntities =\n result.project?.[resultPath]?.edges?.map(({ node }: { node: any }) => {\n // Log restricted links\n const restrictedLinks = node.links.edges?.filter((e: EntityLinkQuery | null) => !e?.node) || []\n if (restrictedLinks.length > 0) {\n console.log(`[RESTRICTED LINKS] Entity ${node.id} (${node.name}) has ${restrictedLinks.length} restricted link(s):`,\n restrictedLinks.map((link: any) => ({\n linkId: link?.id,\n linkType: link?.linkType,\n direction: link?.direction,\n entityType: link?.entityType,\n nodeIsNull: !link?.node\n }))\n )\n }\n\n return {\n id: node.id,\n links:\n node.links.edges\n ?.map((linkEdge: EntityLinkQuery | null) => {\n if (!linkEdge?.node) {\n // Restricted link - node is null\n return {\n ...linkEdge,\n node: null,\n isRestricted: true,\n } as EntityLink\n }\n // Normal link\n return {\n ...linkEdge,\n node: {\n id: linkEdge.node.id,\n name: linkEdge.node.name,\n label: formatEntityLabel(linkEdge.node),\n parents: linkEdge.node.parents || [],\n subType: 'subType' in linkEdge.node ? linkEdge.node.subType : undefined,\n },\n isRestricted: false,\n } as EntityLink\n }) || [], // Flatten the edges structure\n }\n }) || []\n\n // Return the new entities - the merge function will handle combining with existing cache\n return { data: newEntities }\n } catch (error: any) {\n console.error(`Error in getEntityLinks queryFn for ${entityType}:`, error)\n toast.error(`Error fetching ${entityType} links`)\n return { error: { status: 'FETCH_ERROR', error: error.message } as FetchBaseQueryError }\n }\n },\n // 2. We should not create new caches when the entityIds argument changes.\n serializeQueryArgs: ({ queryArgs }) => {\n // Use only projectName and entityType for the cache key, ignoring entityIds\n return { projectName: queryArgs.projectName, entityType: queryArgs.entityType }\n },\n // 3. We should force a refetch every time the entityIds changes.\n forceRefetch: ({ currentArg, previousArg }) => {\n // Force refetch if entityIds array is different\n if (!currentArg || !previousArg) return true\n\n // Compare arrays by converting to sets\n const currentIds = new Set(currentArg.entityIds)\n const previousIds = new Set(previousArg.entityIds)\n\n if (currentIds.size !== previousIds.size) return true\n\n // Check if any IDs are different\n for (const id of currentIds) {\n if (!previousIds.has(id)) return true\n }\n\n return false\n },\n // 4. We should merge new entities into the cache ensuring there are no duplicates.\n merge: (currentCache, newItems) => {\n if (!currentCache) return newItems\n\n const cacheMap = new Map(currentCache.map((item) => [item.id, item]))\n for (const newItem of newItems) {\n cacheMap.set(newItem.id, newItem) // Overwrite if exists, add if not\n }\n // Update currentCache in-place\n currentCache.length = 0\n currentCache.push(...cacheMap.values())\n },\n // Provide tags for potential invalidation\n providesTags: (result, error, arg) =>\n result\n ? [\n ...result.flatMap((entity) =>\n entity.links\n .filter((link) => link.node !== null)\n .map((link) => ({ type: 'link', id: link.node!.id })),\n ),\n { type: 'link', id: `${arg.projectName}-${arg.entityType}` },\n ]\n : [{ type: 'link', id: `${arg.projectName}-${arg.entityType}` }],\n // Subscribe to link.created and link.deleted WebSocket events\n async onCacheEntryAdded(\n { projectName, entityIds, entityType },\n { cacheDataLoaded, cacheEntryRemoved, updateCachedData, dispatch },\n ) {\n let token: any\n const pendingEntityIds = new Set<string>()\n const MAX_BATCH = 100\n const INTERVAL = 500\n let scheduled = false\n\n const schedule = () => {\n if (scheduled) return\n scheduled = true\n setTimeout(flush, INTERVAL)\n }\n\n const flush = async () => {\n scheduled = false\n if (!pendingEntityIds.size) return\n const batchIds = Array.from(pendingEntityIds).slice(0, MAX_BATCH)\n batchIds.forEach((id) => pendingEntityIds.delete(id))\n\n try {\n // Get the appropriate endpoint and parameter names\n const endpoint = entityEndpoints[entityType]\n const resultPath = entityResultPaths[entityType]\n\n // Fetch fresh data for the affected entities\n const result = await dispatch(\n (gqlLinksApi.endpoints as any)[endpoint].initiate(\n { projectName, entityIds: batchIds },\n { forceRefetch: true },\n ),\n ).unwrap()\n\n const updatedEntities =\n result.project?.[resultPath]?.edges?.map(({ node }: { node: any }) => {\n\n return {\n id: node.id,\n links:\n node.links.edges\n ?.map((linkEdge: EntityLinkQuery | null) => {\n if (!linkEdge?.node) {\n // Restricted link - node is null\n return {\n ...linkEdge,\n node: null,\n isRestricted: true,\n } as EntityLink\n }\n // Normal link\n return {\n ...linkEdge,\n node: {\n id: linkEdge.node.id,\n name: linkEdge.node.name,\n label: formatEntityLabel(linkEdge.node),\n parents: linkEdge.node.parents || [],\n subType: 'subType' in linkEdge.node ? linkEdge.node.subType : undefined,\n },\n isRestricted: false,\n } as EntityLink\n }) || [],\n }\n }) || []\n\n updateCachedData((draft: EntityWithLinks[]) => {\n for (const updatedEntity of updatedEntities) {\n const idx = draft.findIndex((entity) => entity.id === updatedEntity.id)\n if (idx > -1) {\n // Update existing entity's links\n draft[idx] = updatedEntity\n } else {\n // Add new entity if not in cache\n draft.push(updatedEntity)\n }\n }\n })\n } catch (err) {\n console.error('Realtime link batch update failed', err)\n } finally {\n if (pendingEntityIds.size) schedule()\n }\n }\n\n try {\n await cacheDataLoaded\n\n const handlePubSub = async (_topic: string, message: any) => {\n // Only react to link.created and link.deleted events for this project\n if (!_topic.startsWith('link.created') && !_topic.startsWith('link.deleted')) return\n if (message?.project !== projectName) return\n\n // Link events have inputId and outputId in the summary (both entities affected by the link)\n const inputId = message?.summary?.inputId\n const outputId = message?.summary?.outputId\n if (!inputId && !outputId) return\n\n // Add both entities to pending list since both are affected by the link change\n if (inputId) pendingEntityIds.add(inputId)\n if (outputId) pendingEntityIds.add(outputId)\n schedule()\n }\n\n // Subscribe to link events\n // NOTE: backend emits topics like 'link.created' and 'link.deleted'.\n // PubSub supports prefix matching when subscribing.\n token = PubSub.subscribe('link', handlePubSub)\n } catch (e) {\n // cache entry removed before loaded - ignore\n }\n\n await cacheEntryRemoved\n if (token) PubSub.unsubscribe(token)\n },\n }),\n }),\n})\n\nexport const { useGetEntityLinksQuery } = injectedQueries\nexport { injectedQueries as entityLinksApi }\n"],"names":["entityEndpoints","entityResultPaths","injectedQueries","foldersApi","build","projectName","entityIds","entityType","getState","dispatch","queryCacheKey","forced","state","cacheKey","cacheEntry","_b","_a","cachedData","cachedEntityIds","entity","entityIdsToFetch","id","endpoint","resultPath","_e","_d","_c","gqlLinksApi","node","restrictedLinks","e","link","linkEdge","formatEntityLabel","error","toast","queryArgs","currentArg","previousArg","currentIds","previousIds","currentCache","newItems","cacheMap","item","newItem","result","arg","cacheDataLoaded","cacheEntryRemoved","updateCachedData","token","pendingEntityIds","MAX_BATCH","INTERVAL","scheduled","schedule","flush","batchIds","updatedEntities","draft","updatedEntity","idx","err","handlePubSub","_topic","message","inputId","outputId","PubSub","useGetEntityLinksQuery"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEA,MAAMA,IAAkB;AAAA,EACtB,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,UAAU;AACZ,GAGMC,IAAoB;AAA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 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../base/client.cjs.js");require("../../generated/graphql.cjs.js");require("../../generated/graphqlLinks.cjs.js");require("../../generated/access.cjs.js");require("../../generated/actions.cjs.js");require("../../generated/activityFeed.cjs.js");require("../../generated/addons.cjs.js");require("../../generated/anatomy.cjs.js");require("../../generated/attributes.cjs.js");require("../../generated/authentication.cjs.js");require("../../generated/bundles.cjs.js");require("../../generated/configuration.cjs.js");require("../../generated/desktop.cjs.js");require("../../generated/entityLists.cjs.js");require("../../generated/events.cjs.js");require("../../generated/files.cjs.js");require("../../generated/folders.cjs.js");require("../../generated/inbox.cjs.js");require("../../generated/links.cjs.js");require("../../generated/market.cjs.js");require("../../generated/onboarding.cjs.js");const W=require("../../generated/operations.cjs.js");require("../../generated/products.cjs.js");require("../../generated/projectDashboard.cjs.js");require("../../generated/projects.cjs.js");require("../../generated/reviewables.cjs.js");require("../../generated/services.cjs.js");require("../../generated/system.cjs.js");require("../../generated/tasks.cjs.js");require("../../generated/teams.cjs.js");require("../../generated/thumbnails.cjs.js");require("../../generated/uRIs.cjs.js");require("../../generated/users.cjs.js");require("../../generated/versions.cjs.js");require("../../generated/workfiles.cjs.js");require("../../generated/ynputCloud.cjs.js");require("../../generated/grouping.cjs.js");require("../../generated/views.cjs.js");require("../actions/getActions.cjs.js");require("../activities/getActivities.cjs.js");require("../activities/updateActivities.cjs.js");require("../activities/updateReaction.cjs.js");require("../activities/getMentions.cjs.js");require("../activities/getCategories.cjs.js");require("../addons/getAddons.cjs.js");require("../addons/updateAddons.cjs.js");require("../attributes/getAttributes.cjs.js");require("../attributes/updateAttributes.cjs.js");require("../authentication/getAuthentication.cjs.js");require("../cloud/cloud.cjs.js");require("../entities/getEntity.cjs.js");const E=require("../entities/getEntityPanel.cjs.js");require("../entities/updateEntity.cjs.js");const B=require("../entityLists/getLists.cjs.js");require("../entityLists/updateLists.cjs.js");require("../entityLists/getListsAttributes.cjs.js");require("../entityLists/updateListsAttributes.cjs.js");require("../entityLists/listFolders.cjs.js");const w=require("../folders/getFolders.cjs.js");require("../grouping/getGrouping.cjs.js");require("../links/updateLinks.cjs.js");require("../links/getLinks.cjs.js");require("../links/getEntityLinks.cjs.js");const T=require("./getOverview.cjs.js"),G=require("./patchVersions.cjs.js"),J=require("./patchProducts.cjs.js");require("../permissions/getPermissions.cjs.js");require("../products/createProduct.cjs.js");require("../project/getProject.cjs.js");require("../project/updateProject.cjs.js");require("../review/getReview.cjs.js");require("../review/updateReview.cjs.js");require("../share/share.cjs.js");require("../system/getSystem.cjs.js");require("../userDashboard/getUserDashboard.cjs.js");require("../users/getUsers.cjs.js");require("../users/updateUsers.cjs.js");require("../users/guests.cjs.js");require("../versions/updateVersions.cjs.js");require("../versions/getVersionsProducts.cjs.js");require("../views/getViews.cjs.js");require("../views/updateViews.cjs.js");require("../watchers/getWatchers.cjs.js");require("../uris/getUris.cjs.js");const N=require("./filterRefetchUtils.cjs.js"),j=require("./refetchFilteredEntities.cjs.js"),O=(e,t)=>{if(Object.keys(t).forEach(r=>{r==="attrib"||r==="links"||r==="deleteLinks"||(e[r]=t[r])}),t.attrib&&(e.attrib={...e.attrib,...t.attrib}),t.links){const r=e.links||[],n=t.links||[];e.links||(e.links=[]),e.links=[...r],n.forEach(i=>{const u=e.links.findIndex(l=>l.id===i.id);u!==-1?e.links[u]={...e.links[u],...i}:e.links.push(i)})}if(t.deleteLinks){const r=t.deleteLinks||[];e.links||(e.links=[]),r.forEach(n=>{e.links=e.links.filter(i=>i.id!==n)})}},S=e=>[{type:"overviewTask",id:"LIST"},...e.map(t=>({type:"overviewTask",id:t.entityId})),...e.filter(t=>{var r;return(r=t.data)==null?void 0:r.projectName}).map(t=>{var r;return{type:"overviewTask",id:(r=t.data)==null?void 0:r.projectName}})],K=e=>[...e.map(t=>({type:"folder",id:t.entityId})),...e.filter(t=>{var r;return(r=t.data)==null?void 0:r.projectName}).map(t=>{var r;return{type:"folder",id:(r=t.data)==null?void 0:r.projectName}})],x=(e,t,r)=>({entityId:e,entityType:t,type:"update",data:{deleteLinks:r}}),X=(e,t)=>e.map(r=>x(r.entityId,r.entityType,t)),Y=(e,{state:t,dispatch:r},n)=>{const i=e.reduce((u,l)=>(u[l.entityType]||(u[l.entityType]=[]),u[l.entityType].push(l),u),{});i.task&&b(i.task,{state:t,dispatch:r},n),i.folder&&P(i.folder,{state:t,dispatch:r},n)},b=(e,{state:t,dispatch:r},n)=>{const i=S(e),u=T.default.util.selectInvalidatedBy(t,i);for(const l of u)if(l.endpointName==="getTasksListInfinite"){const a=r(T.default.util.updateQueryData("getTasksListInfinite",l.originalArgs,o=>{for(const s of e)if(s.type==="create"&&s.data)o.pages[0].tasks.push(s.data);else for(const d of o.pages){const f=d.tasks.find(p=>p.id===s.entityId);f&&O(f,s.data)}}));n==null||n.push(a)}else{const a=r(T.default.util.updateQueryData(l.endpointName,l.originalArgs,o=>{var s;for(const d of e)if(d.type==="create"&&d.data&&((s=l.originalArgs.parentIds)!=null&&s.includes(d.data.folderId))){const f=p=>{p.push(d.data)};if(Array.isArray(o))f(o);else if(o.tasks&&Array.isArray(o.tasks)){const p=o.tasks;f(p)}}else{const f=p=>{const h=p.find(m=>m.id===d.entityId);h&&O(h,d.data)};if(Array.isArray(o))f(o);else if(o.tasks&&Array.isArray(o.tasks)){const p=o.tasks;f(p)}}}));n==null||n.push(a)}},Z=(e,{dispatch:t})=>{e.length&&t(T.default.util.invalidateTags(S(e)))},P=(e,{state:t,dispatch:r},n)=>{const i=w.foldersQueries.util.selectInvalidatedBy(t,K(e)).filter(u=>u.endpointName==="getFolderList");for(const u of i){const l=r(w.foldersQueries.util.updateQueryData(u.endpointName,u.originalArgs,a=>{const o=new Map;a.folders.forEach(s=>{o.set(s.id,s)});for(const s of e)if(s.type==="create"&&s.data)a.folders.push(s.data);else{const d=o.get(s.entityId);d&&O(d,s.data)}}));n==null||n.push(l)}},$=(e,t)=>{const r={name:e.name,attrib:e.attrib,status:e.status,tags:e.tags,label:e.label,updatedAt:e.updatedAt,createdAt:e.createdAt,hasReviewables:e.hasReviewables,thumbnailId:e.thumbnailId};switch(t){case"task":return{...r,task:{assignees:e.assignees,label:e.label,name:e.name,taskType:e.taskType}};case"folder":return{...r,folder:{id:e.id,name:e.name,label:e.label,folderType:e.folderType}};case"version":return{...r,version:{id:e.id,name:e.name}};case"representation":return{...r}}},U=(e=[],t)=>{const r=e.find(a=>a.entityId===t.id),n=r==null?void 0:r.data;if(!n||r.entityType==="product"||r.entityType==="workfile")return console.warn("No operation data found or entity type not supported");const i=$(n,r.entityType);if(r.entityType==="folder"&&n.name&&t.path){const a=t.path.split("/");a[a.length-1]=n.name,i.path=a.join("/")}function u(a){Object.entries(a).forEach(([o,s])=>{s===void 0?delete a[o]:s!==null&&typeof s=="object"&&u(s)})}u(i);const l={...t,...i,attrib:{...(t==null?void 0:t.attrib)||{},...i.attrib},folder:{...(t==null?void 0:t.folder)||{},...i.folder},task:{...(t==null?void 0:t.task)||{},...i.task},version:{...(t==null?void 0:t.version)||{},...i.version}};Object.assign(t,l)},ee=(e,{state:t,dispatch:r},n)=>{const i=e.map(l=>({type:"entityListItem",id:l.entityId})),u=B.default.util.selectInvalidatedBy(t,i);for(const l of u)if(l.endpointName==="getListItemsInfinite"){const a=r(B.default.util.updateQueryData("getListItemsInfinite",l.originalArgs,o=>{for(const s of e)if(s.type==="update"&&s.data)for(const d of o.pages){const f=d.items.find(p=>p.entityId===s.entityId);f&&O(f,s.data)}}));n==null||n.push(a)}},C=e=>e.reduce((t,r)=>(t[r.type].push(r),t),{create:[],update:[],delete:[]}),R=W.api.enhanceEndpoints({endpoints:{operations:{}}}),te=R.injectEndpoints({endpoints:e=>({updateOverviewEntities:e.mutation({async queryFn(t,{dispatch:r}){try{const n=await r(R.endpoints.operations.initiate(t));if(n.error)return{error:n.error};const i=n.data,u=new Set,l=new Set;for(const a of(i==null?void 0:i.operations)||[])a.success===!1&&a.detail&&(u.has(a.detail)||u.add(a.detail),l.has(a.errorCode)||l.add(a.errorCode));return u.size>0?{error:{status:"FETCH_ERROR",error:Array.from(u).join(", "),errorCodes:Array.from(l)}}:{data:i}}catch(n){return console.error(n),{error:{status:"FETCH_ERROR",error:n.message}}}},async onQueryStarted({operationsRequestModel:t,patchOperations:r=[],projectName:n},{dispatch:i,queryFulfilled:u,getState:l}){var L,A,F,D,Q;if(!((L=t.operations)!=null&&L.length))return;const{operations:a}=t,o=a.reduce((c,y)=>(c[y.entityType].push(y),c),{task:[],folder:[],product:[],version:[],representation:[],workfile:[]}),s=l(),d=[];if((A=o.task)!=null&&A.length){const{delete:c,update:y}=C(o.task),q=y.filter(g=>!r.some(v=>v.entityId===g.entityId));b(q,{state:s,dispatch:i},d),Z([...c],{dispatch:i})}if((F=o.folder)!=null&&F.length){const{delete:c,update:y}=C(o.folder),q=y.filter(g=>!r.some(v=>v.entityId===g.entityId));P(q,{state:s,dispatch:i},d),c.length&&i(w.foldersQueries.util.invalidateTags([{type:"folder",id:"LIST"}]))}const f=r.filter(c=>c.entityType==="task"),p=r.filter(c=>c.entityType==="folder");f.length&&b(f,{state:s,dispatch:i},d),p.length&&P(p,{state:s,dispatch:i},d),ee([...a,...r],{state:s,dispatch:i},d),(D=o.version)!=null&&D.length&&G.patchVersions(o.version,{state:s,dispatch:i},d),(Q=o.product)!=null&&Q.length&&J.patchProducts(o.product,{state:s,dispatch:i},d);const h=a.map(c=>({id:c.entityId,type:c.entityType})),m=h.map(c=>({type:"entities",id:c.id})),M=()=>i(E.detailsPanelQueries.util.invalidateTags(m)),_=E.detailsPanelQueries.util.selectInvalidatedBy(s,h),H=E.detailsPanelQueries.util.selectInvalidatedBy(s,m);for(const c of H){if(c.endpointName!=="getEntitiesDetailsPanel")continue;const y=i(E.detailsPanelQueries.util.updateQueryData(c.endpointName,c.originalArgs,q=>{for(const g of q)U(a,g)}));d.push(y)}try{await u;const c=o.task||[],y=o.folder||[];if(c.length===0&&y.length===0)return;const q=N.getUpdatedEntityIds(c),g=N.getUpdatedEntityIds(y),v=q.map(k=>({type:"overviewTask",id:k})),V=T.default.util.selectInvalidatedBy(s,v).filter(k=>k.endpointName==="getTasksListInfinite");if(q.length>0&&n){for(const I of V)await j.refetchTasksForCacheEntry({dispatch:i,projectName:n,updatedTaskIds:q,cacheEntry:I});const k=T.default.util.selectInvalidatedBy(s,v).filter(I=>I.endpointName==="getOverviewTasksByFolders");for(const I of k)await j.refetchOverviewTasksForCacheEntry({dispatch:i,projectName:n,updatedTaskIds:q,cacheEntry:I})}const z=(o.folder||[]).some(k=>k.type==="delete");g.length>0&&n&&!z&&i(w.foldersQueries.util.invalidateTags([{type:"folder",id:"LIST"}]))}catch{for(const y of d)y.undo();_.length&&M()}},invalidatesTags:(t,r,{operationsRequestModel:n,projectName:i})=>{var o;const u=[{type:"kanban",id:"project-"+i}],l=[],a=[];return(o=n.operations)==null||o.forEach(s=>{const{entityId:d}=s;d?(l.push({type:"progress",id:d}),a.push({type:"entityListItem",id:d})):l.push({type:"progress",id:"LIST"})}),[...u,...l,...a]}})})}),{useUpdateOverviewEntitiesMutation:re}=te;exports.createLinkDeletionPatch=x;exports.deleteLinksFromEntities=X;exports.patchDetailsPanelEntity=U;exports.patchOverviewEntities=Y;exports.patchOverviewFolders=P;exports.patchOverviewTasks=b;exports.useUpdateOverviewEntitiesMutation=re;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../base/client.cjs.js");require("../../generated/graphql.cjs.js");require("../../generated/graphqlLinks.cjs.js");require("../../generated/access.cjs.js");require("../../generated/actions.cjs.js");require("../../generated/activityFeed.cjs.js");require("../../generated/addons.cjs.js");require("../../generated/anatomy.cjs.js");require("../../generated/attributes.cjs.js");require("../../generated/authentication.cjs.js");require("../../generated/bundles.cjs.js");require("../../generated/configuration.cjs.js");require("../../generated/desktop.cjs.js");require("../../generated/entityLists.cjs.js");require("../../generated/events.cjs.js");require("../../generated/files.cjs.js");require("../../generated/folders.cjs.js");require("../../generated/inbox.cjs.js");require("../../generated/links.cjs.js");require("../../generated/market.cjs.js");require("../../generated/onboarding.cjs.js");const W=require("../../generated/operations.cjs.js");require("../../generated/products.cjs.js");require("../../generated/projectDashboard.cjs.js");require("../../generated/projects.cjs.js");require("../../generated/reviewables.cjs.js");require("../../generated/services.cjs.js");require("../../generated/system.cjs.js");require("../../generated/tasks.cjs.js");require("../../generated/teams.cjs.js");require("../../generated/thumbnails.cjs.js");require("../../generated/uRIs.cjs.js");require("../../generated/users.cjs.js");require("../../generated/versions.cjs.js");require("../../generated/workfiles.cjs.js");require("../../generated/ynputCloud.cjs.js");require("../../generated/grouping.cjs.js");require("../../generated/views.cjs.js");require("../actions/getActions.cjs.js");require("../activities/getActivities.cjs.js");require("../activities/updateActivities.cjs.js");require("../activities/updateReaction.cjs.js");require("../activities/getMentions.cjs.js");require("../activities/getCategories.cjs.js");require("../addons/getAddons.cjs.js");require("../addons/updateAddons.cjs.js");require("../attributes/getAttributes.cjs.js");require("../attributes/updateAttributes.cjs.js");require("../authentication/getAuthentication.cjs.js");require("../cloud/cloud.cjs.js");require("../config/getConfig.cjs.js");require("../config/updateConfig.cjs.js");require("../entities/getEntity.cjs.js");const E=require("../entities/getEntityPanel.cjs.js");require("../entities/updateEntity.cjs.js");const B=require("../entityLists/getLists.cjs.js");require("../entityLists/updateLists.cjs.js");require("../entityLists/getListsAttributes.cjs.js");require("../entityLists/updateListsAttributes.cjs.js");require("../entityLists/listFolders.cjs.js");const w=require("../folders/getFolders.cjs.js");require("../grouping/getGrouping.cjs.js");require("../links/updateLinks.cjs.js");require("../links/getLinks.cjs.js");require("../links/getEntityLinks.cjs.js");const T=require("./getOverview.cjs.js"),G=require("./patchVersions.cjs.js"),J=require("./patchProducts.cjs.js");require("../permissions/getPermissions.cjs.js");require("../products/createProduct.cjs.js");require("../project/getProject.cjs.js");require("../project/updateProject.cjs.js");require("../review/getReview.cjs.js");require("../review/updateReview.cjs.js");require("../share/share.cjs.js");require("../system/getSystem.cjs.js");require("../userDashboard/getUserDashboard.cjs.js");require("../users/getUsers.cjs.js");require("../users/updateUsers.cjs.js");require("../users/guests.cjs.js");require("../versions/updateVersions.cjs.js");require("../versions/getVersionsProducts.cjs.js");require("../views/getViews.cjs.js");require("../views/updateViews.cjs.js");require("../watchers/getWatchers.cjs.js");require("../uris/getUris.cjs.js");const N=require("./filterRefetchUtils.cjs.js"),j=require("./refetchFilteredEntities.cjs.js"),O=(e,t)=>{if(Object.keys(t).forEach(r=>{r==="attrib"||r==="links"||r==="deleteLinks"||(e[r]=t[r])}),t.attrib&&(e.attrib={...e.attrib,...t.attrib}),t.links){const r=e.links||[],n=t.links||[];e.links||(e.links=[]),e.links=[...r],n.forEach(i=>{const l=e.links.findIndex(u=>u.id===i.id);l!==-1?e.links[l]={...e.links[l],...i}:e.links.push(i)})}if(t.deleteLinks){const r=t.deleteLinks||[];e.links||(e.links=[]),r.forEach(n=>{e.links=e.links.filter(i=>i.id!==n)})}},S=e=>[{type:"overviewTask",id:"LIST"},...e.map(t=>({type:"overviewTask",id:t.entityId})),...e.filter(t=>{var r;return(r=t.data)==null?void 0:r.projectName}).map(t=>{var r;return{type:"overviewTask",id:(r=t.data)==null?void 0:r.projectName}})],K=e=>[...e.map(t=>({type:"folder",id:t.entityId})),...e.filter(t=>{var r;return(r=t.data)==null?void 0:r.projectName}).map(t=>{var r;return{type:"folder",id:(r=t.data)==null?void 0:r.projectName}})],x=(e,t,r)=>({entityId:e,entityType:t,type:"update",data:{deleteLinks:r}}),X=(e,t)=>e.map(r=>x(r.entityId,r.entityType,t)),Y=(e,{state:t,dispatch:r},n)=>{const i=e.reduce((l,u)=>(l[u.entityType]||(l[u.entityType]=[]),l[u.entityType].push(u),l),{});i.task&&b(i.task,{state:t,dispatch:r},n),i.folder&&P(i.folder,{state:t,dispatch:r},n)},b=(e,{state:t,dispatch:r},n)=>{const i=S(e),l=T.default.util.selectInvalidatedBy(t,i);for(const u of l)if(u.endpointName==="getTasksListInfinite"){const a=r(T.default.util.updateQueryData("getTasksListInfinite",u.originalArgs,o=>{for(const s of e)if(s.type==="create"&&s.data)o.pages[0].tasks.push(s.data);else for(const d of o.pages){const f=d.tasks.find(p=>p.id===s.entityId);f&&O(f,s.data)}}));n==null||n.push(a)}else{const a=r(T.default.util.updateQueryData(u.endpointName,u.originalArgs,o=>{var s;for(const d of e)if(d.type==="create"&&d.data&&((s=u.originalArgs.parentIds)!=null&&s.includes(d.data.folderId))){const f=p=>{p.push(d.data)};if(Array.isArray(o))f(o);else if(o.tasks&&Array.isArray(o.tasks)){const p=o.tasks;f(p)}}else{const f=p=>{const h=p.find(m=>m.id===d.entityId);h&&O(h,d.data)};if(Array.isArray(o))f(o);else if(o.tasks&&Array.isArray(o.tasks)){const p=o.tasks;f(p)}}}));n==null||n.push(a)}},Z=(e,{dispatch:t})=>{e.length&&t(T.default.util.invalidateTags(S(e)))},P=(e,{state:t,dispatch:r},n)=>{const i=w.foldersQueries.util.selectInvalidatedBy(t,K(e)).filter(l=>l.endpointName==="getFolderList");for(const l of i){const u=r(w.foldersQueries.util.updateQueryData(l.endpointName,l.originalArgs,a=>{const o=new Map;a.folders.forEach(s=>{o.set(s.id,s)});for(const s of e)if(s.type==="create"&&s.data)a.folders.push(s.data);else{const d=o.get(s.entityId);d&&O(d,s.data)}}));n==null||n.push(u)}},$=(e,t)=>{const r={name:e.name,attrib:e.attrib,status:e.status,tags:e.tags,label:e.label,updatedAt:e.updatedAt,createdAt:e.createdAt,hasReviewables:e.hasReviewables,thumbnailId:e.thumbnailId};switch(t){case"task":return{...r,task:{assignees:e.assignees,label:e.label,name:e.name,taskType:e.taskType}};case"folder":return{...r,folder:{id:e.id,name:e.name,label:e.label,folderType:e.folderType}};case"version":return{...r,version:{id:e.id,name:e.name}};case"representation":return{...r}}},U=(e=[],t)=>{const r=e.find(a=>a.entityId===t.id),n=r==null?void 0:r.data;if(!n||r.entityType==="product"||r.entityType==="workfile")return console.warn("No operation data found or entity type not supported");const i=$(n,r.entityType);if(r.entityType==="folder"&&n.name&&t.path){const a=t.path.split("/");a[a.length-1]=n.name,i.path=a.join("/")}function l(a){Object.entries(a).forEach(([o,s])=>{s===void 0?delete a[o]:s!==null&&typeof s=="object"&&l(s)})}l(i);const u={...t,...i,attrib:{...(t==null?void 0:t.attrib)||{},...i.attrib},folder:{...(t==null?void 0:t.folder)||{},...i.folder},task:{...(t==null?void 0:t.task)||{},...i.task},version:{...(t==null?void 0:t.version)||{},...i.version}};Object.assign(t,u)},ee=(e,{state:t,dispatch:r},n)=>{const i=e.map(u=>({type:"entityListItem",id:u.entityId})),l=B.default.util.selectInvalidatedBy(t,i);for(const u of l)if(u.endpointName==="getListItemsInfinite"){const a=r(B.default.util.updateQueryData("getListItemsInfinite",u.originalArgs,o=>{for(const s of e)if(s.type==="update"&&s.data)for(const d of o.pages){const f=d.items.find(p=>p.entityId===s.entityId);f&&O(f,s.data)}}));n==null||n.push(a)}},C=e=>e.reduce((t,r)=>(t[r.type].push(r),t),{create:[],update:[],delete:[]}),R=W.api.enhanceEndpoints({endpoints:{operations:{}}}),te=R.injectEndpoints({endpoints:e=>({updateOverviewEntities:e.mutation({async queryFn(t,{dispatch:r}){try{const n=await r(R.endpoints.operations.initiate(t));if(n.error)return{error:n.error};const i=n.data,l=new Set,u=new Set;for(const a of(i==null?void 0:i.operations)||[])a.success===!1&&a.detail&&(l.has(a.detail)||l.add(a.detail),u.has(a.errorCode)||u.add(a.errorCode));return l.size>0?{error:{status:"FETCH_ERROR",error:Array.from(l).join(", "),errorCodes:Array.from(u)}}:{data:i}}catch(n){return console.error(n),{error:{status:"FETCH_ERROR",error:n.message}}}},async onQueryStarted({operationsRequestModel:t,patchOperations:r=[],projectName:n},{dispatch:i,queryFulfilled:l,getState:u}){var L,A,F,D,Q;if(!((L=t.operations)!=null&&L.length))return;const{operations:a}=t,o=a.reduce((c,y)=>(c[y.entityType].push(y),c),{task:[],folder:[],product:[],version:[],representation:[],workfile:[]}),s=u(),d=[];if((A=o.task)!=null&&A.length){const{delete:c,update:y}=C(o.task),q=y.filter(g=>!r.some(v=>v.entityId===g.entityId));b(q,{state:s,dispatch:i},d),Z([...c],{dispatch:i})}if((F=o.folder)!=null&&F.length){const{delete:c,update:y}=C(o.folder),q=y.filter(g=>!r.some(v=>v.entityId===g.entityId));P(q,{state:s,dispatch:i},d),c.length&&i(w.foldersQueries.util.invalidateTags([{type:"folder",id:"LIST"}]))}const f=r.filter(c=>c.entityType==="task"),p=r.filter(c=>c.entityType==="folder");f.length&&b(f,{state:s,dispatch:i},d),p.length&&P(p,{state:s,dispatch:i},d),ee([...a,...r],{state:s,dispatch:i},d),(D=o.version)!=null&&D.length&&G.patchVersions(o.version,{state:s,dispatch:i},d),(Q=o.product)!=null&&Q.length&&J.patchProducts(o.product,{state:s,dispatch:i},d);const h=a.map(c=>({id:c.entityId,type:c.entityType})),m=h.map(c=>({type:"entities",id:c.id})),M=()=>i(E.detailsPanelQueries.util.invalidateTags(m)),_=E.detailsPanelQueries.util.selectInvalidatedBy(s,h),H=E.detailsPanelQueries.util.selectInvalidatedBy(s,m);for(const c of H){if(c.endpointName!=="getEntitiesDetailsPanel")continue;const y=i(E.detailsPanelQueries.util.updateQueryData(c.endpointName,c.originalArgs,q=>{for(const g of q)U(a,g)}));d.push(y)}try{await l;const c=o.task||[],y=o.folder||[];if(c.length===0&&y.length===0)return;const q=N.getUpdatedEntityIds(c),g=N.getUpdatedEntityIds(y),v=q.map(k=>({type:"overviewTask",id:k})),V=T.default.util.selectInvalidatedBy(s,v).filter(k=>k.endpointName==="getTasksListInfinite");if(q.length>0&&n){for(const I of V)await j.refetchTasksForCacheEntry({dispatch:i,projectName:n,updatedTaskIds:q,cacheEntry:I});const k=T.default.util.selectInvalidatedBy(s,v).filter(I=>I.endpointName==="getOverviewTasksByFolders");for(const I of k)await j.refetchOverviewTasksForCacheEntry({dispatch:i,projectName:n,updatedTaskIds:q,cacheEntry:I})}const z=(o.folder||[]).some(k=>k.type==="delete");g.length>0&&n&&!z&&i(w.foldersQueries.util.invalidateTags([{type:"folder",id:"LIST"}]))}catch{for(const y of d)y.undo();_.length&&M()}},invalidatesTags:(t,r,{operationsRequestModel:n,projectName:i})=>{var o;const l=[{type:"kanban",id:"project-"+i}],u=[],a=[];return(o=n.operations)==null||o.forEach(s=>{const{entityId:d}=s;d?(u.push({type:"progress",id:d}),a.push({type:"entityListItem",id:d})):u.push({type:"progress",id:"LIST"})}),[...l,...u,...a]}})})}),{useUpdateOverviewEntitiesMutation:re}=te;exports.createLinkDeletionPatch=x;exports.deleteLinksFromEntities=X;exports.patchDetailsPanelEntity=U;exports.patchOverviewEntities=Y;exports.patchOverviewFolders=P;exports.patchOverviewTasks=b;exports.useUpdateOverviewEntitiesMutation=re;
|
|
2
2
|
//# sourceMappingURL=updateOverview.cjs.js.map
|