@datalayer/core 0.0.2 → 0.0.4
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/README.md +124 -2
- package/lib/App.css +47 -0
- package/lib/App.js +14 -2
- package/lib/__tests__/index.test.js +7 -6
- package/lib/api/{RunApi.d.ts → DatalayerApi.d.ts} +4 -4
- package/lib/api/{RunApi.js → DatalayerApi.js} +6 -11
- package/lib/api/index.d.ts +3 -2
- package/lib/api/index.js +3 -7
- package/lib/api/{runtimes → jupyter}/exec/Python.js +0 -5
- package/lib/api/{runtimes → jupyter}/exec/Snippets.js +0 -5
- package/lib/api/{runtimes → jupyter}/exec/index.js +0 -5
- package/lib/api/jupyter/index.d.ts +2 -0
- package/lib/api/jupyter/index.js +6 -0
- package/lib/api/{runtimes → jupyter}/kernelsHandler.d.ts +1 -1
- package/lib/api/{runtimes → jupyter}/kernelsHandler.js +1 -6
- package/lib/api/runtimes/actions.d.ts +102 -0
- package/lib/api/runtimes/{runtimesApi.js → actions.js} +47 -53
- package/lib/api/runtimes/{runtimesApi.d.ts → apis.d.ts} +8 -105
- package/lib/api/runtimes/apis.js +5 -0
- package/lib/api/runtimes/index.d.ts +2 -4
- package/lib/api/runtimes/index.js +2 -9
- package/lib/api/runtimes/settings.js +3 -8
- package/lib/api/runtimes/snapshots.d.ts +1 -1
- package/lib/api/runtimes/snapshots.js +8 -13
- package/lib/api/runtimes/utils.js +1 -9
- package/lib/assets/react.svg +1 -0
- package/lib/collaboration/DatalayerCollaboration.d.ts +9 -0
- package/lib/collaboration/DatalayerCollaboration.js +28 -0
- package/lib/collaboration/DatalayerCollaborationProvider.d.ts +54 -0
- package/lib/collaboration/DatalayerCollaborationProvider.js +162 -0
- package/lib/collaboration/index.d.ts +2 -0
- package/lib/collaboration/index.js +6 -0
- package/lib/components/avatars/BoringAvatar.d.ts +2 -3
- package/lib/components/avatars/BoringAvatar.js +14 -9
- package/lib/components/avatars/BoringAvatar.stories.d.ts +27 -0
- package/lib/components/avatars/BoringAvatar.stories.js +23 -0
- package/lib/components/avatars/UserProfileAvatar.js +2 -14
- package/lib/components/avatars/index.js +0 -5
- package/lib/components/banners/NoAutomationBanner.js +4 -9
- package/lib/components/banners/index.js +0 -5
- package/lib/components/buttons/DownloadCSVButton.d.ts +1 -1
- package/lib/components/buttons/DownloadCSVButton.js +1 -6
- package/lib/components/buttons/DownloadJsonButton.d.ts +1 -1
- package/lib/components/buttons/DownloadJsonButton.js +0 -5
- package/lib/components/buttons/LongActionButton.js +0 -5
- package/lib/components/buttons/UploadButton.js +1 -6
- package/lib/components/buttons/index.js +0 -5
- package/lib/components/checkout/StripeCheckout.d.ts +1 -1
- package/lib/components/checkout/StripeCheckout.js +6 -11
- package/lib/components/checkout/index.js +0 -5
- package/lib/components/confetti/ConfettiSuccess.js +1 -6
- package/lib/components/confetti/index.js +0 -5
- package/lib/components/context/OrganizationSelect.js +5 -10
- package/lib/components/context/SpaceSelect.js +7 -12
- package/lib/components/context/index.js +0 -5
- package/lib/components/display/AvatarSkeleton.js +1 -6
- package/lib/components/display/CenteredSpinner.js +4 -9
- package/lib/components/display/CodePreview.js +4 -9
- package/lib/components/display/DatalayerBox.js +13 -19
- package/lib/components/display/HorizontalCenter.d.ts +1 -1
- package/lib/components/display/HorizontalCenter.js +1 -1
- package/lib/components/display/JupyterDialog.js +17 -20
- package/lib/components/display/NavLink.d.ts +4 -2
- package/lib/components/display/NavLink.js +6 -9
- package/lib/components/display/NotebookSkeleton.js +2 -7
- package/lib/components/display/Placeholder.js +1 -6
- package/lib/components/display/ToTopBranded.js +1 -6
- package/lib/components/display/VisuallyHidden.js +0 -5
- package/lib/components/display/index.js +0 -5
- package/lib/components/echarts/EChartsReact.d.ts +1 -1
- package/lib/components/echarts/EChartsReact.js +7 -7
- package/lib/components/echarts/index.js +0 -5
- package/lib/components/flashes/FlashClosable.js +11 -16
- package/lib/components/flashes/FlashDisclaimer.js +2 -8
- package/lib/components/flashes/FlashGuest.js +3 -9
- package/lib/components/flashes/FlashSurveys.js +3 -9
- package/lib/components/flashes/FlashUnauthorized.js +2 -7
- package/lib/components/flashes/index.js +0 -5
- package/lib/components/flashes/surveys/Survey2025_1.d.ts +1 -1
- package/lib/components/flashes/surveys/Survey2025_1.js +62 -90
- package/lib/components/flashes/surveys/index.js +0 -5
- package/lib/components/iam/ExternalTokenSilentLogin.js +6 -9
- package/lib/components/iam/index.js +0 -5
- package/lib/components/icons/ArtifactIcon.d.ts +2 -2
- package/lib/components/icons/ArtifactIcon.js +39 -44
- package/lib/components/icons/index.js +0 -5
- package/lib/components/index.js +1 -6
- package/lib/components/labels/VisibilityLabel.js +2 -10
- package/lib/components/labels/index.js +0 -5
- package/lib/components/landings/StepBlock.d.ts +1 -1
- package/lib/components/landings/StepBlock.js +1 -6
- package/lib/components/landings/index.js +0 -5
- package/lib/components/navbar/NavigationVisbilityObserver.js +2 -7
- package/lib/components/navbar/SubdomainNavBar.js +46 -29
- package/lib/components/navbar/SubdomainNavBar.module.css +737 -0
- package/lib/components/navbar/index.js +0 -5
- package/lib/components/nbgrader/NbGradesDetails.d.ts +1 -1
- package/lib/components/nbgrader/NbGradesDetails.js +5 -13
- package/lib/components/nbgrader/index.js +0 -5
- package/lib/components/notebooks/JupyterNotebook.js +5 -10
- package/lib/components/notebooks/JupyterNotebookToolbar.js +3 -8
- package/lib/components/notebooks/index.js +0 -5
- package/lib/components/primer/Helper.d.ts +1 -1
- package/lib/components/primer/Helper.js +5 -3
- package/lib/components/primer/Portals.d.ts +1 -1
- package/lib/components/primer/Portals.js +2 -7
- package/lib/components/primer/Styles.js +1 -6
- package/lib/components/primer/index.js +0 -5
- package/lib/components/progress/ConsumptionBar.js +2 -7
- package/lib/components/progress/CreditsIndicator.d.ts +1 -1
- package/lib/components/progress/CreditsIndicator.js +4 -13
- package/lib/components/progress/ProgressBar.js +0 -5
- package/lib/components/progress/ProgressRing.js +2 -2
- package/lib/components/progress/Timer.js +0 -5
- package/lib/components/progress/index.js +0 -5
- package/lib/components/runtimes/RuntimeCellVariables.js +9 -14
- package/lib/components/runtimes/RuntimeCellVariablesDialog.js +7 -12
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +1 -2
- package/lib/components/runtimes/RuntimeLauncherDialog.js +32 -40
- package/lib/components/runtimes/RuntimePickerBase.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerBase.js +42 -36
- package/lib/components/runtimes/RuntimePickerCell.js +9 -17
- package/lib/components/runtimes/RuntimePickerNotebook.d.ts +1 -2
- package/lib/components/runtimes/RuntimePickerNotebook.js +45 -50
- package/lib/components/runtimes/RuntimeReservationControl.js +10 -20
- package/lib/components/runtimes/RuntimeSimplePicker.d.ts +1 -1
- package/lib/components/runtimes/RuntimeSimplePicker.js +44 -52
- package/lib/components/runtimes/RuntimeUtils.d.ts +1 -1
- package/lib/components/runtimes/RuntimeUtils.js +22 -17
- package/lib/components/runtimes/RuntimeVariables.js +7 -12
- package/lib/components/runtimes/index.js +0 -5
- package/lib/components/screenshot/ScreenCapture.js +10 -19
- package/lib/components/screenshot/ScreenCaptureButton.d.ts +1 -1
- package/lib/components/screenshot/ScreenCaptureButton.js +14 -8
- package/lib/components/screenshot/index.js +0 -5
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +19 -22
- package/lib/components/snapshots/index.js +0 -5
- package/lib/components/snippets/SnippetDialog.js +5 -10
- package/lib/components/snippets/index.js +0 -5
- package/lib/components/storage/ContentsBrowser.js +75 -63
- package/lib/components/storage/ContentsItems.js +10 -13
- package/lib/components/storage/index.js +0 -5
- package/lib/components/students/StudentItemStatus.d.ts +1 -1
- package/lib/components/students/StudentItemStatus.js +38 -21
- package/lib/components/students/index.js +0 -5
- package/lib/components/subnav/SubNav.d.ts +3 -3
- package/lib/components/subnav/SubNav.js +34 -24
- package/lib/components/subnav/SubNav.module.css +717 -0
- package/lib/components/subnav/index.js +0 -5
- package/lib/components/tables/DataTable.js +1 -9
- package/lib/components/tables/index.js +0 -5
- package/lib/components/text-reveal/TextRevealAnimation.js +7 -8
- package/lib/components/text-reveal/TextRevealAnimation.module.css +45 -0
- package/lib/components/text-reveal/index.js +0 -5
- package/lib/components/text-reveal/useTextRevealAnimationLines.js +0 -5
- package/lib/components/tokens/SpaceVariantToken.d.ts +1 -1
- package/lib/components/tokens/SpaceVariantToken.js +5 -10
- package/lib/components/tokens/index.js +0 -5
- package/lib/components/toolbars/AssignmentEditorToolbar.js +1 -8
- package/lib/components/toolbars/DocumentEditorToolbar.js +0 -5
- package/lib/components/toolbars/NotebookEditorToolbar.d.ts +1 -1
- package/lib/components/toolbars/NotebookEditorToolbar.js +0 -5
- package/lib/components/toolbars/index.js +0 -5
- package/lib/components/users/PeerIndicator.d.ts +1 -1
- package/lib/components/users/PeerIndicator.js +5 -10
- package/lib/components/users/index.js +0 -5
- package/lib/config/Configuration.d.ts +48 -0
- package/lib/config/Configuration.js +42 -5
- package/lib/config/index.js +0 -5
- package/lib/config/integrations/Loom.js +3 -8
- package/lib/config/integrations/index.js +0 -5
- package/lib/examples/CellExample.d.ts +6 -0
- package/lib/examples/CellExample.js +55 -0
- package/lib/examples/DatalayerNotebookExample.d.ts +16 -0
- package/lib/examples/DatalayerNotebookExample.js +75 -0
- package/lib/examples/NativeNavigationExample.d.ts +8 -0
- package/lib/examples/NativeNavigationExample.js +97 -0
- package/lib/examples/NotebookExample.d.ts +6 -0
- package/lib/examples/NotebookExample.js +24 -0
- package/lib/examples/NotebookMutationsKernel.d.ts +2 -0
- package/lib/examples/NotebookMutationsKernel.js +115 -0
- package/lib/examples/NotebookMutationsServiceManager.d.ts +2 -0
- package/lib/examples/NotebookMutationsServiceManager.js +107 -0
- package/lib/examples/ReactRouterExample.d.ts +6 -0
- package/lib/examples/ReactRouterExample.js +175 -0
- package/lib/examples/example-selector.d.ts +22 -0
- package/lib/examples/example-selector.js +45 -0
- package/lib/examples/index.d.ts +2 -0
- package/lib/examples/index.js +6 -0
- package/lib/examples/main.js +153 -0
- package/lib/examples/notebooks/IPyWidgetsExample.ipynb.json +101 -0
- package/lib/examples/notebooks/IPyWidgetsExampleWithState.ipynb.json +112 -0
- package/lib/examples/notebooks/Lite.ipynb.json +128 -0
- package/lib/examples/notebooks/Matplotlib.ipynb.json +137 -0
- package/lib/examples/notebooks/NotebookExample1.ipynb.json +126 -0
- package/lib/examples/notebooks/NotebookExample2.ipynb.json +48 -0
- package/lib/examples/notebooks/NotebookOutputs.ipynb.json +49 -0
- package/lib/examples/notebooks/NotebookToCExample.ipynb.json +102 -0
- package/lib/examples/notebooks/OutputIPyWidgetsExample.d.ts +145 -0
- package/lib/examples/notebooks/OutputIPyWidgetsExample.js +153 -0
- package/lib/examples/notebooks/PyGWalker.ipynb.json +55 -0
- package/lib/hooks/assets/OutputshotPlaceholders.d.ts +10 -10
- package/lib/hooks/assets/OutputshotPlaceholders.js +9 -14
- package/lib/hooks/assets/index.js +0 -5
- package/lib/hooks/index.d.ts +29 -28
- package/lib/hooks/index.js +29 -33
- package/lib/hooks/layouts/LayoutBackdrop.js +3 -11
- package/lib/hooks/layouts/LayoutScreenshot.css +58 -0
- package/lib/hooks/layouts/LayoutScreenshot.d.ts +1 -0
- package/lib/hooks/layouts/LayoutScreenshot.js +7 -11
- package/lib/hooks/layouts/index.js +0 -5
- package/lib/hooks/useAIAgents.d.ts +1 -1
- package/lib/hooks/useAIAgents.js +13 -18
- package/lib/hooks/useAuthorization.js +4 -10
- package/lib/hooks/useBackdrop.js +7 -12
- package/lib/hooks/useBackdropJupyterLab.d.ts +1 -1
- package/lib/hooks/useBackdropJupyterLab.js +4 -9
- package/lib/hooks/useCache.d.ts +8 -4
- package/lib/hooks/useCache.js +410 -361
- package/lib/hooks/useCellOutputshot.js +3 -11
- package/lib/hooks/useContainsFocus.js +2 -6
- package/lib/hooks/useDatalayer.d.ts +21 -0
- package/lib/hooks/{useRun.js → useDatalayer.js} +16 -18
- package/lib/hooks/useError.d.ts +1 -1
- package/lib/hooks/useError.js +2 -7
- package/lib/hooks/useExternalScript.js +4 -9
- package/lib/hooks/useFocusTrap.d.ts +1 -1
- package/lib/hooks/useFocusTrap.js +3 -7
- package/lib/hooks/useIAM.js +6 -12
- package/lib/hooks/useId.js +6 -11
- package/lib/hooks/useIsomorphicLayoutEffect.js +0 -5
- package/lib/hooks/useJupyterLabTheme.js +3 -6
- package/lib/hooks/useKeyboardEscape.js +0 -5
- package/lib/hooks/useLocation.d.ts +22 -0
- package/lib/hooks/useLocation.js +149 -0
- package/lib/hooks/useLocationHandles.d.ts +2 -2
- package/lib/hooks/useLocationHandles.js +6 -9
- package/lib/hooks/useNavigate.d.ts +5 -1
- package/lib/hooks/useNavigate.js +62 -12
- package/lib/hooks/useNotebookAIAgent.js +3 -6
- package/lib/hooks/useOnClickOutside.js +0 -5
- package/lib/hooks/useParams.d.ts +5 -0
- package/lib/hooks/useParams.js +152 -0
- package/lib/hooks/useRef.js +0 -5
- package/lib/hooks/useRuntimes.js +2 -7
- package/lib/hooks/useScreenshot.js +5 -10
- package/lib/hooks/useToast.js +21 -21
- package/lib/hooks/useUpload.js +9 -14
- package/lib/hooks/useUser.js +1 -1
- package/lib/hooks/useVisibilityObserver.js +0 -5
- package/lib/hooks/useWindowSize.js +0 -6
- package/lib/i18n/Labels.js +0 -5
- package/lib/i18n/index.js +0 -5
- package/lib/index.css +73 -0
- package/lib/index.d.ts +6 -3
- package/lib/index.js +7 -3
- package/lib/main.js +1 -2
- package/lib/mocks/components/FlashMock.js +4 -9
- package/lib/mocks/components/index.js +0 -5
- package/lib/mocks/hooks/index.d.ts +1 -1
- package/lib/mocks/hooks/index.js +1 -6
- package/lib/mocks/hooks/rests/index.js +0 -5
- package/lib/mocks/hooks/rests/rests.js +15 -23
- package/lib/mocks/hooks/useDatalayerMock.d.ts +6 -0
- package/lib/mocks/hooks/{useRunMock.js → useDatalayerMock.js} +9 -14
- package/lib/mocks/index.js +0 -5
- package/lib/mocks/jupyter/index.js +1 -6
- package/lib/mocks/models/CodeBlockMock.js +1 -6
- package/lib/mocks/models/CodelineMock.js +1 -6
- package/lib/mocks/models/CourseMock.d.ts +1 -1
- package/lib/mocks/models/CourseMock.js +10 -15
- package/lib/mocks/models/InviteMock.d.ts +1 -1
- package/lib/mocks/models/InviteMock.js +21 -11
- package/lib/mocks/models/JupyterLabUserMock.js +2 -2
- package/lib/mocks/models/OrganisationMock.d.ts +1 -1
- package/lib/mocks/models/OrganisationMock.js +11 -7
- package/lib/mocks/models/SchoolMock.d.ts +1 -1
- package/lib/mocks/models/SchoolMock.js +6 -6
- package/lib/mocks/models/SpaceMock.d.ts +1 -1
- package/lib/mocks/models/SpaceMock.js +9 -14
- package/lib/mocks/models/TeamMock.d.ts +1 -1
- package/lib/mocks/models/TeamMock.js +6 -6
- package/lib/mocks/models/UserMock.d.ts +1 -1
- package/lib/mocks/models/UserMock.js +4 -11
- package/lib/mocks/models/index.js +0 -5
- package/lib/mocks/views/ActionMenuMock.js +1 -6
- package/lib/mocks/views/ChartMock.js +3 -8
- package/lib/mocks/views/ChartMockOptions.js +24 -29
- package/lib/mocks/views/DashboardMock.js +74 -79
- package/lib/mocks/views/FormMock.js +1 -6
- package/lib/mocks/views/TableMock.js +1 -6
- package/lib/mocks/views/WipMock.js +0 -5
- package/lib/mocks/views/index.js +0 -5
- package/lib/models/Account.d.ts +2 -2
- package/lib/models/Assignment.d.ts +2 -2
- package/lib/models/Cell.d.ts +1 -1
- package/lib/models/CodeBlock.d.ts +1 -1
- package/lib/models/CodefeedBlocks.d.ts +2 -2
- package/lib/models/Contact.d.ts +1 -1
- package/lib/models/Contact.js +14 -19
- package/lib/models/ContactEvent.js +0 -5
- package/lib/models/ContactIAMProvider.js +2 -2
- package/lib/models/Course.d.ts +7 -7
- package/lib/models/Credits.js +0 -5
- package/lib/models/Dataset.d.ts +2 -2
- package/lib/models/Datasource.js +0 -5
- package/lib/models/Dean.d.ts +1 -1
- package/lib/models/Document.d.ts +1 -1
- package/lib/models/Environment.d.ts +2 -2
- package/lib/models/Errors.js +0 -5
- package/lib/models/Exercise.d.ts +1 -1
- package/lib/models/GrowthKPI.js +0 -5
- package/lib/models/IAMProviderLinked.js +1 -1
- package/lib/models/IAMProviderUsers.js +0 -5
- package/lib/models/IAMToken.js +0 -5
- package/lib/models/Inbound.js +0 -5
- package/lib/models/Instructor.d.ts +1 -1
- package/lib/models/Invite.d.ts +2 -2
- package/lib/models/Invite.js +1 -1
- package/lib/models/Item.d.ts +5 -5
- package/lib/models/LandingRoles.js +18 -23
- package/lib/models/Lesson.d.ts +1 -1
- package/lib/models/Member.d.ts +1 -1
- package/lib/models/Notebook.d.ts +1 -1
- package/lib/models/Organization.d.ts +4 -4
- package/lib/models/Organization.js +2 -7
- package/lib/models/OrganizationMember.d.ts +2 -2
- package/lib/models/Outbound.js +7 -12
- package/lib/models/Page.js +4 -2
- package/lib/models/PageTag.d.ts +2 -2
- package/lib/models/PageTag.js +56 -9
- package/lib/models/Profile.d.ts +1 -1
- package/lib/models/RolesOrganization.d.ts +1 -1
- package/lib/models/RolesOrganization.js +4 -17
- package/lib/models/RolesPlatform.d.ts +1 -1
- package/lib/models/RolesPlatform.js +12 -39
- package/lib/models/RolesTeam.d.ts +1 -1
- package/lib/models/RolesTeam.js +3 -15
- package/lib/models/Runtime.d.ts +59 -1
- package/lib/models/Runtime.js +11 -9
- package/lib/models/RuntimeSnapshot.js +1 -1
- package/lib/models/School.d.ts +4 -4
- package/lib/models/Secret.js +0 -5
- package/lib/models/Space.d.ts +5 -5
- package/lib/models/Space.js +3 -3
- package/lib/models/SpaceItem.d.ts +8 -8
- package/lib/models/SpaceMember.d.ts +2 -2
- package/lib/models/Student.d.ts +2 -2
- package/lib/models/StudentItem.d.ts +3 -3
- package/lib/models/Survey.js +0 -5
- package/lib/models/Team.d.ts +3 -3
- package/lib/models/Team.js +2 -7
- package/lib/models/TeamMember.d.ts +2 -2
- package/lib/models/URN.js +1 -6
- package/lib/models/User.d.ts +2 -2
- package/lib/models/User.js +7 -10
- package/lib/models/UserEvent.js +0 -5
- package/lib/models/UserOnboarding.d.ts +1 -1
- package/lib/models/UserOnboarding.js +7 -12
- package/lib/models/UserSettings.js +2 -7
- package/lib/models/index.d.ts +2 -2
- package/lib/models/index.js +2 -7
- package/lib/navigation/adapters/native.d.ts +11 -0
- package/lib/navigation/adapters/native.js +48 -0
- package/lib/navigation/adapters/nextjs.d.ts +9 -0
- package/lib/navigation/adapters/nextjs.js +35 -0
- package/lib/navigation/adapters/react-router.d.ts +4 -0
- package/lib/navigation/adapters/react-router.js +12 -0
- package/lib/navigation/components.d.ts +20 -0
- package/lib/navigation/components.js +36 -0
- package/lib/navigation/index.d.ts +4 -0
- package/lib/navigation/index.js +12 -0
- package/lib/routes/Routes.js +0 -5
- package/lib/routes/index.d.ts +1 -1
- package/lib/routes/index.js +1 -6
- package/lib/services/DatalayerServiceManager.d.ts +22 -0
- package/lib/services/DatalayerServiceManager.js +79 -0
- package/lib/services/index.d.ts +4 -0
- package/lib/services/index.js +7 -0
- package/lib/services/reconnectToRuntime.d.ts +32 -0
- package/lib/services/reconnectToRuntime.js +59 -0
- package/lib/state/State.d.ts +1 -1
- package/lib/state/State.js +1 -6
- package/lib/state/index.d.ts +1 -1
- package/lib/state/index.js +1 -6
- package/lib/state/storage/IAMStorage.js +14 -7
- package/lib/state/storage/index.d.ts +1 -1
- package/lib/state/storage/index.js +1 -6
- package/lib/state/substates/AIAgentState.js +4 -7
- package/lib/state/substates/CellState.js +6 -10
- package/lib/state/substates/CoreState.d.ts +1 -1
- package/lib/state/substates/CoreState.js +23 -20
- package/lib/state/substates/DatasourceState.js +1 -6
- package/lib/state/substates/DocumentState.js +0 -5
- package/lib/state/substates/GradeState.js +0 -5
- package/lib/state/substates/IAMState.d.ts +5 -1
- package/lib/state/substates/IAMState.js +88 -72
- package/lib/state/substates/JupyterLabState.js +1 -6
- package/lib/state/substates/LayoutState.d.ts +2 -2
- package/lib/state/substates/LayoutState.js +41 -28
- package/lib/state/substates/NbformatState.js +0 -5
- package/lib/state/substates/OrganizationState.js +1 -6
- package/lib/state/substates/RuntimesState.d.ts +2 -2
- package/lib/state/substates/RuntimesState.js +6 -10
- package/lib/state/substates/SpaceState.js +1 -6
- package/lib/state/substates/SurveysState.js +7 -12
- package/lib/state/substates/TeamState.js +1 -6
- package/lib/state/substates/index.js +0 -5
- package/lib/stories/assets/accessibility.png +0 -0
- package/lib/stories/assets/accessibility.svg +1 -0
- package/lib/stories/assets/addon-library.png +0 -0
- package/lib/stories/assets/assets.png +0 -0
- package/lib/stories/assets/context.png +0 -0
- package/lib/stories/assets/discord.svg +1 -0
- package/lib/stories/assets/docs.png +0 -0
- package/lib/stories/assets/figma-plugin.png +0 -0
- package/lib/stories/assets/github.svg +1 -0
- package/lib/stories/assets/share.png +0 -0
- package/lib/stories/assets/styling.png +0 -0
- package/lib/stories/assets/testing.png +0 -0
- package/lib/stories/assets/theming.png +0 -0
- package/lib/stories/assets/tutorials.svg +1 -0
- package/lib/stories/assets/youtube.svg +1 -0
- package/lib/stories/button.css +35 -0
- package/lib/stories/header.css +37 -0
- package/lib/stories/page.css +73 -0
- package/lib/test-setup.js +73 -1
- package/lib/theme/DatalayerTheme.js +1 -6
- package/lib/theme/DatalayerThemeProvider.js +17 -19
- package/lib/theme/Palette.js +1 -6
- package/lib/theme/index.js +0 -5
- package/lib/utils/Array.js +0 -5
- package/lib/utils/Avatar.js +2 -7
- package/lib/utils/Browser.js +6 -11
- package/lib/utils/Cells.d.ts +1 -1
- package/lib/utils/Cookie.js +1 -6
- package/lib/utils/Date.js +5 -10
- package/lib/utils/Download.js +5 -8
- package/lib/utils/DownloadFile.js +4 -7
- package/lib/utils/Env.js +2 -6
- package/lib/utils/File.js +0 -5
- package/lib/utils/Ids.js +0 -5
- package/lib/utils/Jupyter.js +0 -5
- package/lib/utils/Lazy.d.ts +1 -1
- package/lib/utils/Lazy.js +2 -8
- package/lib/utils/Name.js +10 -13
- package/lib/utils/Notebook.d.ts +1 -1
- package/lib/utils/Notebook.js +3 -3
- package/lib/utils/Number.js +13 -14
- package/lib/utils/Plots.d.ts +1 -1
- package/lib/utils/Plots.js +5 -5
- package/lib/utils/Random.js +0 -5
- package/lib/utils/Screenshot.js +1 -6
- package/lib/utils/Scroll.js +3 -7
- package/lib/utils/Sleep.js +1 -6
- package/lib/utils/Snapshot.js +2 -7
- package/lib/utils/String.js +2 -7
- package/lib/utils/Uri.js +2 -7
- package/lib/utils/Validator.js +0 -5
- package/lib/utils/WithSuspense.js +3 -11
- package/lib/utils/index.js +0 -5
- package/package.json +96 -30
- package/style/animation/Animation.module.css +174 -0
- package/style/base.css +64 -0
- package/style/index.css +6 -0
- package/lib/__tests__/App.test.js +0 -17
- package/lib/api/runtimes/models.d.ts +0 -59
- package/lib/api/runtimes/models.js +0 -11
- package/lib/hooks/useRun.d.ts +0 -21
- package/lib/mocks/hooks/useRunMock.d.ts +0 -6
- /package/lib/api/{runtimes → jupyter}/exec/Python.d.ts +0 -0
- /package/lib/api/{runtimes → jupyter}/exec/Snippets.d.ts +0 -0
- /package/lib/api/{runtimes → jupyter}/exec/index.d.ts +0 -0
- /package/lib/{__tests__/App.test.d.ts → examples/main.d.ts} +0 -0
package/lib/hooks/useCache.js
CHANGED
|
@@ -2,19 +2,15 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
/*
|
|
6
|
-
* Copyright (c) 2021-2024 Datalayer, Inc.
|
|
7
|
-
*
|
|
8
|
-
* Datalayer License
|
|
9
|
-
*/
|
|
10
5
|
import { URLExt } from '@jupyterlab/coreutils';
|
|
11
|
-
import { BOOTSTRAP_USER_ONBOARDING, LinkedInUser, asContact, asDatasource, asInbound, asInvite, asOrganization, asOutbound, asPage, asSecret, asSpace, asSurvey, asTeam, asToken, asUsage, asUser, } from
|
|
6
|
+
import { BOOTSTRAP_USER_ONBOARDING, LinkedInUser, asContact, asDatasource, asInbound, asInvite, asOrganization, asOutbound, asPage, asSecret, asSpace, asSurvey, asTeam, asToken, asUsage, asUser, } from '../models';
|
|
12
7
|
import { useCoreStore, useIAMStore } from '../state';
|
|
13
|
-
import { asDisplayName, namesAsInitials, asArray } from
|
|
8
|
+
import { asDisplayName, namesAsInitials, asArray } from '../utils';
|
|
14
9
|
import { IAMProvidersSpecs } from '../models';
|
|
15
10
|
import { newUserMock } from './../mocks';
|
|
16
|
-
import {
|
|
17
|
-
import { useAuthorization } from
|
|
11
|
+
import { useDatalayer } from './useDatalayer';
|
|
12
|
+
import { useAuthorization } from './useAuthorization';
|
|
13
|
+
import { useUploadForm } from './useUpload';
|
|
18
14
|
import { OUTPUTSHOT_PLACEHOLDER_DEFAULT_SVG } from './assets';
|
|
19
15
|
const CONTACTS_BY_HANDLE = new Map();
|
|
20
16
|
const CONTACTS_BY_ID = new Map();
|
|
@@ -69,10 +65,13 @@ const DEFAULT_SEARCH_OPTS = {
|
|
|
69
65
|
* instead of redirecting to the login page).
|
|
70
66
|
*/
|
|
71
67
|
export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
72
|
-
const
|
|
68
|
+
const coreStore = useCoreStore();
|
|
69
|
+
const { configuration } = coreStore;
|
|
73
70
|
const { user } = useIAMStore();
|
|
74
|
-
const {
|
|
71
|
+
const { requestDatalayer } = useDatalayer({ loginRoute });
|
|
75
72
|
const { checkIsOrganizationMember } = useAuthorization();
|
|
73
|
+
// Hook for notebook upload/creation
|
|
74
|
+
const { isLoading: notebookUploadLoading, uploadAndSubmit: uploadNotebook, progress: notebookUploadProgress, reset: resetNotebookUpload, } = useUploadForm(`${coreStore.configuration.spacerRunUrl}/api/spacer/v1/notebooks`);
|
|
76
75
|
// Caches -------------------------------------------------------------------
|
|
77
76
|
const clearAllCaches = () => {
|
|
78
77
|
CONTACTS_BY_HANDLE.clear();
|
|
@@ -128,25 +127,25 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
128
127
|
};
|
|
129
128
|
// Authentication ------------------------------------------------------------------
|
|
130
129
|
const login = (handle, password) => {
|
|
131
|
-
return
|
|
130
|
+
return requestDatalayer({
|
|
132
131
|
url: `${configuration.iamRunUrl}/api/iam/v1/login`,
|
|
133
132
|
method: 'POST',
|
|
134
133
|
body: {
|
|
135
134
|
handle,
|
|
136
135
|
password,
|
|
137
|
-
}
|
|
136
|
+
},
|
|
138
137
|
});
|
|
139
138
|
};
|
|
140
139
|
const logout = () => {
|
|
141
140
|
clearAllCaches();
|
|
142
|
-
return
|
|
141
|
+
return requestDatalayer({
|
|
143
142
|
url: `${configuration.iamRunUrl}/api/iam/v1/logout`,
|
|
144
143
|
method: 'GET',
|
|
145
144
|
});
|
|
146
145
|
};
|
|
147
146
|
// Join ------------------------------------------------------------------
|
|
148
147
|
const requestJoin = (handle, email, firstName, lastName, password, passwordConfirm) => {
|
|
149
|
-
return
|
|
148
|
+
return requestDatalayer({
|
|
150
149
|
url: `${configuration.iamRunUrl}/api/iam/v1/join/request`,
|
|
151
150
|
method: 'POST',
|
|
152
151
|
body: {
|
|
@@ -156,11 +155,11 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
156
155
|
lastName,
|
|
157
156
|
password,
|
|
158
157
|
passwordConfirm,
|
|
159
|
-
}
|
|
158
|
+
},
|
|
160
159
|
});
|
|
161
160
|
};
|
|
162
161
|
const requestJoinToken = (handle, email, firstName, lastName, password, passwordConfirm) => {
|
|
163
|
-
return
|
|
162
|
+
return requestDatalayer({
|
|
164
163
|
url: `${configuration.iamRunUrl}/api/iam/v1/join/request/token`,
|
|
165
164
|
method: 'POST',
|
|
166
165
|
body: {
|
|
@@ -170,11 +169,11 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
170
169
|
lastName,
|
|
171
170
|
password,
|
|
172
171
|
passwordConfirm,
|
|
173
|
-
}
|
|
172
|
+
},
|
|
174
173
|
});
|
|
175
174
|
};
|
|
176
175
|
const joinWithInvite = (formValues, token) => {
|
|
177
|
-
return
|
|
176
|
+
return requestDatalayer({
|
|
178
177
|
url: `${configuration.iamRunUrl}/api/iam/v1/join/invites/token`,
|
|
179
178
|
method: 'POST',
|
|
180
179
|
body: {
|
|
@@ -184,49 +183,50 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
184
183
|
});
|
|
185
184
|
};
|
|
186
185
|
const confirmJoinWithToken = (userHandle, token) => {
|
|
187
|
-
return
|
|
186
|
+
return requestDatalayer({
|
|
188
187
|
url: `${configuration.iamRunUrl}/api/iam/v1/join/users/${userHandle}/tokens/${token}`,
|
|
189
188
|
method: 'GET',
|
|
190
189
|
});
|
|
191
190
|
};
|
|
192
191
|
// Password ------------------------------------------------------------------
|
|
193
192
|
const changePassword = (handle, password, passwordConfirm) => {
|
|
194
|
-
return
|
|
193
|
+
return requestDatalayer({
|
|
195
194
|
url: `${configuration.iamRunUrl}/api/iam/v1/password`,
|
|
196
195
|
method: 'PUT',
|
|
197
196
|
body: {
|
|
198
197
|
handle,
|
|
199
198
|
password,
|
|
200
199
|
passwordConfirm,
|
|
201
|
-
}
|
|
200
|
+
},
|
|
202
201
|
});
|
|
203
202
|
};
|
|
204
203
|
const createTokenForPasswordChange = (handle, password, passwordConfirm) => {
|
|
205
|
-
return
|
|
204
|
+
return requestDatalayer({
|
|
206
205
|
url: `${configuration.iamRunUrl}/api/iam/v1/password/token`,
|
|
207
206
|
method: 'POST',
|
|
208
207
|
body: {
|
|
209
208
|
handle,
|
|
210
209
|
password,
|
|
211
210
|
passwordConfirm,
|
|
212
|
-
}
|
|
211
|
+
},
|
|
213
212
|
});
|
|
214
213
|
};
|
|
215
214
|
const confirmPassworkWithToken = (userHandle, token) => {
|
|
216
|
-
return
|
|
215
|
+
return requestDatalayer({
|
|
217
216
|
url: `${configuration.iamRunUrl}/api/iam/v1/password/confirm/users/${userHandle}/tokens/${token}`,
|
|
218
217
|
method: 'PUT',
|
|
219
218
|
});
|
|
220
219
|
};
|
|
221
220
|
// OAuth2 -------------------------------------------------------------------
|
|
222
221
|
const getOAuth2AuthorizationURL = async (queryArgs) => {
|
|
223
|
-
return
|
|
224
|
-
url: URLExt.join(configuration.iamRunUrl, 'api/iam/v1/oauth2/authz/url') +
|
|
222
|
+
return requestDatalayer({
|
|
223
|
+
url: URLExt.join(configuration.iamRunUrl, 'api/iam/v1/oauth2/authz/url') +
|
|
224
|
+
URLExt.objectToQueryString(queryArgs),
|
|
225
225
|
notifyOnError: false,
|
|
226
226
|
});
|
|
227
227
|
};
|
|
228
228
|
const getOAuth2AuthorizationLinkURL = async (queryArgs) => {
|
|
229
|
-
return
|
|
229
|
+
return requestDatalayer({
|
|
230
230
|
url: URLExt.join(configuration.iamRunUrl, 'api/iam/v1/oauth2/authz/url/link') + URLExt.objectToQueryString(queryArgs),
|
|
231
231
|
});
|
|
232
232
|
};
|
|
@@ -235,8 +235,8 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
235
235
|
return fetch(IAMProvidersSpecs.GitHub.userInfoURL, {
|
|
236
236
|
method: 'GET',
|
|
237
237
|
headers: {
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
Accept: 'application/vnd.github+json',
|
|
239
|
+
Authorization: `Bearer ${accessToken}`,
|
|
240
240
|
'X-GitHub-Api-Version': '2022-11-28',
|
|
241
241
|
},
|
|
242
242
|
}).then(resp => resp.json());
|
|
@@ -251,53 +251,50 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
251
251
|
};
|
|
252
252
|
const postLinkedinShare = async (linkedinUser, postText, accessToken) => {
|
|
253
253
|
const POST_SHARE_REQUEST = {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
254
|
+
author: linkedinUser.getUrn(),
|
|
255
|
+
lifecycleState: 'PUBLISHED',
|
|
256
|
+
specificContent: {
|
|
257
|
+
'com.linkedin.ugc.ShareContent': {
|
|
258
|
+
shareCommentary: {
|
|
259
|
+
text: postText,
|
|
260
260
|
},
|
|
261
|
-
|
|
262
|
-
}
|
|
261
|
+
shareMediaCategory: 'NONE',
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
visibility: {
|
|
265
|
+
'com.linkedin.ugc.MemberNetworkVisibility': 'PUBLIC',
|
|
263
266
|
},
|
|
264
|
-
"visibility": {
|
|
265
|
-
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
|
|
266
|
-
}
|
|
267
267
|
};
|
|
268
268
|
return proxyPOST(IAMProvidersSpecs.LinkedIn.postShareURL, POST_SHARE_REQUEST, accessToken);
|
|
269
269
|
};
|
|
270
270
|
const postLinkedinShareWithUpload = async (linkedinUser, postText, uploadObject, accessToken) => {
|
|
271
271
|
const REGISTER_UPLOAD_REQUEST = {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
"owner": linkedinUser.getUrn(),
|
|
277
|
-
"serviceRelationships": [
|
|
272
|
+
registerUploadRequest: {
|
|
273
|
+
recipes: ['urn:li:digitalmediaRecipe:feedshare-image'],
|
|
274
|
+
owner: linkedinUser.getUrn(),
|
|
275
|
+
serviceRelationships: [
|
|
278
276
|
{
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
]
|
|
283
|
-
}
|
|
277
|
+
relationshipType: 'OWNER',
|
|
278
|
+
identifier: 'urn:li:userGeneratedContent',
|
|
279
|
+
},
|
|
280
|
+
],
|
|
281
|
+
},
|
|
284
282
|
};
|
|
285
|
-
return proxyPOST(IAMProvidersSpecs.LinkedIn.registerUploadURL, REGISTER_UPLOAD_REQUEST, accessToken)
|
|
286
|
-
.then(registerUploadReponse => {
|
|
283
|
+
return proxyPOST(IAMProvidersSpecs.LinkedIn.registerUploadURL, REGISTER_UPLOAD_REQUEST, accessToken).then(registerUploadReponse => {
|
|
287
284
|
/*
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
285
|
+
{
|
|
286
|
+
"value": {
|
|
287
|
+
"uploadMechanism": {
|
|
288
|
+
"com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest": {
|
|
289
|
+
"headers": {},
|
|
290
|
+
"uploadUrl": "https://api.linkedin.com/mediaUpload/C5522AQGTYER3k3ByHQ/feedshare-uploadedImage/0?ca=vector_feedshare&cn=uploads&m=AQJbrN86Zm265gAAAWemyz2pxPSgONtBiZdchrgG872QltnfYjnMdb2j3A&app=1953784&sync=0&v=beta&ut=2H-IhpbfXrRow1"
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
"mediaArtifact": "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C5522AQGTYER3k3ByHQ,urn:li:digitalmediaMediaArtifactClass:feedshare-uploadedImage)",
|
|
294
|
+
"asset": "urn:li:digitalmediaAsset:C5522AQGTYER3k3ByHQ"
|
|
295
|
+
}
|
|
298
296
|
}
|
|
299
|
-
|
|
300
|
-
*/
|
|
297
|
+
*/
|
|
301
298
|
const asset = registerUploadReponse.response.value.asset;
|
|
302
299
|
const uploadURL = registerUploadReponse.response.value.uploadMechanism['com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest'].uploadUrl;
|
|
303
300
|
const UPLOAD_OBJECT_REQUEST = {
|
|
@@ -305,34 +302,33 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
305
302
|
content: uploadObject,
|
|
306
303
|
userURN: linkedinUser.getUrn(),
|
|
307
304
|
};
|
|
308
|
-
return proxyPUT(uploadURL, UPLOAD_OBJECT_REQUEST, accessToken)
|
|
309
|
-
.then(resp => {
|
|
305
|
+
return proxyPUT(uploadURL, UPLOAD_OBJECT_REQUEST, accessToken).then(resp => {
|
|
310
306
|
const share = {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
307
|
+
author: linkedinUser.getUrn(),
|
|
308
|
+
lifecycleState: 'PUBLISHED',
|
|
309
|
+
specificContent: {
|
|
310
|
+
'com.linkedin.ugc.ShareContent': {
|
|
311
|
+
shareCommentary: {
|
|
312
|
+
text: postText,
|
|
317
313
|
},
|
|
318
|
-
|
|
319
|
-
|
|
314
|
+
shareMediaCategory: 'IMAGE',
|
|
315
|
+
media: [
|
|
320
316
|
{
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
317
|
+
status: 'READY',
|
|
318
|
+
description: {
|
|
319
|
+
text: 'Datalayer Notebook',
|
|
324
320
|
},
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
]
|
|
331
|
-
}
|
|
321
|
+
media: asset,
|
|
322
|
+
title: {
|
|
323
|
+
text: 'Datalayer Notebook',
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
],
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
visibility: {
|
|
330
|
+
'com.linkedin.ugc.MemberNetworkVisibility': 'PUBLIC',
|
|
332
331
|
},
|
|
333
|
-
"visibility": {
|
|
334
|
-
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
|
|
335
|
-
}
|
|
336
332
|
};
|
|
337
333
|
return proxyPOST(IAMProvidersSpecs.LinkedIn.postShareURL, share, accessToken);
|
|
338
334
|
});
|
|
@@ -340,18 +336,18 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
340
336
|
};
|
|
341
337
|
// Proxy -------------------------------------------------------------------
|
|
342
338
|
const proxyGET = async (url, token) => {
|
|
343
|
-
return
|
|
339
|
+
return requestDatalayer({
|
|
344
340
|
url: URLExt.join(configuration.iamRunUrl, 'api/iam/v1/proxy/request'),
|
|
345
341
|
method: 'POST',
|
|
346
342
|
body: {
|
|
347
343
|
request_method: 'GET',
|
|
348
344
|
request_url: url,
|
|
349
345
|
request_token: token,
|
|
350
|
-
}
|
|
346
|
+
},
|
|
351
347
|
});
|
|
352
348
|
};
|
|
353
349
|
const proxyPOST = async (url, body, token) => {
|
|
354
|
-
return
|
|
350
|
+
return requestDatalayer({
|
|
355
351
|
url: URLExt.join(configuration.iamRunUrl, 'api/iam/v1/proxy/request'),
|
|
356
352
|
method: 'POST',
|
|
357
353
|
body: {
|
|
@@ -359,11 +355,11 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
359
355
|
request_url: url,
|
|
360
356
|
request_token: token,
|
|
361
357
|
request_body: body,
|
|
362
|
-
}
|
|
358
|
+
},
|
|
363
359
|
});
|
|
364
360
|
};
|
|
365
361
|
const proxyPUT = async (url, body, token) => {
|
|
366
|
-
return
|
|
362
|
+
return requestDatalayer({
|
|
367
363
|
url: URLExt.join(configuration.iamRunUrl, 'api/iam/v1/proxy/request'),
|
|
368
364
|
method: 'POST',
|
|
369
365
|
body: {
|
|
@@ -371,20 +367,20 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
371
367
|
request_url: url,
|
|
372
368
|
request_token: token,
|
|
373
369
|
request_body: body,
|
|
374
|
-
}
|
|
370
|
+
},
|
|
375
371
|
});
|
|
376
372
|
};
|
|
377
373
|
// Waiting List -------------------------------------------------------------
|
|
378
374
|
const registerToWaitingList = (formData) => {
|
|
379
|
-
|
|
375
|
+
requestDatalayer({
|
|
380
376
|
url: `${configuration.growthRunUrl}/api/growth/v1/waitinglist/register`,
|
|
381
377
|
method: 'POST',
|
|
382
378
|
body: {
|
|
383
379
|
firstName: formData.firstName,
|
|
384
380
|
lastName: formData.lastName,
|
|
385
381
|
email: formData.email,
|
|
386
|
-
affiliation: formData.affiliation || ''
|
|
387
|
-
}
|
|
382
|
+
affiliation: formData.affiliation || '',
|
|
383
|
+
},
|
|
388
384
|
})
|
|
389
385
|
.then(resp => {
|
|
390
386
|
// Special case, make the error very explicit to the user...
|
|
@@ -400,10 +396,10 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
400
396
|
};
|
|
401
397
|
// Profile ------------------------------------------------------------------
|
|
402
398
|
const getMe = async (token) => {
|
|
403
|
-
const resp = await
|
|
399
|
+
const resp = await requestDatalayer({
|
|
404
400
|
url: `${configuration.iamRunUrl}/api/iam/v1/me`,
|
|
405
401
|
method: 'GET',
|
|
406
|
-
token
|
|
402
|
+
token,
|
|
407
403
|
});
|
|
408
404
|
const me = resp.me;
|
|
409
405
|
if (me) {
|
|
@@ -413,53 +409,53 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
413
409
|
return null;
|
|
414
410
|
};
|
|
415
411
|
const updateMe = (email, firstName, lastName) => {
|
|
416
|
-
return
|
|
412
|
+
return requestDatalayer({
|
|
417
413
|
url: `${configuration.iamRunUrl}/api/iam/v1/me`,
|
|
418
414
|
method: 'PUT',
|
|
419
415
|
body: {
|
|
420
416
|
email,
|
|
421
417
|
firstName,
|
|
422
418
|
lastName,
|
|
423
|
-
}
|
|
419
|
+
},
|
|
424
420
|
});
|
|
425
421
|
};
|
|
426
422
|
const whoami = () => {
|
|
427
|
-
return
|
|
423
|
+
return requestDatalayer({
|
|
428
424
|
url: `${configuration.iamRunUrl}/api/iam/v1/whoami`,
|
|
429
425
|
method: 'GET',
|
|
430
426
|
});
|
|
431
427
|
};
|
|
432
|
-
const requestEmailUpdate =
|
|
433
|
-
return
|
|
428
|
+
const requestEmailUpdate = email => {
|
|
429
|
+
return requestDatalayer({
|
|
434
430
|
url: `${configuration.iamRunUrl}/api/iam/v1/me/email`,
|
|
435
431
|
method: 'PUT',
|
|
436
432
|
body: {
|
|
437
433
|
email,
|
|
438
|
-
}
|
|
434
|
+
},
|
|
439
435
|
});
|
|
440
436
|
};
|
|
441
|
-
const confirmEmailUpdate =
|
|
442
|
-
return
|
|
437
|
+
const confirmEmailUpdate = token => {
|
|
438
|
+
return requestDatalayer({
|
|
443
439
|
url: `${configuration.iamRunUrl}/api/iam/v1/me/email`,
|
|
444
440
|
method: 'POST',
|
|
445
441
|
body: {
|
|
446
442
|
token,
|
|
447
|
-
}
|
|
443
|
+
},
|
|
448
444
|
});
|
|
449
445
|
};
|
|
450
446
|
// Onboarding ---------------------------------------------------------------
|
|
451
447
|
const updateUserOnboarding = (onboarding) => {
|
|
452
|
-
return
|
|
448
|
+
return requestDatalayer({
|
|
453
449
|
url: `${configuration.iamRunUrl}/api/iam/v1/onboardings`,
|
|
454
450
|
method: 'PUT',
|
|
455
451
|
body: {
|
|
456
452
|
onboarding,
|
|
457
|
-
}
|
|
453
|
+
},
|
|
458
454
|
});
|
|
459
455
|
};
|
|
460
456
|
// Settings -----------------------------------------------------------------
|
|
461
457
|
const updateUserSettings = (userId, settings) => {
|
|
462
|
-
return
|
|
458
|
+
return requestDatalayer({
|
|
463
459
|
url: `${configuration.iamRunUrl}/api/iam/v1/users/${userId}/settings`,
|
|
464
460
|
method: 'PUT',
|
|
465
461
|
body: {
|
|
@@ -477,10 +473,10 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
477
473
|
}
|
|
478
474
|
};
|
|
479
475
|
const createPage = (page) => {
|
|
480
|
-
return
|
|
476
|
+
return requestDatalayer({
|
|
481
477
|
url: `${configuration.libraryRunUrl}/api/library/v1/pages`,
|
|
482
478
|
method: 'POST',
|
|
483
|
-
body: { ...page }
|
|
479
|
+
body: { ...page },
|
|
484
480
|
}).then(resp => {
|
|
485
481
|
if (resp.success) {
|
|
486
482
|
if (resp.page) {
|
|
@@ -495,7 +491,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
495
491
|
});
|
|
496
492
|
};
|
|
497
493
|
const updatePage = (page) => {
|
|
498
|
-
return
|
|
494
|
+
return requestDatalayer({
|
|
499
495
|
url: `${configuration.libraryRunUrl}/api/library/v1/pages/${page.id}`,
|
|
500
496
|
method: 'PUT',
|
|
501
497
|
body: {
|
|
@@ -513,7 +509,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
513
509
|
});
|
|
514
510
|
};
|
|
515
511
|
const deletePage = (page) => {
|
|
516
|
-
return
|
|
512
|
+
return requestDatalayer({
|
|
517
513
|
url: `${configuration.libraryRunUrl}/api/library/v1/pages/${page.id}`,
|
|
518
514
|
method: 'DELETE',
|
|
519
515
|
});
|
|
@@ -521,7 +517,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
521
517
|
const getPage = (pageId) => PAGES_BY_ID.get(pageId);
|
|
522
518
|
const clearCachedPages = () => PAGES_BY_ID.clear();
|
|
523
519
|
const refreshPage = (pageId) => {
|
|
524
|
-
return
|
|
520
|
+
return requestDatalayer({
|
|
525
521
|
url: `${configuration.libraryRunUrl}/api/library/v1/pages/${pageId}`,
|
|
526
522
|
method: 'GET',
|
|
527
523
|
}).then(resp => {
|
|
@@ -537,7 +533,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
537
533
|
return Array.from(PAGES_BY_ID.values());
|
|
538
534
|
};
|
|
539
535
|
const refreshPages = () => {
|
|
540
|
-
return
|
|
536
|
+
return requestDatalayer({
|
|
541
537
|
url: `${configuration.libraryRunUrl}/api/library/v1/pages`,
|
|
542
538
|
method: 'GET',
|
|
543
539
|
}).then(resp => {
|
|
@@ -562,10 +558,10 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
562
558
|
}
|
|
563
559
|
};
|
|
564
560
|
const createDatasource = (datasource) => {
|
|
565
|
-
return
|
|
561
|
+
return requestDatalayer({
|
|
566
562
|
url: `${configuration.iamRunUrl}/api/iam/v1/datasources`,
|
|
567
563
|
method: 'POST',
|
|
568
|
-
body: { ...datasource }
|
|
564
|
+
body: { ...datasource },
|
|
569
565
|
}).then(resp => {
|
|
570
566
|
if (resp.success) {
|
|
571
567
|
if (resp.datasource) {
|
|
@@ -576,10 +572,10 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
576
572
|
});
|
|
577
573
|
};
|
|
578
574
|
const updateDatasource = (datasource) => {
|
|
579
|
-
return
|
|
575
|
+
return requestDatalayer({
|
|
580
576
|
url: `${configuration.iamRunUrl}/api/iam/v1/datasources/${datasource.id}`,
|
|
581
577
|
method: 'PUT',
|
|
582
|
-
body: { ...datasource }
|
|
578
|
+
body: { ...datasource },
|
|
583
579
|
}).then(resp => {
|
|
584
580
|
if (resp.success) {
|
|
585
581
|
if (resp.datasource) {
|
|
@@ -592,7 +588,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
592
588
|
const getDatasource = (datasourceId) => DATASOURCES_BY_ID.get(datasourceId);
|
|
593
589
|
const clearCachedDatasources = () => DATASOURCES_BY_ID.clear();
|
|
594
590
|
const refreshDatasource = (datasourceId) => {
|
|
595
|
-
return
|
|
591
|
+
return requestDatalayer({
|
|
596
592
|
url: `${configuration.iamRunUrl}/api/iam/v1/datasources/${datasourceId}`,
|
|
597
593
|
method: 'GET',
|
|
598
594
|
}).then(resp => {
|
|
@@ -608,7 +604,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
608
604
|
return Array.from(DATASOURCES_BY_ID.values());
|
|
609
605
|
};
|
|
610
606
|
const refreshDatasources = () => {
|
|
611
|
-
return
|
|
607
|
+
return requestDatalayer({
|
|
612
608
|
url: `${configuration.iamRunUrl}/api/iam/v1/datasources`,
|
|
613
609
|
method: 'GET',
|
|
614
610
|
}).then(resp => {
|
|
@@ -633,10 +629,10 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
633
629
|
}
|
|
634
630
|
};
|
|
635
631
|
const createSecret = (secret) => {
|
|
636
|
-
return
|
|
632
|
+
return requestDatalayer({
|
|
637
633
|
url: `${configuration.iamRunUrl}/api/iam/v1/secrets`,
|
|
638
634
|
method: 'POST',
|
|
639
|
-
body: { ...secret }
|
|
635
|
+
body: { ...secret },
|
|
640
636
|
}).then(resp => {
|
|
641
637
|
if (resp.success) {
|
|
642
638
|
if (resp.secret) {
|
|
@@ -647,10 +643,10 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
647
643
|
});
|
|
648
644
|
};
|
|
649
645
|
const updateSecret = (secret) => {
|
|
650
|
-
return
|
|
646
|
+
return requestDatalayer({
|
|
651
647
|
url: `${configuration.iamRunUrl}/api/iam/v1/secrets/${secret.id}`,
|
|
652
648
|
method: 'PUT',
|
|
653
|
-
body: { ...secret }
|
|
649
|
+
body: { ...secret },
|
|
654
650
|
}).then(resp => {
|
|
655
651
|
if (resp.success) {
|
|
656
652
|
if (resp.secret) {
|
|
@@ -661,7 +657,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
661
657
|
});
|
|
662
658
|
};
|
|
663
659
|
const deleteSecret = (secret) => {
|
|
664
|
-
return
|
|
660
|
+
return requestDatalayer({
|
|
665
661
|
url: `${configuration.iamRunUrl}/api/iam/v1/secrets/${secret.id}`,
|
|
666
662
|
method: 'DELETE',
|
|
667
663
|
});
|
|
@@ -669,7 +665,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
669
665
|
const getSecret = (secretId) => SECRETS_BY_ID.get(secretId);
|
|
670
666
|
const clearCachedSecrets = () => SECRETS_BY_ID.clear();
|
|
671
667
|
const refreshSecret = (secretId) => {
|
|
672
|
-
return
|
|
668
|
+
return requestDatalayer({
|
|
673
669
|
url: `${configuration.iamRunUrl}/api/iam/v1/secrets/${secretId}`,
|
|
674
670
|
method: 'GET',
|
|
675
671
|
}).then(resp => {
|
|
@@ -685,7 +681,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
685
681
|
return Array.from(SECRETS_BY_ID.values());
|
|
686
682
|
};
|
|
687
683
|
const refreshSecrets = () => {
|
|
688
|
-
return
|
|
684
|
+
return requestDatalayer({
|
|
689
685
|
url: `${configuration.iamRunUrl}/api/iam/v1/secrets`,
|
|
690
686
|
method: 'GET',
|
|
691
687
|
}).then(resp => {
|
|
@@ -710,13 +706,13 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
710
706
|
}
|
|
711
707
|
};
|
|
712
708
|
const createToken = (token) => {
|
|
713
|
-
return
|
|
709
|
+
return requestDatalayer({
|
|
714
710
|
url: `${configuration.iamRunUrl}/api/iam/v1/tokens`,
|
|
715
711
|
method: 'POST',
|
|
716
712
|
body: {
|
|
717
713
|
...token,
|
|
718
714
|
expirationDate: token.expirationDate.getTime(),
|
|
719
|
-
}
|
|
715
|
+
},
|
|
720
716
|
}).then(resp => {
|
|
721
717
|
if (resp.success) {
|
|
722
718
|
if (resp.token) {
|
|
@@ -727,10 +723,10 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
727
723
|
});
|
|
728
724
|
};
|
|
729
725
|
const updateToken = (token) => {
|
|
730
|
-
return
|
|
726
|
+
return requestDatalayer({
|
|
731
727
|
url: `${configuration.iamRunUrl}/api/iam/v1/tokens/${token.id}`,
|
|
732
728
|
method: 'PUT',
|
|
733
|
-
body: { ...token }
|
|
729
|
+
body: { ...token },
|
|
734
730
|
}).then(resp => {
|
|
735
731
|
if (resp.success) {
|
|
736
732
|
if (resp.token) {
|
|
@@ -743,7 +739,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
743
739
|
const getToken = (tokenId) => TOKENS_BY_ID.get(tokenId);
|
|
744
740
|
const clearCachedTokens = () => TOKENS_BY_ID.clear();
|
|
745
741
|
const refreshToken = (tokenId) => {
|
|
746
|
-
return
|
|
742
|
+
return requestDatalayer({
|
|
747
743
|
url: `${configuration.iamRunUrl}/api/iam/v1/tokens/${tokenId}`,
|
|
748
744
|
method: 'GET',
|
|
749
745
|
}).then(resp => {
|
|
@@ -759,7 +755,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
759
755
|
return Array.from(TOKENS_BY_ID.values());
|
|
760
756
|
};
|
|
761
757
|
const refreshTokens = () => {
|
|
762
|
-
return
|
|
758
|
+
return requestDatalayer({
|
|
763
759
|
url: `${configuration.iamRunUrl}/api/iam/v1/tokens`,
|
|
764
760
|
method: 'GET',
|
|
765
761
|
}).then(resp => {
|
|
@@ -777,7 +773,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
777
773
|
};
|
|
778
774
|
// Layout -------------------------------------------------------------------
|
|
779
775
|
const refreshLayout = (accountHandle, spaceHandle, user) => {
|
|
780
|
-
return
|
|
776
|
+
return requestDatalayer({
|
|
781
777
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/layouts/accounts/${accountHandle}${spaceHandle !== undefined ? '/spaces/' + spaceHandle : ''}`,
|
|
782
778
|
method: 'GET',
|
|
783
779
|
}).then(resp => {
|
|
@@ -819,7 +815,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
819
815
|
};
|
|
820
816
|
// Invites -------------------------------------------------------------------
|
|
821
817
|
const requestInvite = (firstName, lastName, email, socialUrl) => {
|
|
822
|
-
return
|
|
818
|
+
return requestDatalayer({
|
|
823
819
|
url: `${configuration.growthRunUrl}/api/growth/v1/invites/request`,
|
|
824
820
|
method: 'POST',
|
|
825
821
|
body: {
|
|
@@ -827,11 +823,11 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
827
823
|
last_name: lastName,
|
|
828
824
|
email: email,
|
|
829
825
|
social_url: socialUrl,
|
|
830
|
-
}
|
|
826
|
+
},
|
|
831
827
|
});
|
|
832
828
|
};
|
|
833
829
|
const sendInvite = (invite) => {
|
|
834
|
-
return
|
|
830
|
+
return requestDatalayer({
|
|
835
831
|
url: `${configuration.growthRunUrl}/api/growth/v1/invites`,
|
|
836
832
|
method: 'POST',
|
|
837
833
|
body: {
|
|
@@ -840,13 +836,13 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
840
836
|
lastName: invite.to.lastName,
|
|
841
837
|
message: invite.message,
|
|
842
838
|
brand: invite.brand,
|
|
843
|
-
}
|
|
839
|
+
},
|
|
844
840
|
});
|
|
845
841
|
};
|
|
846
842
|
const getInvite = (token) => INVITES_BY_TOKEN.get(token);
|
|
847
843
|
const clearCachedInvites = () => INVITES_BY_TOKEN.clear();
|
|
848
844
|
const refreshInvite = (token) => {
|
|
849
|
-
return
|
|
845
|
+
return requestDatalayer({
|
|
850
846
|
url: `${configuration.growthRunUrl}/api/growth/v1/invites/tokens/${token}`,
|
|
851
847
|
method: 'GET',
|
|
852
848
|
}).then(resp => {
|
|
@@ -866,7 +862,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
866
862
|
return Array.from(INVITES_BY_TOKEN.values());
|
|
867
863
|
};
|
|
868
864
|
const refreshInvites = (accountId) => {
|
|
869
|
-
return
|
|
865
|
+
return requestDatalayer({
|
|
870
866
|
url: `${configuration.growthRunUrl}/api/growth/v1/invites/users/${accountId}`,
|
|
871
867
|
method: 'GET',
|
|
872
868
|
}).then(resp => {
|
|
@@ -882,14 +878,14 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
882
878
|
});
|
|
883
879
|
};
|
|
884
880
|
const putInvite = (token) => {
|
|
885
|
-
return
|
|
881
|
+
return requestDatalayer({
|
|
886
882
|
url: `${configuration.growthRunUrl}/api/growth/v1/invites/tokens/${token}`,
|
|
887
883
|
method: 'PUT',
|
|
888
884
|
});
|
|
889
885
|
};
|
|
890
886
|
// Accounts -------------------------------------------------------------------
|
|
891
887
|
const refreshAccount = (accountHandle) => {
|
|
892
|
-
return
|
|
888
|
+
return requestDatalayer({
|
|
893
889
|
url: `${configuration.iamRunUrl}/api/iam/v1/accounts/${accountHandle}`,
|
|
894
890
|
method: 'GET',
|
|
895
891
|
}).then(resp => {
|
|
@@ -916,12 +912,12 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
916
912
|
const getContactById = (contactId) => CONTACTS_BY_ID.get(contactId);
|
|
917
913
|
const getContactByHandle = (contactHandle) => CONTACTS_BY_HANDLE.get(contactHandle);
|
|
918
914
|
const createContact = (contact) => {
|
|
919
|
-
return
|
|
915
|
+
return requestDatalayer({
|
|
920
916
|
url: `${configuration.growthRunUrl}/api/growth/v1/contacts`,
|
|
921
917
|
method: 'POST',
|
|
922
918
|
body: {
|
|
923
919
|
contact,
|
|
924
|
-
}
|
|
920
|
+
},
|
|
925
921
|
}).then(resp => {
|
|
926
922
|
if (resp.success) {
|
|
927
923
|
toContact(resp.contact);
|
|
@@ -930,12 +926,12 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
930
926
|
});
|
|
931
927
|
};
|
|
932
928
|
const updateContact = (contactId, contact) => {
|
|
933
|
-
return
|
|
929
|
+
return requestDatalayer({
|
|
934
930
|
url: `${configuration.growthRunUrl}/api/growth/v1/contacts/${contactId}`,
|
|
935
931
|
method: 'PUT',
|
|
936
932
|
body: {
|
|
937
933
|
contact,
|
|
938
|
-
}
|
|
934
|
+
},
|
|
939
935
|
}).then(resp => {
|
|
940
936
|
if (resp.success) {
|
|
941
937
|
toContact(resp.contact);
|
|
@@ -944,7 +940,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
944
940
|
});
|
|
945
941
|
};
|
|
946
942
|
const refreshContact = (contactId) => {
|
|
947
|
-
return
|
|
943
|
+
return requestDatalayer({
|
|
948
944
|
url: `${configuration.growthRunUrl}/api/growth/v1/contacts/${contactId}`,
|
|
949
945
|
method: 'GET',
|
|
950
946
|
}).then(resp => {
|
|
@@ -955,12 +951,12 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
955
951
|
});
|
|
956
952
|
};
|
|
957
953
|
const searchContacts = (query) => {
|
|
958
|
-
return
|
|
954
|
+
return requestDatalayer({
|
|
959
955
|
url: `${configuration.growthRunUrl}/api/growth/v1/contacts/search`,
|
|
960
956
|
method: 'POST',
|
|
961
957
|
body: {
|
|
962
958
|
query,
|
|
963
|
-
}
|
|
959
|
+
},
|
|
964
960
|
}).then(resp => {
|
|
965
961
|
if (resp.success) {
|
|
966
962
|
const contacts = resp.contacts.map(contact => toContact(contact));
|
|
@@ -970,53 +966,53 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
970
966
|
});
|
|
971
967
|
};
|
|
972
968
|
const assignTagToContact = (contactId, tagName) => {
|
|
973
|
-
return
|
|
969
|
+
return requestDatalayer({
|
|
974
970
|
url: `${configuration.growthRunUrl}/api/growth/v1/contacts/${contactId}/tags/${tagName}`,
|
|
975
971
|
method: 'POST',
|
|
976
972
|
});
|
|
977
973
|
};
|
|
978
974
|
const unassignTagFromContact = (contactId, tagName) => {
|
|
979
|
-
return
|
|
975
|
+
return requestDatalayer({
|
|
980
976
|
url: `${configuration.growthRunUrl}/api/growth/v1/contacts/${contactId}/tags/${tagName}`,
|
|
981
977
|
method: 'DELETE',
|
|
982
978
|
});
|
|
983
979
|
};
|
|
984
980
|
const deleteContact = (contactId) => {
|
|
985
|
-
return
|
|
981
|
+
return requestDatalayer({
|
|
986
982
|
url: `${configuration.growthRunUrl}/api/growth/v1/contacts/${contactId}`,
|
|
987
983
|
method: 'DELETE',
|
|
988
984
|
});
|
|
989
985
|
};
|
|
990
986
|
const sendInviteToContact = (contact, message) => {
|
|
991
|
-
return
|
|
987
|
+
return requestDatalayer({
|
|
992
988
|
url: `${configuration.growthRunUrl}/api/growth/v1/contacts/invites`,
|
|
993
989
|
method: 'POST',
|
|
994
990
|
body: {
|
|
995
991
|
contactId: contact.id,
|
|
996
992
|
message,
|
|
997
|
-
}
|
|
993
|
+
},
|
|
998
994
|
});
|
|
999
995
|
};
|
|
1000
996
|
// Contacts Enrich ----------------------------------------------------------
|
|
1001
997
|
const enrichContactEmail = (contactId, useDomain) => {
|
|
1002
|
-
return
|
|
998
|
+
return requestDatalayer({
|
|
1003
999
|
url: `${configuration.growthRunUrl}/api/growth/v1/contacts/${contactId}/enrich/email?useDomain=${useDomain}`,
|
|
1004
1000
|
method: 'GET',
|
|
1005
1001
|
});
|
|
1006
1002
|
};
|
|
1007
|
-
const enrichContactLinkedin =
|
|
1008
|
-
return
|
|
1003
|
+
const enrichContactLinkedin = contactId => {
|
|
1004
|
+
return requestDatalayer({
|
|
1009
1005
|
url: `${configuration.growthRunUrl}/api/growth/v1/contacts/${contactId}/enrich/linkedin`,
|
|
1010
1006
|
method: 'GET',
|
|
1011
1007
|
});
|
|
1012
1008
|
};
|
|
1013
1009
|
const sendLinkedinConnectionRequest = (contact, message) => {
|
|
1014
|
-
return
|
|
1010
|
+
return requestDatalayer({
|
|
1015
1011
|
url: `${configuration.growthRunUrl}/api/growth/v1/contacts/${contact.id}/connect/linkedin`,
|
|
1016
1012
|
method: 'POST',
|
|
1017
1013
|
body: {
|
|
1018
1014
|
message,
|
|
1019
|
-
}
|
|
1015
|
+
},
|
|
1020
1016
|
}).then(resp => {
|
|
1021
1017
|
if (resp.success) {
|
|
1022
1018
|
toContact(resp.contact);
|
|
@@ -1026,14 +1022,14 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1026
1022
|
};
|
|
1027
1023
|
// Contacts Links -----------------------------------------------------------
|
|
1028
1024
|
const linkUserWithContact = (userId, contactId) => {
|
|
1029
|
-
return
|
|
1030
|
-
url: `${configuration.growthRunUrl}/api/growth/v1/users/${userId}/contacts/${contactId}`,
|
|
1025
|
+
return requestDatalayer({
|
|
1026
|
+
url: `${configuration.growthRunUrl}/api/growth/v1/users/${userId}/contacts/${contactId}/link`,
|
|
1031
1027
|
method: 'POST',
|
|
1032
1028
|
});
|
|
1033
1029
|
};
|
|
1034
1030
|
const unlinkUserFromContact = (userId, contactId) => {
|
|
1035
|
-
return
|
|
1036
|
-
url: `${configuration.growthRunUrl}/api/growth/v1/users/${userId}/contacts/${contactId}`,
|
|
1031
|
+
return requestDatalayer({
|
|
1032
|
+
url: `${configuration.growthRunUrl}/api/growth/v1/users/${userId}/contacts/${contactId}/link`,
|
|
1037
1033
|
method: 'DELETE',
|
|
1038
1034
|
});
|
|
1039
1035
|
};
|
|
@@ -1049,7 +1045,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1049
1045
|
const getUser = (id) => USERS_BY_ID.get(id);
|
|
1050
1046
|
const getUserByHandle = (handle) => USERS_BY_HANDLE.get(handle);
|
|
1051
1047
|
const refreshUser = (userId) => {
|
|
1052
|
-
return
|
|
1048
|
+
return requestDatalayer({
|
|
1053
1049
|
url: `${configuration.iamRunUrl}/api/iam/v1/users/${userId}`,
|
|
1054
1050
|
method: 'GET',
|
|
1055
1051
|
}).then(resp => {
|
|
@@ -1060,12 +1056,12 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1060
1056
|
});
|
|
1061
1057
|
};
|
|
1062
1058
|
const searchUsers = (namingPattern) => {
|
|
1063
|
-
return
|
|
1059
|
+
return requestDatalayer({
|
|
1064
1060
|
url: `${configuration.iamRunUrl}/api/iam/v1/users/search`,
|
|
1065
1061
|
method: 'POST',
|
|
1066
1062
|
body: {
|
|
1067
|
-
namingPattern
|
|
1068
|
-
}
|
|
1063
|
+
namingPattern,
|
|
1064
|
+
},
|
|
1069
1065
|
}).then(resp => {
|
|
1070
1066
|
if (resp.success) {
|
|
1071
1067
|
const users = resp.users.map(user => toUser(user));
|
|
@@ -1076,13 +1072,13 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1076
1072
|
};
|
|
1077
1073
|
// User Roles ---------------------------------------------------------------
|
|
1078
1074
|
const assignRoleToUser = (userId, roleName) => {
|
|
1079
|
-
return
|
|
1075
|
+
return requestDatalayer({
|
|
1080
1076
|
url: `${configuration.iamRunUrl}/api/iam/v1/users/${userId}/roles/${roleName}`,
|
|
1081
1077
|
method: 'POST',
|
|
1082
1078
|
});
|
|
1083
1079
|
};
|
|
1084
1080
|
const unassignRoleFromUser = (userId, roleName) => {
|
|
1085
|
-
return
|
|
1081
|
+
return requestDatalayer({
|
|
1086
1082
|
url: `${configuration.iamRunUrl}/api/iam/v1/users/${userId}/roles/${roleName}`,
|
|
1087
1083
|
method: 'DELETE',
|
|
1088
1084
|
});
|
|
@@ -1095,14 +1091,14 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1095
1091
|
return organization;
|
|
1096
1092
|
};
|
|
1097
1093
|
const createOrganization = (organization) => {
|
|
1098
|
-
return
|
|
1094
|
+
return requestDatalayer({
|
|
1099
1095
|
url: `${configuration.iamRunUrl}/api/iam/v1/organizations`,
|
|
1100
1096
|
method: 'POST',
|
|
1101
1097
|
body: {
|
|
1102
1098
|
handle: organization.handle,
|
|
1103
1099
|
name: organization.name,
|
|
1104
1100
|
description: organization.description,
|
|
1105
|
-
}
|
|
1101
|
+
},
|
|
1106
1102
|
}).then(resp => {
|
|
1107
1103
|
const organization = toOrganization(resp.organization);
|
|
1108
1104
|
ORGANISATIONS_FOR_USER_BY_ID.set(organization.id, organization);
|
|
@@ -1117,7 +1113,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1117
1113
|
ORGANISATIONS_FOR_USER_BY_ID.clear();
|
|
1118
1114
|
};
|
|
1119
1115
|
const refreshOrganization = (user, organizationId) => {
|
|
1120
|
-
return
|
|
1116
|
+
return requestDatalayer({
|
|
1121
1117
|
url: `${configuration.iamRunUrl}/api/iam/v1/organizations/${organizationId}`,
|
|
1122
1118
|
method: 'GET',
|
|
1123
1119
|
}).then(resp => {
|
|
@@ -1134,13 +1130,13 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1134
1130
|
});
|
|
1135
1131
|
};
|
|
1136
1132
|
const updateOrganization = (organization) => {
|
|
1137
|
-
return
|
|
1133
|
+
return requestDatalayer({
|
|
1138
1134
|
url: `${configuration.iamRunUrl}/api/iam/v1/organizations/${organization.id}`,
|
|
1139
1135
|
method: 'PUT',
|
|
1140
1136
|
body: {
|
|
1141
1137
|
name: organization.name,
|
|
1142
1138
|
description: organization.description,
|
|
1143
|
-
}
|
|
1139
|
+
},
|
|
1144
1140
|
}).then(resp => {
|
|
1145
1141
|
if (resp.success) {
|
|
1146
1142
|
const org = getOrganizationById(organization.id);
|
|
@@ -1155,7 +1151,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1155
1151
|
const getUserOrganizations = () => Array.from(ORGANISATIONS_FOR_USER_BY_ID.values());
|
|
1156
1152
|
const getUserOrganizationById = (organizationId) => ORGANISATIONS_FOR_USER_BY_ID.get(organizationId);
|
|
1157
1153
|
const refreshUserOrganizations = (user) => {
|
|
1158
|
-
return
|
|
1154
|
+
return requestDatalayer({
|
|
1159
1155
|
url: `${configuration.iamRunUrl}/api/iam/v1/organizations`,
|
|
1160
1156
|
method: 'GET',
|
|
1161
1157
|
}).then(resp => {
|
|
@@ -1171,25 +1167,25 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1171
1167
|
});
|
|
1172
1168
|
};
|
|
1173
1169
|
const addMemberToOrganization = (organizationId, userId) => {
|
|
1174
|
-
return
|
|
1170
|
+
return requestDatalayer({
|
|
1175
1171
|
url: `${configuration.iamRunUrl}/api/iam/v1/organizations/${organizationId}/members/${userId}`,
|
|
1176
1172
|
method: 'POST',
|
|
1177
1173
|
});
|
|
1178
1174
|
};
|
|
1179
1175
|
const removeMemberFromOrganization = (organizationId, userId) => {
|
|
1180
|
-
return
|
|
1176
|
+
return requestDatalayer({
|
|
1181
1177
|
url: `${configuration.iamRunUrl}/api/iam/v1/organizations/${organizationId}/members/${userId}`,
|
|
1182
1178
|
method: 'DELETE',
|
|
1183
1179
|
});
|
|
1184
1180
|
};
|
|
1185
1181
|
const addRoleToOrganizationMember = (organizationId, userId, roleName) => {
|
|
1186
|
-
return
|
|
1182
|
+
return requestDatalayer({
|
|
1187
1183
|
url: `${configuration.iamRunUrl}/api/iam/v1/organizations/${organizationId}/members/${userId}/roles/${roleName}`,
|
|
1188
1184
|
method: 'POST',
|
|
1189
1185
|
});
|
|
1190
1186
|
};
|
|
1191
1187
|
const removeRoleFromOrganizationMember = (organizationId, userId, roleName) => {
|
|
1192
|
-
return
|
|
1188
|
+
return requestDatalayer({
|
|
1193
1189
|
url: `${configuration.iamRunUrl}/api/iam/v1/organizations/${organizationId}/members/${userId}/roles/${roleName}`,
|
|
1194
1190
|
method: 'DELETE',
|
|
1195
1191
|
});
|
|
@@ -1202,7 +1198,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1202
1198
|
return team;
|
|
1203
1199
|
};
|
|
1204
1200
|
const createTeam = (team, organization) => {
|
|
1205
|
-
return
|
|
1201
|
+
return requestDatalayer({
|
|
1206
1202
|
url: `${configuration.iamRunUrl}/api/iam/v1/teams`,
|
|
1207
1203
|
method: 'POST',
|
|
1208
1204
|
body: {
|
|
@@ -1210,7 +1206,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1210
1206
|
name: team.name,
|
|
1211
1207
|
description: team.description,
|
|
1212
1208
|
organizationId: organization.id,
|
|
1213
|
-
}
|
|
1209
|
+
},
|
|
1214
1210
|
}).then(resp => {
|
|
1215
1211
|
const team = toTeam(resp.team, organization.id);
|
|
1216
1212
|
TEAMS_BY_HANDLE.set(team.handle, team);
|
|
@@ -1225,7 +1221,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1225
1221
|
TEAMS_BY_ID.clear();
|
|
1226
1222
|
};
|
|
1227
1223
|
const refreshTeam = (teamId, organizationId) => {
|
|
1228
|
-
return
|
|
1224
|
+
return requestDatalayer({
|
|
1229
1225
|
url: `${configuration.iamRunUrl}/api/iam/v1/teams/${teamId}`,
|
|
1230
1226
|
method: 'GET',
|
|
1231
1227
|
}).then(resp => {
|
|
@@ -1241,13 +1237,13 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1241
1237
|
});
|
|
1242
1238
|
};
|
|
1243
1239
|
const updateTeam = (team) => {
|
|
1244
|
-
return
|
|
1240
|
+
return requestDatalayer({
|
|
1245
1241
|
url: `${configuration.iamRunUrl}/api/iam/v1/teams/${team.id}`,
|
|
1246
1242
|
method: 'PUT',
|
|
1247
1243
|
body: {
|
|
1248
1244
|
name: team.name,
|
|
1249
1245
|
description: team.description,
|
|
1250
|
-
}
|
|
1246
|
+
},
|
|
1251
1247
|
}).then(resp => {
|
|
1252
1248
|
if (resp.success) {
|
|
1253
1249
|
const t = resp.team;
|
|
@@ -1262,7 +1258,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1262
1258
|
};
|
|
1263
1259
|
const getTeamsByOrganizationId = (organizationId) => TEAMS_BY_ORGANIZATION_BY_ID.get(organizationId);
|
|
1264
1260
|
const refreshTeams = (organizationId) => {
|
|
1265
|
-
return
|
|
1261
|
+
return requestDatalayer({
|
|
1266
1262
|
url: `${configuration.iamRunUrl}/api/iam/v1/organizations/${organizationId}/teams`,
|
|
1267
1263
|
method: 'GET',
|
|
1268
1264
|
}).then(resp => {
|
|
@@ -1279,25 +1275,25 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1279
1275
|
});
|
|
1280
1276
|
};
|
|
1281
1277
|
const addMemberToTeam = (teamId, userId) => {
|
|
1282
|
-
return
|
|
1278
|
+
return requestDatalayer({
|
|
1283
1279
|
url: `${configuration.iamRunUrl}/api/iam/v1/teams/${teamId}/members/${userId}`,
|
|
1284
1280
|
method: 'POST',
|
|
1285
1281
|
});
|
|
1286
1282
|
};
|
|
1287
1283
|
const removeMemberFromTeam = (teamId, userId) => {
|
|
1288
|
-
return
|
|
1284
|
+
return requestDatalayer({
|
|
1289
1285
|
url: `${configuration.iamRunUrl}/api/iam/v1/teams/${teamId}/members/${userId}`,
|
|
1290
1286
|
method: 'DELETE',
|
|
1291
1287
|
});
|
|
1292
1288
|
};
|
|
1293
1289
|
const addRoleToTeamMember = (teamId, userId, roleName) => {
|
|
1294
|
-
return
|
|
1290
|
+
return requestDatalayer({
|
|
1295
1291
|
url: `${configuration.iamRunUrl}/api/iam/v1/teams/${teamId}/members/${userId}/roles/${roleName}`,
|
|
1296
1292
|
method: 'POST',
|
|
1297
1293
|
});
|
|
1298
1294
|
};
|
|
1299
1295
|
const removeRoleFromTeamMember = (teamId, userId, roleName) => {
|
|
1300
|
-
return
|
|
1296
|
+
return requestDatalayer({
|
|
1301
1297
|
url: `${configuration.iamRunUrl}/api/iam/v1/teams/${teamId}/members/${userId}/roles/${roleName}`,
|
|
1302
1298
|
method: 'DELETE',
|
|
1303
1299
|
});
|
|
@@ -1307,13 +1303,13 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1307
1303
|
return Array.from(SCHOOLS_BY_ID.values());
|
|
1308
1304
|
};
|
|
1309
1305
|
const refreshSchools = () => {
|
|
1310
|
-
return
|
|
1306
|
+
return requestDatalayer({
|
|
1311
1307
|
url: `${configuration.iamRunUrl}/api/iam/v1/organizations/schools`,
|
|
1312
1308
|
method: 'GET',
|
|
1313
1309
|
}).then(resp => {
|
|
1314
1310
|
if (resp.success) {
|
|
1315
1311
|
resp.orgs.forEach(s => {
|
|
1316
|
-
|
|
1312
|
+
const dean = undefined;
|
|
1317
1313
|
const students = new Array();
|
|
1318
1314
|
const members = new Array();
|
|
1319
1315
|
const courses = new Array();
|
|
@@ -1331,7 +1327,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1331
1327
|
creationDate: new Date(s.creation_ts_dt),
|
|
1332
1328
|
setMembers(members) {
|
|
1333
1329
|
this.members = members;
|
|
1334
|
-
}
|
|
1330
|
+
},
|
|
1335
1331
|
};
|
|
1336
1332
|
SCHOOLS_BY_ID.set(school.id, school);
|
|
1337
1333
|
});
|
|
@@ -1345,10 +1341,8 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1345
1341
|
return space;
|
|
1346
1342
|
};
|
|
1347
1343
|
const createSpace = (space, organization) => {
|
|
1348
|
-
const seedSpaceId =
|
|
1349
|
-
|
|
1350
|
-
: undefined;
|
|
1351
|
-
return requestRun({
|
|
1344
|
+
const seedSpaceId = space.variant === 'course' ? space.seedSpace?.id : undefined;
|
|
1345
|
+
return requestDatalayer({
|
|
1352
1346
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces`,
|
|
1353
1347
|
method: 'POST',
|
|
1354
1348
|
body: {
|
|
@@ -1359,7 +1353,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1359
1353
|
spaceHandle: space.handle,
|
|
1360
1354
|
organizationId: organization?.id,
|
|
1361
1355
|
seedSpaceId,
|
|
1362
|
-
}
|
|
1356
|
+
},
|
|
1363
1357
|
}).then(resp => {
|
|
1364
1358
|
const spc = resp.space;
|
|
1365
1359
|
if (spc) {
|
|
@@ -1389,7 +1383,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1389
1383
|
return organizationSpaces ? organizationSpaces.get(spaceHandle) : undefined;
|
|
1390
1384
|
};
|
|
1391
1385
|
const refreshOrganizationSpace = (organizationId, spaceId) => {
|
|
1392
|
-
return
|
|
1386
|
+
return requestDatalayer({
|
|
1393
1387
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${spaceId}/organizations/${organizationId}`,
|
|
1394
1388
|
method: 'GET',
|
|
1395
1389
|
}).then(resp => {
|
|
@@ -1409,19 +1403,19 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1409
1403
|
});
|
|
1410
1404
|
};
|
|
1411
1405
|
const exportSpace = (spaceId) => {
|
|
1412
|
-
return
|
|
1406
|
+
return requestDatalayer({
|
|
1413
1407
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${spaceId}/export`,
|
|
1414
1408
|
method: 'GET',
|
|
1415
1409
|
});
|
|
1416
1410
|
};
|
|
1417
1411
|
const updateOrganizationSpace = (organization, space) => {
|
|
1418
|
-
return
|
|
1412
|
+
return requestDatalayer({
|
|
1419
1413
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${space.id}/organizations/${organization.id}`,
|
|
1420
1414
|
method: 'PUT',
|
|
1421
1415
|
body: {
|
|
1422
1416
|
name: space.name,
|
|
1423
1417
|
description: space.description,
|
|
1424
|
-
}
|
|
1418
|
+
},
|
|
1425
1419
|
}).then(resp => {
|
|
1426
1420
|
if (resp.success) {
|
|
1427
1421
|
const spc = getOrganizationSpace(organization.id, space.id);
|
|
@@ -1441,7 +1435,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1441
1435
|
return [];
|
|
1442
1436
|
};
|
|
1443
1437
|
const refreshOrganizationSpaces = (organizationId) => {
|
|
1444
|
-
return
|
|
1438
|
+
return requestDatalayer({
|
|
1445
1439
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/organizations/${organizationId}`,
|
|
1446
1440
|
method: 'GET',
|
|
1447
1441
|
}).then(resp => {
|
|
@@ -1461,7 +1455,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1461
1455
|
};
|
|
1462
1456
|
const getUserSpaces = () => Array.from(SPACES_FOR_USER_BY_ID.values());
|
|
1463
1457
|
const refreshUserSpaces = () => {
|
|
1464
|
-
return
|
|
1458
|
+
return requestDatalayer({
|
|
1465
1459
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/users/me`,
|
|
1466
1460
|
method: 'GET',
|
|
1467
1461
|
}).then(resp => {
|
|
@@ -1478,7 +1472,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1478
1472
|
const getUserSpace = (userId) => SPACES_FOR_USER_BY_ID.get(userId);
|
|
1479
1473
|
const getUserSpaceByHandle = (userHandle) => SPACES_FOR_USER_BY_HANDLE.get(userHandle);
|
|
1480
1474
|
const refreshUserSpace = (userId, spaceId) => {
|
|
1481
|
-
return
|
|
1475
|
+
return requestDatalayer({
|
|
1482
1476
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${spaceId}/users/${userId}`,
|
|
1483
1477
|
method: 'GET',
|
|
1484
1478
|
}).then(resp => {
|
|
@@ -1494,13 +1488,13 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1494
1488
|
});
|
|
1495
1489
|
};
|
|
1496
1490
|
const updateSpace = (space) => {
|
|
1497
|
-
return
|
|
1491
|
+
return requestDatalayer({
|
|
1498
1492
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${space.id}/users/${user?.id}`,
|
|
1499
1493
|
method: 'PUT',
|
|
1500
1494
|
body: {
|
|
1501
1495
|
name: space.name,
|
|
1502
1496
|
description: space.description,
|
|
1503
|
-
}
|
|
1497
|
+
},
|
|
1504
1498
|
}).then(resp => {
|
|
1505
1499
|
if (resp.success) {
|
|
1506
1500
|
const spc = getUserSpace(space.id);
|
|
@@ -1513,13 +1507,13 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1513
1507
|
});
|
|
1514
1508
|
};
|
|
1515
1509
|
const addMemberToOrganizationSpace = (organizationId, spaceId, accountId) => {
|
|
1516
|
-
return
|
|
1510
|
+
return requestDatalayer({
|
|
1517
1511
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${spaceId}/organizations/${organizationId}/members/${accountId}`,
|
|
1518
1512
|
method: 'POST',
|
|
1519
1513
|
});
|
|
1520
1514
|
};
|
|
1521
1515
|
const removeMemberFromOrganizationSpace = (organizationId, spaceId, accountId) => {
|
|
1522
|
-
return
|
|
1516
|
+
return requestDatalayer({
|
|
1523
1517
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${spaceId}/organizations/${organizationId}/members/${accountId}`,
|
|
1524
1518
|
method: 'DELETE',
|
|
1525
1519
|
}).then(resp => {
|
|
@@ -1530,13 +1524,13 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1530
1524
|
});
|
|
1531
1525
|
};
|
|
1532
1526
|
const makeSpacePublic = (spaceId) => {
|
|
1533
|
-
return
|
|
1527
|
+
return requestDatalayer({
|
|
1534
1528
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${spaceId}/public`,
|
|
1535
1529
|
method: 'PUT',
|
|
1536
1530
|
});
|
|
1537
1531
|
};
|
|
1538
1532
|
const makeSpacePrivate = (spaceId) => {
|
|
1539
|
-
return
|
|
1533
|
+
return requestDatalayer({
|
|
1540
1534
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${spaceId}/private`,
|
|
1541
1535
|
method: 'PUT',
|
|
1542
1536
|
});
|
|
@@ -1608,7 +1602,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1608
1602
|
onboarding: BOOTSTRAP_USER_ONBOARDING,
|
|
1609
1603
|
linkedContactId: undefined,
|
|
1610
1604
|
events: [],
|
|
1611
|
-
settings: {}
|
|
1605
|
+
settings: {},
|
|
1612
1606
|
};
|
|
1613
1607
|
USERS_BY_ID.set(instructor.id, instructor);
|
|
1614
1608
|
}
|
|
@@ -1628,7 +1622,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1628
1622
|
raw_item_uids = raw_item_uids.replace('(', '').replace(')', '');
|
|
1629
1623
|
itemIds = raw_item_uids.split(' ');
|
|
1630
1624
|
}
|
|
1631
|
-
|
|
1625
|
+
const items = new Array();
|
|
1632
1626
|
if (raw_course.items) {
|
|
1633
1627
|
raw_course.items.forEach(item => {
|
|
1634
1628
|
const i = toItem(item);
|
|
@@ -1639,7 +1633,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1639
1633
|
id: raw_course.uid,
|
|
1640
1634
|
handle: raw_course.handle_s,
|
|
1641
1635
|
type: 'space',
|
|
1642
|
-
variant:
|
|
1636
|
+
variant: 'course',
|
|
1643
1637
|
name: raw_course.name_t,
|
|
1644
1638
|
description: raw_course.description_t,
|
|
1645
1639
|
creationDate: new Date(raw_course.creation_ts_dt),
|
|
@@ -1655,17 +1649,17 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1655
1649
|
};
|
|
1656
1650
|
const getCourse = (courseId) => COURSES_BY_ID.get(courseId);
|
|
1657
1651
|
const updateCourse = (courseId, name, description) => {
|
|
1658
|
-
return
|
|
1652
|
+
return requestDatalayer({
|
|
1659
1653
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/courses/${courseId}`,
|
|
1660
1654
|
method: 'PUT',
|
|
1661
1655
|
body: {
|
|
1662
1656
|
name,
|
|
1663
1657
|
description,
|
|
1664
|
-
}
|
|
1658
|
+
},
|
|
1665
1659
|
});
|
|
1666
1660
|
};
|
|
1667
1661
|
const refreshCourse = (courseId) => {
|
|
1668
|
-
return
|
|
1662
|
+
return requestDatalayer({
|
|
1669
1663
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/courses/${courseId}`,
|
|
1670
1664
|
method: 'GET',
|
|
1671
1665
|
}).then(resp => {
|
|
@@ -1679,13 +1673,13 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1679
1673
|
});
|
|
1680
1674
|
};
|
|
1681
1675
|
const enrollStudentToCourse = (courseId, studentId) => {
|
|
1682
|
-
return
|
|
1676
|
+
return requestDatalayer({
|
|
1683
1677
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/courses/${courseId}/enrollments/students/${studentId}`,
|
|
1684
1678
|
method: 'POST',
|
|
1685
1679
|
});
|
|
1686
1680
|
};
|
|
1687
1681
|
const removeStudentFromCourse = (courseId, studentId) => {
|
|
1688
|
-
return
|
|
1682
|
+
return requestDatalayer({
|
|
1689
1683
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/courses/${courseId}/enrollments/students/${studentId}`,
|
|
1690
1684
|
method: 'DELETE',
|
|
1691
1685
|
}).then(resp => {
|
|
@@ -1697,7 +1691,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1697
1691
|
};
|
|
1698
1692
|
const getStudent = (courseId, studentId) => STUDENTS_BY_ID.get(courseId + '-' + studentId);
|
|
1699
1693
|
const refreshStudent = (courseId, studentHandle) => {
|
|
1700
|
-
return
|
|
1694
|
+
return requestDatalayer({
|
|
1701
1695
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/courses/${courseId}/enrollments/students/${studentHandle}`,
|
|
1702
1696
|
method: 'GET',
|
|
1703
1697
|
}).then(resp => {
|
|
@@ -1709,7 +1703,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1709
1703
|
};
|
|
1710
1704
|
const getPublicCourses = () => Array.from(PUBLIC_COURSES_BY_ID.values());
|
|
1711
1705
|
const refreshPublicCourses = () => {
|
|
1712
|
-
return
|
|
1706
|
+
return requestDatalayer({
|
|
1713
1707
|
url: `${configuration.libraryRunUrl}/api/library/v1/courses/public`,
|
|
1714
1708
|
method: 'GET',
|
|
1715
1709
|
}).then(resp => {
|
|
@@ -1723,7 +1717,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1723
1717
|
};
|
|
1724
1718
|
const getInstructorCourses = () => Array.from(COURSES_INSTRUCTORS_BY_ID.values());
|
|
1725
1719
|
const refreshInstructorCourses = () => {
|
|
1726
|
-
return
|
|
1720
|
+
return requestDatalayer({
|
|
1727
1721
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/instructors/${user?.id}/courses`,
|
|
1728
1722
|
method: 'GET',
|
|
1729
1723
|
}).then(resp => {
|
|
@@ -1737,7 +1731,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1737
1731
|
};
|
|
1738
1732
|
const getCoursesEnrollments = () => Array.from(COURSES_ENROLLMENTS_BY_ID.values());
|
|
1739
1733
|
const refreshCoursesEnrollments = () => {
|
|
1740
|
-
return
|
|
1734
|
+
return requestDatalayer({
|
|
1741
1735
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/courses/enrollments/me`,
|
|
1742
1736
|
method: 'GET',
|
|
1743
1737
|
}).then(resp => {
|
|
@@ -1750,26 +1744,26 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1750
1744
|
});
|
|
1751
1745
|
};
|
|
1752
1746
|
const confirmCourseItemCompletion = (courseId, itemType, itemId, completed) => {
|
|
1753
|
-
return
|
|
1747
|
+
return requestDatalayer({
|
|
1754
1748
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/assignments/${courseId}/types/${itemType}/items/${itemId}/complete`,
|
|
1755
1749
|
method: 'PUT',
|
|
1756
1750
|
body: {
|
|
1757
1751
|
completed,
|
|
1758
|
-
}
|
|
1752
|
+
},
|
|
1759
1753
|
});
|
|
1760
1754
|
};
|
|
1761
1755
|
const setCourseItems = (courseId, itemIds) => {
|
|
1762
|
-
return
|
|
1756
|
+
return requestDatalayer({
|
|
1763
1757
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/courses/${courseId}/items`,
|
|
1764
1758
|
method: 'PUT',
|
|
1765
1759
|
body: {
|
|
1766
1760
|
itemIds,
|
|
1767
|
-
}
|
|
1761
|
+
},
|
|
1768
1762
|
});
|
|
1769
1763
|
};
|
|
1770
1764
|
// Surveys ---------------------------------------------------------------------
|
|
1771
1765
|
const getUserSurveys = (userId) => {
|
|
1772
|
-
return
|
|
1766
|
+
return requestDatalayer({
|
|
1773
1767
|
url: `${configuration.growthRunUrl}/api/growth/v1/surveys/users/${userId}`,
|
|
1774
1768
|
method: 'GET',
|
|
1775
1769
|
}).then(resp => {
|
|
@@ -1795,7 +1789,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1795
1789
|
const getInbound = (id) => INBOUNDS_BY_ID.get(id);
|
|
1796
1790
|
const getInboundByHandle = (handle) => INBOUNDS_BY_HANDLE.get(handle);
|
|
1797
1791
|
const refreshInbound = (userId) => {
|
|
1798
|
-
return
|
|
1792
|
+
return requestDatalayer({
|
|
1799
1793
|
url: `${configuration.inboundsRunUrl}/api/inbounds/v1/inbounds/${userId}`,
|
|
1800
1794
|
method: 'GET',
|
|
1801
1795
|
}).then(resp => {
|
|
@@ -1806,7 +1800,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1806
1800
|
});
|
|
1807
1801
|
};
|
|
1808
1802
|
const getInbounds = () => {
|
|
1809
|
-
return
|
|
1803
|
+
return requestDatalayer({
|
|
1810
1804
|
url: `${configuration.inboundsRunUrl}/api/inbounds/v1/inbounds`,
|
|
1811
1805
|
method: 'GET',
|
|
1812
1806
|
}).then(resp => {
|
|
@@ -1827,7 +1821,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1827
1821
|
};
|
|
1828
1822
|
const getOutbound = (id) => OUTBOUNDS_BY_ID.get(id);
|
|
1829
1823
|
const refreshOutbound = (outboundId) => {
|
|
1830
|
-
return
|
|
1824
|
+
return requestDatalayer({
|
|
1831
1825
|
url: `${configuration.growthRunUrl}/api/growth/v1/outbounds/${outboundId}`,
|
|
1832
1826
|
method: 'GET',
|
|
1833
1827
|
}).then(resp => {
|
|
@@ -1839,7 +1833,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1839
1833
|
});
|
|
1840
1834
|
};
|
|
1841
1835
|
const getOutbounds = () => {
|
|
1842
|
-
return
|
|
1836
|
+
return requestDatalayer({
|
|
1843
1837
|
url: `${configuration.growthRunUrl}/api/growth/v1/outbounds`,
|
|
1844
1838
|
method: 'GET',
|
|
1845
1839
|
}).then(resp => {
|
|
@@ -1851,28 +1845,28 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1851
1845
|
});
|
|
1852
1846
|
};
|
|
1853
1847
|
const draftBulkEmailsOutbounds = (params) => {
|
|
1854
|
-
return
|
|
1848
|
+
return requestDatalayer({
|
|
1855
1849
|
url: `${configuration.growthRunUrl}/api/growth/v1/outbounds/emails/bulk/draft`,
|
|
1856
1850
|
method: 'POST',
|
|
1857
1851
|
body: params,
|
|
1858
1852
|
});
|
|
1859
1853
|
};
|
|
1860
1854
|
const tryBulkEmailsOutbounds = (outboundId) => {
|
|
1861
|
-
return
|
|
1855
|
+
return requestDatalayer({
|
|
1862
1856
|
url: `${configuration.growthRunUrl}/api/growth/v1/outbounds/${outboundId}/try`,
|
|
1863
1857
|
method: 'POST',
|
|
1864
1858
|
body: {},
|
|
1865
1859
|
});
|
|
1866
1860
|
};
|
|
1867
1861
|
const launchBulkEmailsOutbounds = (outboundId) => {
|
|
1868
|
-
return
|
|
1862
|
+
return requestDatalayer({
|
|
1869
1863
|
url: `${configuration.growthRunUrl}/api/growth/v1/outbounds/${outboundId}/launch`,
|
|
1870
1864
|
method: 'POST',
|
|
1871
1865
|
body: {},
|
|
1872
1866
|
});
|
|
1873
1867
|
};
|
|
1874
1868
|
const sendOutboundEmailToUser = (userId, recipient, subject, content) => {
|
|
1875
|
-
return
|
|
1869
|
+
return requestDatalayer({
|
|
1876
1870
|
url: `${configuration.growthRunUrl}/api/growth/v1/outbounds/email`,
|
|
1877
1871
|
method: 'POST',
|
|
1878
1872
|
body: {
|
|
@@ -1884,19 +1878,19 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1884
1878
|
});
|
|
1885
1879
|
};
|
|
1886
1880
|
const enableUserMFA = () => {
|
|
1887
|
-
return
|
|
1881
|
+
return requestDatalayer({
|
|
1888
1882
|
url: `${configuration.iamRunUrl}/api/iam/v1/mfa`,
|
|
1889
1883
|
method: 'PUT',
|
|
1890
1884
|
});
|
|
1891
1885
|
};
|
|
1892
1886
|
const disableUserMFA = () => {
|
|
1893
|
-
return
|
|
1887
|
+
return requestDatalayer({
|
|
1894
1888
|
url: `${configuration.iamRunUrl}/api/iam/v1/mfa`,
|
|
1895
1889
|
method: 'DELETE',
|
|
1896
1890
|
});
|
|
1897
1891
|
};
|
|
1898
1892
|
const validateUserMFACode = (userUid, code) => {
|
|
1899
|
-
return
|
|
1893
|
+
return requestDatalayer({
|
|
1900
1894
|
url: `${configuration.iamRunUrl}/api/iam/v1/mfa`,
|
|
1901
1895
|
method: 'POST',
|
|
1902
1896
|
body: {
|
|
@@ -1906,31 +1900,31 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1906
1900
|
});
|
|
1907
1901
|
};
|
|
1908
1902
|
const subscribeUserToOutbounds = (userId) => {
|
|
1909
|
-
return
|
|
1903
|
+
return requestDatalayer({
|
|
1910
1904
|
url: `${configuration.iamRunUrl}/api/iam/v1/outbounds/users/${userId}`,
|
|
1911
1905
|
method: 'PUT',
|
|
1912
1906
|
});
|
|
1913
1907
|
};
|
|
1914
1908
|
const unsubscribeUserFromOutbounds = (userId) => {
|
|
1915
|
-
return
|
|
1909
|
+
return requestDatalayer({
|
|
1916
1910
|
url: `${configuration.iamRunUrl}/api/iam/v1/outbounds/users/${userId}`,
|
|
1917
1911
|
method: 'DELETE',
|
|
1918
1912
|
});
|
|
1919
1913
|
};
|
|
1920
1914
|
const unsubscribeContactFromOutbounds = (contactId) => {
|
|
1921
|
-
return
|
|
1915
|
+
return requestDatalayer({
|
|
1922
1916
|
url: `${configuration.growthRunUrl}/api/growth/v1/contacts/unsubscribe/${contactId}`,
|
|
1923
1917
|
method: 'GET',
|
|
1924
1918
|
});
|
|
1925
1919
|
};
|
|
1926
1920
|
const unsubscribeInviteeFromOutbounds = (token) => {
|
|
1927
|
-
return
|
|
1921
|
+
return requestDatalayer({
|
|
1928
1922
|
url: `${configuration.growthRunUrl}/api/growth/v1/outbounds/unsubscribe/${token}`,
|
|
1929
1923
|
method: 'GET',
|
|
1930
1924
|
});
|
|
1931
1925
|
};
|
|
1932
1926
|
const deleteOutbound = (outboundId) => {
|
|
1933
|
-
return
|
|
1927
|
+
return requestDatalayer({
|
|
1934
1928
|
url: `${configuration.growthRunUrl}/api/growth/v1/outbounds/${outboundId}`,
|
|
1935
1929
|
method: 'DELETE',
|
|
1936
1930
|
});
|
|
@@ -1938,7 +1932,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1938
1932
|
// Items --------------------------------------------------------------
|
|
1939
1933
|
const toItem = (item) => {
|
|
1940
1934
|
if (!item.type_s) {
|
|
1941
|
-
console.error(
|
|
1935
|
+
console.error('No type_s found on item', item);
|
|
1942
1936
|
return {};
|
|
1943
1937
|
}
|
|
1944
1938
|
switch (item.type_s) {
|
|
@@ -1965,7 +1959,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1965
1959
|
const clearCachedPublicItems = () => PUBLIC_ITEMS_BY_ID.clear();
|
|
1966
1960
|
const getPublicItems = () => Array.from(PUBLIC_ITEMS_BY_ID.values());
|
|
1967
1961
|
const refreshPublicItems = () => {
|
|
1968
|
-
return
|
|
1962
|
+
return requestDatalayer({
|
|
1969
1963
|
url: `${configuration.libraryRunUrl}/api/library/v1/items/public`,
|
|
1970
1964
|
method: 'GET',
|
|
1971
1965
|
}).then(resp => {
|
|
@@ -1980,7 +1974,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1980
1974
|
};
|
|
1981
1975
|
const getSpaceItems = () => Array.from(SPACE_ITEMS_CACHE.values());
|
|
1982
1976
|
const refreshSpaceItems = (spaceId) => {
|
|
1983
|
-
return
|
|
1977
|
+
return requestDatalayer({
|
|
1984
1978
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${spaceId}/items`,
|
|
1985
1979
|
method: 'GET',
|
|
1986
1980
|
}).then(resp => {
|
|
@@ -1996,19 +1990,19 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1996
1990
|
});
|
|
1997
1991
|
};
|
|
1998
1992
|
const makeItemPublic = (id) => {
|
|
1999
|
-
return
|
|
1993
|
+
return requestDatalayer({
|
|
2000
1994
|
url: `${configuration.libraryRunUrl}/api/library/v1/items/${id}/public`,
|
|
2001
1995
|
method: 'PUT',
|
|
2002
1996
|
});
|
|
2003
1997
|
};
|
|
2004
1998
|
const makeItemPrivate = (id) => {
|
|
2005
|
-
return
|
|
1999
|
+
return requestDatalayer({
|
|
2006
2000
|
url: `${configuration.libraryRunUrl}/api/library/v1/items/${id}/private`,
|
|
2007
2001
|
method: 'PUT',
|
|
2008
2002
|
});
|
|
2009
2003
|
};
|
|
2010
2004
|
const deleteItem = (itemId) => {
|
|
2011
|
-
return
|
|
2005
|
+
return requestDatalayer({
|
|
2012
2006
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/items/${itemId}`,
|
|
2013
2007
|
method: 'DELETE',
|
|
2014
2008
|
}).then(resp => {
|
|
@@ -2035,7 +2029,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2035
2029
|
max: max.toFixed(0).toString(),
|
|
2036
2030
|
public: 'true',
|
|
2037
2031
|
};
|
|
2038
|
-
return
|
|
2032
|
+
return requestDatalayer({
|
|
2039
2033
|
url: `${configuration.libraryRunUrl}/api/library/v1/search${URLExt.objectToQueryString(queryArgs)}`,
|
|
2040
2034
|
method: 'GET',
|
|
2041
2035
|
}).then(resp => {
|
|
@@ -2051,7 +2045,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2051
2045
|
});
|
|
2052
2046
|
};
|
|
2053
2047
|
// Datasets ------------------------------------------------------------------
|
|
2054
|
-
const toDataset =
|
|
2048
|
+
const toDataset = raw_dataset => {
|
|
2055
2049
|
const owner = newUserMock();
|
|
2056
2050
|
USERS_BY_ID.set(owner.id, owner);
|
|
2057
2051
|
const dataset = {
|
|
@@ -2068,21 +2062,23 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2068
2062
|
cdnUrl: raw_dataset.cdn_url_s,
|
|
2069
2063
|
creationDate: new Date(raw_dataset.creation_ts_dt),
|
|
2070
2064
|
public: raw_dataset.public_b ?? false,
|
|
2071
|
-
lastPublicationDate: raw_dataset.creation_ts_dt
|
|
2065
|
+
lastPublicationDate: raw_dataset.creation_ts_dt
|
|
2066
|
+
? new Date(raw_dataset.creation_ts_dt)
|
|
2067
|
+
: undefined,
|
|
2072
2068
|
owner,
|
|
2073
2069
|
space: {
|
|
2074
2070
|
handle: raw_dataset.handle_s,
|
|
2075
2071
|
},
|
|
2076
2072
|
organization: {
|
|
2077
2073
|
handle: raw_dataset.handle_s,
|
|
2078
|
-
}
|
|
2074
|
+
},
|
|
2079
2075
|
};
|
|
2080
2076
|
SPACE_DATASETS_BY_ID.set(dataset.id, dataset);
|
|
2081
2077
|
return dataset;
|
|
2082
2078
|
};
|
|
2083
|
-
const getDataset =
|
|
2079
|
+
const getDataset = id => SPACE_DATASETS_BY_ID.get(id);
|
|
2084
2080
|
const refreshDataset = (id) => {
|
|
2085
|
-
return
|
|
2081
|
+
return requestDatalayer({
|
|
2086
2082
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/items/${id}`,
|
|
2087
2083
|
method: 'GET',
|
|
2088
2084
|
}).then(resp => {
|
|
@@ -2098,7 +2094,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2098
2094
|
const getSpaceDatasets = () => Array.from(SPACE_DATASETS_BY_ID.values());
|
|
2099
2095
|
const refreshSpaceDatasets = (space, organization) => {
|
|
2100
2096
|
const url = `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${space.id}/items/types/dataset`;
|
|
2101
|
-
return
|
|
2097
|
+
return requestDatalayer({
|
|
2102
2098
|
url,
|
|
2103
2099
|
method: 'GET',
|
|
2104
2100
|
}).then(resp => {
|
|
@@ -2111,17 +2107,17 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2111
2107
|
});
|
|
2112
2108
|
};
|
|
2113
2109
|
const updateDataset = (id, name, description) => {
|
|
2114
|
-
return
|
|
2110
|
+
return requestDatalayer({
|
|
2115
2111
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/datasets/${id}`,
|
|
2116
2112
|
method: 'PUT',
|
|
2117
2113
|
body: {
|
|
2118
2114
|
name,
|
|
2119
2115
|
description,
|
|
2120
|
-
}
|
|
2116
|
+
},
|
|
2121
2117
|
});
|
|
2122
2118
|
};
|
|
2123
2119
|
// Cells ------------------------------------------------------------------
|
|
2124
|
-
const toCell =
|
|
2120
|
+
const toCell = cl => {
|
|
2125
2121
|
const owner = newUserMock();
|
|
2126
2122
|
USERS_BY_ID.set(owner.id, owner);
|
|
2127
2123
|
const cell = {
|
|
@@ -2132,7 +2128,9 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2132
2128
|
source: cl.source_t,
|
|
2133
2129
|
creationDate: new Date(cl.creation_ts_dt),
|
|
2134
2130
|
public: cl.public_b ?? false,
|
|
2135
|
-
lastPublicationDate: cl.last_publication_ts_dt
|
|
2131
|
+
lastPublicationDate: cl.last_publication_ts_dt
|
|
2132
|
+
? new Date(cl.last_publication_ts_dt)
|
|
2133
|
+
: undefined,
|
|
2136
2134
|
outputshotUrl: cl.outputshot_url_s || '',
|
|
2137
2135
|
outputshotData: OUTPUTSHOT_PLACEHOLDER_DEFAULT_SVG,
|
|
2138
2136
|
owner,
|
|
@@ -2148,7 +2146,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2148
2146
|
};
|
|
2149
2147
|
const getCell = (id) => SPACE_CELLS_BY_ID.get(id);
|
|
2150
2148
|
const refreshCell = (id) => {
|
|
2151
|
-
return
|
|
2149
|
+
return requestDatalayer({
|
|
2152
2150
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/items/${id}`,
|
|
2153
2151
|
method: 'GET',
|
|
2154
2152
|
}).then(resp => {
|
|
@@ -2164,7 +2162,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2164
2162
|
const getSpaceCells = () => Array.from(SPACE_CELLS_BY_ID.values());
|
|
2165
2163
|
const refreshSpaceCells = (space, organization) => {
|
|
2166
2164
|
const url = `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${space.id}/items/types/cell`;
|
|
2167
|
-
return
|
|
2165
|
+
return requestDatalayer({
|
|
2168
2166
|
url,
|
|
2169
2167
|
method: 'GET',
|
|
2170
2168
|
}).then(resp => {
|
|
@@ -2177,14 +2175,14 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2177
2175
|
});
|
|
2178
2176
|
};
|
|
2179
2177
|
const updateCell = (cell) => {
|
|
2180
|
-
return
|
|
2178
|
+
return requestDatalayer({
|
|
2181
2179
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/cells/${cell.id}`,
|
|
2182
2180
|
method: 'PUT',
|
|
2183
|
-
body: cell
|
|
2181
|
+
body: cell,
|
|
2184
2182
|
});
|
|
2185
2183
|
};
|
|
2186
2184
|
const cloneCell = (cellId) => {
|
|
2187
|
-
return
|
|
2185
|
+
return requestDatalayer({
|
|
2188
2186
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/cells/${cellId}/clone`,
|
|
2189
2187
|
method: 'POST',
|
|
2190
2188
|
}).then(resp => {
|
|
@@ -2195,7 +2193,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2195
2193
|
});
|
|
2196
2194
|
};
|
|
2197
2195
|
// Notebooks ------------------------------------------------------------------
|
|
2198
|
-
const toNotebook =
|
|
2196
|
+
const toNotebook = raw_notebook => {
|
|
2199
2197
|
const owner = newUserMock();
|
|
2200
2198
|
USERS_BY_ID.set(owner.id, owner);
|
|
2201
2199
|
const notebook = {
|
|
@@ -2203,11 +2201,17 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2203
2201
|
type: 'notebook',
|
|
2204
2202
|
name: raw_notebook.name_t,
|
|
2205
2203
|
description: raw_notebook.description_t,
|
|
2206
|
-
nbformat: raw_notebook.model_s
|
|
2204
|
+
nbformat: raw_notebook.model_s
|
|
2205
|
+
? JSON.parse(raw_notebook.model_s)
|
|
2206
|
+
: undefined,
|
|
2207
2207
|
public: raw_notebook.public_b ?? false,
|
|
2208
2208
|
creationDate: new Date(raw_notebook.creation_ts_dt),
|
|
2209
|
-
lastUpdateDate: raw_notebook.last_update_ts_dt
|
|
2210
|
-
|
|
2209
|
+
lastUpdateDate: raw_notebook.last_update_ts_dt
|
|
2210
|
+
? new Date(raw_notebook.last_update_ts_dt)
|
|
2211
|
+
: undefined,
|
|
2212
|
+
lastPublicationDate: raw_notebook.creation_ts_dt
|
|
2213
|
+
? new Date(raw_notebook.creation_ts_dt)
|
|
2214
|
+
: undefined,
|
|
2211
2215
|
datasets: [],
|
|
2212
2216
|
owner,
|
|
2213
2217
|
space: {
|
|
@@ -2215,14 +2219,14 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2215
2219
|
},
|
|
2216
2220
|
organization: {
|
|
2217
2221
|
handle: raw_notebook.handle_s,
|
|
2218
|
-
}
|
|
2222
|
+
},
|
|
2219
2223
|
};
|
|
2220
2224
|
SPACE_NOTEBOOKS_BY_ID.set(notebook.id, notebook);
|
|
2221
2225
|
return notebook;
|
|
2222
2226
|
};
|
|
2223
|
-
const getNotebook =
|
|
2227
|
+
const getNotebook = notebookId => SPACE_NOTEBOOKS_BY_ID.get(notebookId);
|
|
2224
2228
|
const refreshNotebook = (notebookId) => {
|
|
2225
|
-
return
|
|
2229
|
+
return requestDatalayer({
|
|
2226
2230
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/notebooks/${notebookId}`,
|
|
2227
2231
|
method: 'GET',
|
|
2228
2232
|
}).then(resp => {
|
|
@@ -2236,10 +2240,10 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2236
2240
|
});
|
|
2237
2241
|
};
|
|
2238
2242
|
const getSpaceNotebooks = () => Array.from(SPACE_NOTEBOOKS_BY_ID.values());
|
|
2239
|
-
const getSpaceNotebook =
|
|
2243
|
+
const getSpaceNotebook = id => SPACE_NOTEBOOKS_BY_ID.get(id);
|
|
2240
2244
|
const refreshSpaceNotebooks = (space, organization) => {
|
|
2241
2245
|
const url = `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${space.id}/items/types/notebook`;
|
|
2242
|
-
return
|
|
2246
|
+
return requestDatalayer({
|
|
2243
2247
|
url,
|
|
2244
2248
|
method: 'GET',
|
|
2245
2249
|
}).then(resp => {
|
|
@@ -2252,7 +2256,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2252
2256
|
});
|
|
2253
2257
|
};
|
|
2254
2258
|
const cloneNotebook = (notebookId) => {
|
|
2255
|
-
return
|
|
2259
|
+
return requestDatalayer({
|
|
2256
2260
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/notebooks/${notebookId}/clone`,
|
|
2257
2261
|
method: 'POST',
|
|
2258
2262
|
}).then(resp => {
|
|
@@ -2262,27 +2266,48 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2262
2266
|
return resp;
|
|
2263
2267
|
});
|
|
2264
2268
|
};
|
|
2269
|
+
const createNotebook = async (spaceId, name, description, notebookType = 'notebook') => {
|
|
2270
|
+
// Create FormData for the upload
|
|
2271
|
+
const formData = new FormData();
|
|
2272
|
+
formData.append('spaceId', spaceId);
|
|
2273
|
+
formData.append('notebookType', notebookType);
|
|
2274
|
+
formData.append('name', name);
|
|
2275
|
+
formData.append('description', description || '');
|
|
2276
|
+
try {
|
|
2277
|
+
const resp = await uploadNotebook(formData);
|
|
2278
|
+
if (resp.success) {
|
|
2279
|
+
if (resp.notebook) {
|
|
2280
|
+
toNotebook(resp.notebook);
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
return resp;
|
|
2284
|
+
}
|
|
2285
|
+
catch (error) {
|
|
2286
|
+
console.error('Failed to create notebook:', error);
|
|
2287
|
+
return { success: false, error };
|
|
2288
|
+
}
|
|
2289
|
+
};
|
|
2265
2290
|
const updateNotebook = (id, name, description) => {
|
|
2266
|
-
return
|
|
2291
|
+
return requestDatalayer({
|
|
2267
2292
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/notebooks/${id}`,
|
|
2268
2293
|
method: 'PUT',
|
|
2269
2294
|
body: {
|
|
2270
2295
|
name,
|
|
2271
2296
|
description,
|
|
2272
|
-
}
|
|
2297
|
+
},
|
|
2273
2298
|
});
|
|
2274
2299
|
};
|
|
2275
2300
|
const updateNotebookModel = (notebookId, nbformat) => {
|
|
2276
|
-
return
|
|
2301
|
+
return requestDatalayer({
|
|
2277
2302
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/notebooks/${notebookId}/model`,
|
|
2278
2303
|
method: 'PUT',
|
|
2279
2304
|
body: {
|
|
2280
2305
|
nbformat,
|
|
2281
|
-
}
|
|
2306
|
+
},
|
|
2282
2307
|
});
|
|
2283
2308
|
};
|
|
2284
2309
|
// Documents ------------------------------------------------------------------
|
|
2285
|
-
const toDocument =
|
|
2310
|
+
const toDocument = doc => {
|
|
2286
2311
|
const owner = newUserMock();
|
|
2287
2312
|
USERS_BY_ID.set(owner.id, owner);
|
|
2288
2313
|
const document = {
|
|
@@ -2293,22 +2318,26 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2293
2318
|
model: doc.model_s ? JSON.parse(doc.model_s) : undefined,
|
|
2294
2319
|
public: doc.public_b ?? false,
|
|
2295
2320
|
creationDate: new Date(doc.creation_ts_dt),
|
|
2296
|
-
lastUpdateDate: doc.last_update_ts_dt
|
|
2297
|
-
|
|
2321
|
+
lastUpdateDate: doc.last_update_ts_dt
|
|
2322
|
+
? new Date(doc.last_update_ts_dt)
|
|
2323
|
+
: undefined,
|
|
2324
|
+
lastPublicationDate: doc.creation_ts_dt
|
|
2325
|
+
? new Date(doc.creation_ts_dt)
|
|
2326
|
+
: undefined,
|
|
2298
2327
|
owner,
|
|
2299
2328
|
space: {
|
|
2300
2329
|
handle: doc.handle_s,
|
|
2301
2330
|
},
|
|
2302
2331
|
organization: {
|
|
2303
2332
|
handle: doc.handle_s,
|
|
2304
|
-
}
|
|
2333
|
+
},
|
|
2305
2334
|
};
|
|
2306
2335
|
SPACE_DOCUMENTS_BY_ID.set(document.id, document);
|
|
2307
2336
|
return document;
|
|
2308
2337
|
};
|
|
2309
|
-
const getDocument =
|
|
2338
|
+
const getDocument = id => SPACE_DOCUMENTS_BY_ID.get(id);
|
|
2310
2339
|
const refreshDocument = (id) => {
|
|
2311
|
-
return
|
|
2340
|
+
return requestDatalayer({
|
|
2312
2341
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/lexicals/${id}`,
|
|
2313
2342
|
method: 'GET',
|
|
2314
2343
|
}).then(resp => {
|
|
@@ -2322,10 +2351,10 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2322
2351
|
});
|
|
2323
2352
|
};
|
|
2324
2353
|
const getSpaceDocuments = () => Array.from(SPACE_DOCUMENTS_BY_ID.values());
|
|
2325
|
-
const getSpaceDocument =
|
|
2354
|
+
const getSpaceDocument = id => SPACE_DOCUMENTS_BY_ID.get(id);
|
|
2326
2355
|
const refreshSpaceDocuments = (space, organization) => {
|
|
2327
2356
|
const url = `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${space.id}/items/types/document`;
|
|
2328
|
-
return
|
|
2357
|
+
return requestDatalayer({
|
|
2329
2358
|
url,
|
|
2330
2359
|
method: 'GET',
|
|
2331
2360
|
}).then(resp => {
|
|
@@ -2338,7 +2367,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2338
2367
|
});
|
|
2339
2368
|
};
|
|
2340
2369
|
const cloneDocument = (documentId) => {
|
|
2341
|
-
return
|
|
2370
|
+
return requestDatalayer({
|
|
2342
2371
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/lexicals/${documentId}/clone`,
|
|
2343
2372
|
method: 'POST',
|
|
2344
2373
|
}).then(resp => {
|
|
@@ -2349,22 +2378,22 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2349
2378
|
});
|
|
2350
2379
|
};
|
|
2351
2380
|
const updateDocument = (id, name, description) => {
|
|
2352
|
-
return
|
|
2381
|
+
return requestDatalayer({
|
|
2353
2382
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/lexicals/${id}`,
|
|
2354
2383
|
method: 'PUT',
|
|
2355
2384
|
body: {
|
|
2356
2385
|
name,
|
|
2357
2386
|
description,
|
|
2358
|
-
}
|
|
2387
|
+
},
|
|
2359
2388
|
});
|
|
2360
2389
|
};
|
|
2361
2390
|
const updateDocumentModel = (id, model) => {
|
|
2362
|
-
return
|
|
2391
|
+
return requestDatalayer({
|
|
2363
2392
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/lexicals/${id}/model`,
|
|
2364
2393
|
method: 'PUT',
|
|
2365
2394
|
body: {
|
|
2366
2395
|
model,
|
|
2367
|
-
}
|
|
2396
|
+
},
|
|
2368
2397
|
});
|
|
2369
2398
|
};
|
|
2370
2399
|
// Environments ------------------------------------------------------------------
|
|
@@ -2378,21 +2407,23 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2378
2407
|
description: env.description_t,
|
|
2379
2408
|
creationDate: new Date(env.creation_ts_dt),
|
|
2380
2409
|
public: env.public_b ?? false,
|
|
2381
|
-
lastPublicationDate: env.creation_ts_dt
|
|
2410
|
+
lastPublicationDate: env.creation_ts_dt
|
|
2411
|
+
? new Date(env.creation_ts_dt)
|
|
2412
|
+
: undefined,
|
|
2382
2413
|
owner,
|
|
2383
2414
|
space: {
|
|
2384
2415
|
handle: env.handle_s,
|
|
2385
2416
|
},
|
|
2386
2417
|
organization: {
|
|
2387
2418
|
handle: env.handle_s,
|
|
2388
|
-
}
|
|
2419
|
+
},
|
|
2389
2420
|
};
|
|
2390
2421
|
cache.set(environment.id, environment);
|
|
2391
2422
|
return environment;
|
|
2392
2423
|
};
|
|
2393
2424
|
const getEnvironment = (id) => SPACE_ENVIRONMENTS_BY_ID.get(id);
|
|
2394
2425
|
const refreshEnvironment = (id) => {
|
|
2395
|
-
return
|
|
2426
|
+
return requestDatalayer({
|
|
2396
2427
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/items/${id}`,
|
|
2397
2428
|
method: 'GET',
|
|
2398
2429
|
}).then(resp => {
|
|
@@ -2408,7 +2439,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2408
2439
|
const getSpaceEnvironments = () => Array.from(SPACE_ENVIRONMENTS_BY_ID.values());
|
|
2409
2440
|
const refreshSpaceEnvironments = (space, organization) => {
|
|
2410
2441
|
const url = `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${space.id}/items/types/environment`;
|
|
2411
|
-
return
|
|
2442
|
+
return requestDatalayer({
|
|
2412
2443
|
url,
|
|
2413
2444
|
method: 'GET',
|
|
2414
2445
|
}).then(resp => {
|
|
@@ -2421,7 +2452,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2421
2452
|
});
|
|
2422
2453
|
};
|
|
2423
2454
|
// Lessons ------------------------------------------------------------------
|
|
2424
|
-
const toLesson =
|
|
2455
|
+
const toLesson = raw_lesson => {
|
|
2425
2456
|
const owner = newUserMock();
|
|
2426
2457
|
USERS_BY_ID.set(owner.id, owner);
|
|
2427
2458
|
const lesson = {
|
|
@@ -2432,8 +2463,12 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2432
2463
|
nbformat: raw_lesson.model_s ? JSON.parse(raw_lesson.model_s) : undefined,
|
|
2433
2464
|
public: raw_lesson.public_b ?? false,
|
|
2434
2465
|
creationDate: new Date(raw_lesson.creation_ts_dt),
|
|
2435
|
-
lastUpdateDate: raw_lesson.last_update_ts_dt
|
|
2436
|
-
|
|
2466
|
+
lastUpdateDate: raw_lesson.last_update_ts_dt
|
|
2467
|
+
? new Date(raw_lesson.last_update_ts_dt)
|
|
2468
|
+
: undefined,
|
|
2469
|
+
lastPublicationDate: raw_lesson.creation_ts_dt
|
|
2470
|
+
? new Date(raw_lesson.creation_ts_dt)
|
|
2471
|
+
: undefined,
|
|
2437
2472
|
owner,
|
|
2438
2473
|
space: {
|
|
2439
2474
|
handle: raw_lesson.handle_s,
|
|
@@ -2446,9 +2481,9 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2446
2481
|
SPACE_LESSONS_BY_ID.set(lesson.id, lesson);
|
|
2447
2482
|
return lesson;
|
|
2448
2483
|
};
|
|
2449
|
-
const getLesson =
|
|
2484
|
+
const getLesson = id => SPACE_LESSONS_BY_ID.get(id);
|
|
2450
2485
|
const refreshLesson = (id) => {
|
|
2451
|
-
return
|
|
2486
|
+
return requestDatalayer({
|
|
2452
2487
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/lessons/${id}`,
|
|
2453
2488
|
method: 'GET',
|
|
2454
2489
|
}).then(resp => {
|
|
@@ -2462,10 +2497,10 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2462
2497
|
});
|
|
2463
2498
|
};
|
|
2464
2499
|
const getSpaceLessons = () => Array.from(SPACE_LESSONS_BY_ID.values());
|
|
2465
|
-
const getSpaceLesson =
|
|
2500
|
+
const getSpaceLesson = id => SPACE_LESSONS_BY_ID.get(id);
|
|
2466
2501
|
const refreshSpaceLessons = (space, organization) => {
|
|
2467
2502
|
const url = `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${space.id}/items/types/lesson`;
|
|
2468
|
-
return
|
|
2503
|
+
return requestDatalayer({
|
|
2469
2504
|
url,
|
|
2470
2505
|
method: 'GET',
|
|
2471
2506
|
}).then(resp => {
|
|
@@ -2478,7 +2513,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2478
2513
|
});
|
|
2479
2514
|
};
|
|
2480
2515
|
const cloneLesson = (lessonId) => {
|
|
2481
|
-
return
|
|
2516
|
+
return requestDatalayer({
|
|
2482
2517
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/notebooks/${lessonId}/clone`,
|
|
2483
2518
|
method: 'POST',
|
|
2484
2519
|
}).then(resp => {
|
|
@@ -2504,8 +2539,12 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2504
2539
|
codeTest: ex.code_test_t,
|
|
2505
2540
|
public: ex.public_b ?? false,
|
|
2506
2541
|
creationDate: new Date(ex.creation_ts_dt),
|
|
2507
|
-
lastUpdateDate: ex.last_update_ts_dt
|
|
2508
|
-
|
|
2542
|
+
lastUpdateDate: ex.last_update_ts_dt
|
|
2543
|
+
? new Date(ex.last_update_ts_dt)
|
|
2544
|
+
: undefined,
|
|
2545
|
+
lastPublicationDate: ex.creation_ts_dt
|
|
2546
|
+
? new Date(ex.creation_ts_dt)
|
|
2547
|
+
: undefined,
|
|
2509
2548
|
owner,
|
|
2510
2549
|
space: {
|
|
2511
2550
|
handle: ex.handle_s,
|
|
@@ -2520,7 +2559,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2520
2559
|
};
|
|
2521
2560
|
const getExercise = (id) => SPACE_EXERCISES_BY_ID.get(id);
|
|
2522
2561
|
const refreshExercise = (id) => {
|
|
2523
|
-
return
|
|
2562
|
+
return requestDatalayer({
|
|
2524
2563
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/items/${id}`,
|
|
2525
2564
|
method: 'GET',
|
|
2526
2565
|
}).then(resp => {
|
|
@@ -2538,7 +2577,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2538
2577
|
};
|
|
2539
2578
|
const refreshSpaceExercises = (space, organization) => {
|
|
2540
2579
|
const url = `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${space.id}/items/types/exercise`;
|
|
2541
|
-
return
|
|
2580
|
+
return requestDatalayer({
|
|
2542
2581
|
url,
|
|
2543
2582
|
method: 'GET',
|
|
2544
2583
|
}).then(resp => {
|
|
@@ -2551,7 +2590,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2551
2590
|
});
|
|
2552
2591
|
};
|
|
2553
2592
|
const cloneExercise = (exerciseId) => {
|
|
2554
|
-
return
|
|
2593
|
+
return requestDatalayer({
|
|
2555
2594
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/exercises/${exerciseId}/clone`,
|
|
2556
2595
|
method: 'POST',
|
|
2557
2596
|
}).then(resp => {
|
|
@@ -2562,7 +2601,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2562
2601
|
});
|
|
2563
2602
|
};
|
|
2564
2603
|
const updateExercise = ({ id, name, description, help, codePre, codeSolution, codeQuestion, codeTest, }) => {
|
|
2565
|
-
return
|
|
2604
|
+
return requestDatalayer({
|
|
2566
2605
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/exercises/${id}`,
|
|
2567
2606
|
method: 'PUT',
|
|
2568
2607
|
body: {
|
|
@@ -2573,17 +2612,17 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2573
2612
|
codeSolution,
|
|
2574
2613
|
codeQuestion,
|
|
2575
2614
|
codeTest,
|
|
2576
|
-
}
|
|
2615
|
+
},
|
|
2577
2616
|
});
|
|
2578
2617
|
};
|
|
2579
2618
|
const updateExercisePoints = (id, codeStudent, points) => {
|
|
2580
|
-
return
|
|
2619
|
+
return requestDatalayer({
|
|
2581
2620
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/exercises/${id}/points`,
|
|
2582
2621
|
method: 'PUT',
|
|
2583
2622
|
body: {
|
|
2584
2623
|
codeStudent,
|
|
2585
2624
|
points,
|
|
2586
|
-
}
|
|
2625
|
+
},
|
|
2587
2626
|
});
|
|
2588
2627
|
};
|
|
2589
2628
|
// Assignments ------------------------------------------------------------------
|
|
@@ -2595,7 +2634,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2595
2634
|
raw_assignment.student_items.forEach(student_item => {
|
|
2596
2635
|
studentItem = {
|
|
2597
2636
|
id: student_item.uid,
|
|
2598
|
-
type:
|
|
2637
|
+
type: 'student_item',
|
|
2599
2638
|
itemId: student_item.item_uid,
|
|
2600
2639
|
itemType: student_item.item_type_s,
|
|
2601
2640
|
nbgrades: student_item.nbgrades,
|
|
@@ -2610,11 +2649,17 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2610
2649
|
type: 'assignment',
|
|
2611
2650
|
name: raw_assignment.name_t,
|
|
2612
2651
|
description: raw_assignment.description_t,
|
|
2613
|
-
nbformat: raw_assignment.model_s
|
|
2652
|
+
nbformat: raw_assignment.model_s
|
|
2653
|
+
? JSON.parse(raw_assignment.model_s)
|
|
2654
|
+
: undefined,
|
|
2614
2655
|
public: raw_assignment.public_b ?? false,
|
|
2615
2656
|
creationDate: new Date(raw_assignment.creation_ts_dt),
|
|
2616
|
-
lastUpdateDate: raw_assignment.last_update_ts_dt
|
|
2617
|
-
|
|
2657
|
+
lastUpdateDate: raw_assignment.last_update_ts_dt
|
|
2658
|
+
? new Date(raw_assignment.last_update_ts_dt)
|
|
2659
|
+
: undefined,
|
|
2660
|
+
lastPublicationDate: raw_assignment.creation_ts_dt
|
|
2661
|
+
? new Date(raw_assignment.creation_ts_dt)
|
|
2662
|
+
: undefined,
|
|
2618
2663
|
studentItem,
|
|
2619
2664
|
datasets: [],
|
|
2620
2665
|
owner,
|
|
@@ -2629,9 +2674,9 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2629
2674
|
STUDENT_ASSIGNMENTS_BY_ID.set(assignment.id, assignment);
|
|
2630
2675
|
return assignment;
|
|
2631
2676
|
};
|
|
2632
|
-
const getAssignment =
|
|
2677
|
+
const getAssignment = assignmentId => SPACE_ASSIGNMENTS_BY_ID.get(assignmentId);
|
|
2633
2678
|
const refreshAssignment = (assignmentId) => {
|
|
2634
|
-
return
|
|
2679
|
+
return requestDatalayer({
|
|
2635
2680
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/assignments/${assignmentId}`,
|
|
2636
2681
|
method: 'GET',
|
|
2637
2682
|
}).then(resp => {
|
|
@@ -2646,7 +2691,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2646
2691
|
};
|
|
2647
2692
|
const getAssignmentForStudent = (assignmentId) => STUDENT_ASSIGNMENTS_BY_ID.get(assignmentId);
|
|
2648
2693
|
const refreshAssignmentForStudent = (courseId, user, assignmentId) => {
|
|
2649
|
-
return
|
|
2694
|
+
return requestDatalayer({
|
|
2650
2695
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/assignments/${assignmentId}/courses/${courseId}/students/${user.id}`,
|
|
2651
2696
|
method: 'GET',
|
|
2652
2697
|
}).then(resp => {
|
|
@@ -2660,7 +2705,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2660
2705
|
});
|
|
2661
2706
|
};
|
|
2662
2707
|
const resetAssignmentForStudent = (courseId, user, assignmentId) => {
|
|
2663
|
-
return
|
|
2708
|
+
return requestDatalayer({
|
|
2664
2709
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/assignments/${assignmentId}/reset`,
|
|
2665
2710
|
method: 'POST',
|
|
2666
2711
|
}).then(resp => {
|
|
@@ -2674,12 +2719,12 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2674
2719
|
});
|
|
2675
2720
|
};
|
|
2676
2721
|
const gradeAssignmentForStudent = (courseId, user, assignmentId, model) => {
|
|
2677
|
-
return
|
|
2722
|
+
return requestDatalayer({
|
|
2678
2723
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/assignments/${assignmentId}/students/${user.id}/grade`,
|
|
2679
2724
|
method: 'PUT',
|
|
2680
2725
|
body: {
|
|
2681
2726
|
model,
|
|
2682
|
-
}
|
|
2727
|
+
},
|
|
2683
2728
|
}).then(resp => {
|
|
2684
2729
|
if (resp.success) {
|
|
2685
2730
|
const assignment = resp.assignment;
|
|
@@ -2691,10 +2736,10 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2691
2736
|
});
|
|
2692
2737
|
};
|
|
2693
2738
|
const getSpaceAssignments = () => Array.from(SPACE_ASSIGNMENTS_BY_ID.values());
|
|
2694
|
-
const getSpaceAssignment =
|
|
2739
|
+
const getSpaceAssignment = id => SPACE_ASSIGNMENTS_BY_ID.get(id);
|
|
2695
2740
|
const refreshSpaceAssignments = (space, organization) => {
|
|
2696
2741
|
const url = `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${space.id}/items/types/assignment`;
|
|
2697
|
-
return
|
|
2742
|
+
return requestDatalayer({
|
|
2698
2743
|
url,
|
|
2699
2744
|
method: 'GET',
|
|
2700
2745
|
}).then(resp => {
|
|
@@ -2707,7 +2752,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2707
2752
|
});
|
|
2708
2753
|
};
|
|
2709
2754
|
const cloneAssignment = (assignmentId) => {
|
|
2710
|
-
return
|
|
2755
|
+
return requestDatalayer({
|
|
2711
2756
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/notebooks/${assignmentId}/clone`,
|
|
2712
2757
|
method: 'POST',
|
|
2713
2758
|
}).then(resp => {
|
|
@@ -2717,28 +2762,28 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2717
2762
|
return resp;
|
|
2718
2763
|
});
|
|
2719
2764
|
};
|
|
2720
|
-
const getAssignmentStudentVersion =
|
|
2721
|
-
return
|
|
2765
|
+
const getAssignmentStudentVersion = assignmentId => {
|
|
2766
|
+
return requestDatalayer({
|
|
2722
2767
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/assignments/${assignmentId}/student_version`,
|
|
2723
2768
|
method: 'GET',
|
|
2724
2769
|
});
|
|
2725
2770
|
};
|
|
2726
2771
|
// Prices -------------------------------------------------------------------
|
|
2727
2772
|
const refreshStripePrices = () => {
|
|
2728
|
-
return
|
|
2773
|
+
return requestDatalayer({
|
|
2729
2774
|
url: `${configuration.iamRunUrl}/api/iam/stripe/v1/prices`,
|
|
2730
2775
|
method: 'GET',
|
|
2731
2776
|
});
|
|
2732
2777
|
};
|
|
2733
2778
|
// Checkout -------------------------------------------------------------------
|
|
2734
2779
|
const createCheckoutSession = (product, location) => {
|
|
2735
|
-
return
|
|
2780
|
+
return requestDatalayer({
|
|
2736
2781
|
url: `${configuration.iamRunUrl}/api/iam/stripe/v1/checkout/session`,
|
|
2737
2782
|
method: 'POST',
|
|
2738
2783
|
body: {
|
|
2739
2784
|
price_id: product?.id,
|
|
2740
|
-
return_url: `${location.protocol}//${location.host}${location.pathname.split('/').slice(0, -1).join('/')}
|
|
2741
|
-
}
|
|
2785
|
+
return_url: `${location.protocol}//${location.host}${location.pathname.split('/').slice(0, -1).join('/')}`,
|
|
2786
|
+
},
|
|
2742
2787
|
})
|
|
2743
2788
|
.then(data => data.client_secret)
|
|
2744
2789
|
.catch(error => {
|
|
@@ -2746,40 +2791,40 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2746
2791
|
});
|
|
2747
2792
|
};
|
|
2748
2793
|
// Credits -------------------------------------------------------------------
|
|
2749
|
-
const burnCredit =
|
|
2750
|
-
return
|
|
2794
|
+
const burnCredit = credits => {
|
|
2795
|
+
return requestDatalayer({
|
|
2751
2796
|
url: `${configuration.iamRunUrl}/api/iam/v1/usage/credits`,
|
|
2752
|
-
method:
|
|
2797
|
+
method: 'DELETE',
|
|
2753
2798
|
body: {
|
|
2754
2799
|
credits,
|
|
2755
|
-
}
|
|
2800
|
+
},
|
|
2756
2801
|
});
|
|
2757
2802
|
};
|
|
2758
|
-
const getUserCredits =
|
|
2759
|
-
return
|
|
2803
|
+
const getUserCredits = userId => {
|
|
2804
|
+
return requestDatalayer({
|
|
2760
2805
|
url: `${configuration.iamRunUrl}/api/iam/v1/usage/credits/users/${userId}`,
|
|
2761
|
-
method:
|
|
2806
|
+
method: 'GET',
|
|
2762
2807
|
});
|
|
2763
2808
|
};
|
|
2764
2809
|
const updateUserCredits = (userId, credits, brand) => {
|
|
2765
|
-
return
|
|
2810
|
+
return requestDatalayer({
|
|
2766
2811
|
url: `${configuration.iamRunUrl}/api/iam/v1/usage/credits/users/${userId}`,
|
|
2767
|
-
method:
|
|
2812
|
+
method: 'PUT',
|
|
2768
2813
|
body: {
|
|
2769
2814
|
credits,
|
|
2770
2815
|
brand,
|
|
2771
|
-
}
|
|
2816
|
+
},
|
|
2772
2817
|
});
|
|
2773
2818
|
};
|
|
2774
2819
|
const updateUserCreditsQuota = (userId, quota) => {
|
|
2775
|
-
return
|
|
2820
|
+
return requestDatalayer({
|
|
2776
2821
|
url: `${configuration.iamRunUrl}/api/iam/v1/usage/quota`,
|
|
2777
|
-
method:
|
|
2822
|
+
method: 'PUT',
|
|
2778
2823
|
body: {
|
|
2779
2824
|
user_uid: userId,
|
|
2780
2825
|
quota,
|
|
2781
|
-
reset:
|
|
2782
|
-
}
|
|
2826
|
+
reset: '0',
|
|
2827
|
+
},
|
|
2783
2828
|
});
|
|
2784
2829
|
};
|
|
2785
2830
|
// Usages -------------------------------------------------------------------
|
|
@@ -2787,9 +2832,9 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2787
2832
|
* Get user usages
|
|
2788
2833
|
*/
|
|
2789
2834
|
const getUsages = async () => {
|
|
2790
|
-
const data = await
|
|
2835
|
+
const data = await requestDatalayer({
|
|
2791
2836
|
url: `${configuration.iamRunUrl}/api/iam/v1/usage/user`,
|
|
2792
|
-
method:
|
|
2837
|
+
method: 'GET',
|
|
2793
2838
|
});
|
|
2794
2839
|
data.usages = (data.usages ?? []).map(u => asUsage(u));
|
|
2795
2840
|
return data;
|
|
@@ -2798,9 +2843,9 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2798
2843
|
* Get user usages
|
|
2799
2844
|
*/
|
|
2800
2845
|
const getUsagesForUser = async (userId) => {
|
|
2801
|
-
const data = await
|
|
2846
|
+
const data = await requestDatalayer({
|
|
2802
2847
|
url: `${configuration.iamRunUrl}/api/iam/v1/usage/users/${userId}`,
|
|
2803
|
-
method:
|
|
2848
|
+
method: 'GET',
|
|
2804
2849
|
});
|
|
2805
2850
|
data.usages = (data.usages ?? []).map(u => asUsage(u));
|
|
2806
2851
|
return data;
|
|
@@ -2809,16 +2854,16 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2809
2854
|
* Get platform usages
|
|
2810
2855
|
*/
|
|
2811
2856
|
const getPlatformUsages = async () => {
|
|
2812
|
-
const data = await
|
|
2857
|
+
const data = await requestDatalayer({
|
|
2813
2858
|
url: `${configuration.iamRunUrl}/api/iam/v1/usage/platform`,
|
|
2814
|
-
method:
|
|
2859
|
+
method: 'GET',
|
|
2815
2860
|
});
|
|
2816
2861
|
data.usages = (data.usages ?? []).map(u => asUsage(u));
|
|
2817
2862
|
return data;
|
|
2818
2863
|
};
|
|
2819
2864
|
// Support ------------------------------------------------------------------
|
|
2820
2865
|
const requestPlatformSupport = (subject, message, email, brand) => {
|
|
2821
|
-
return
|
|
2866
|
+
return requestDatalayer({
|
|
2822
2867
|
url: `${configuration.supportRunUrl}/api/support/v1/support/request`,
|
|
2823
2868
|
method: 'POST',
|
|
2824
2869
|
body: {
|
|
@@ -2826,11 +2871,11 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2826
2871
|
message,
|
|
2827
2872
|
email,
|
|
2828
2873
|
brand,
|
|
2829
|
-
}
|
|
2874
|
+
},
|
|
2830
2875
|
});
|
|
2831
2876
|
};
|
|
2832
2877
|
const requestPlatformSupport2 = (accountHandle, firstName, lastName, email, message) => {
|
|
2833
|
-
return
|
|
2878
|
+
return requestDatalayer({
|
|
2834
2879
|
url: `${configuration.supportRunUrl}/api/support/v1/support/request2`,
|
|
2835
2880
|
method: 'POST',
|
|
2836
2881
|
body: {
|
|
@@ -2839,12 +2884,12 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2839
2884
|
lastName,
|
|
2840
2885
|
email,
|
|
2841
2886
|
message,
|
|
2842
|
-
}
|
|
2887
|
+
},
|
|
2843
2888
|
});
|
|
2844
2889
|
};
|
|
2845
2890
|
// Growth ------------------------------------------------------------------
|
|
2846
2891
|
const getGrowthKPI = () => {
|
|
2847
|
-
return
|
|
2892
|
+
return requestDatalayer({
|
|
2848
2893
|
url: `${configuration.growthRunUrl}/api/growth/v1/kpis`,
|
|
2849
2894
|
method: 'GET',
|
|
2850
2895
|
});
|
|
@@ -2876,6 +2921,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2876
2921
|
cloneExercise,
|
|
2877
2922
|
cloneLesson,
|
|
2878
2923
|
cloneNotebook,
|
|
2924
|
+
createNotebook,
|
|
2879
2925
|
confirmCourseItemCompletion,
|
|
2880
2926
|
confirmEmailUpdate,
|
|
2881
2927
|
confirmJoinWithToken,
|
|
@@ -3098,6 +3144,9 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
3098
3144
|
updateUserSettings,
|
|
3099
3145
|
validateUserMFACode,
|
|
3100
3146
|
whoami,
|
|
3147
|
+
notebookUploadLoading,
|
|
3148
|
+
notebookUploadProgress,
|
|
3149
|
+
resetNotebookUpload,
|
|
3101
3150
|
};
|
|
3102
3151
|
};
|
|
3103
3152
|
export default useCache;
|