@datalayer/core 0.0.9 → 0.0.11
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/lib/__tests__/shared/cleanup-shared.d.ts +4 -0
- package/lib/__tests__/shared/cleanup-shared.js +228 -0
- package/lib/__tests__/shared/test-config.d.ts +51 -0
- package/lib/__tests__/shared/test-config.js +110 -0
- package/lib/__tests__/shared/test-constants.d.ts +66 -0
- package/lib/__tests__/shared/test-constants.js +79 -0
- package/lib/api/DatalayerApi.d.ts +1 -1
- package/lib/api/DatalayerApi.js +73 -42
- package/lib/api/__tests__/iam.authentication.integration.test.d.ts +1 -0
- package/lib/api/__tests__/iam.authentication.integration.test.js +247 -0
- package/lib/api/__tests__/iam.healthz.integration.test.d.ts +1 -0
- package/lib/api/__tests__/iam.healthz.integration.test.js +63 -0
- package/lib/api/__tests__/iam.profile.integration.test.d.ts +1 -0
- package/lib/api/__tests__/iam.profile.integration.test.js +252 -0
- package/lib/api/__tests__/runtimes.environments.integration.test.d.ts +1 -0
- package/lib/api/__tests__/runtimes.environments.integration.test.js +122 -0
- package/lib/api/__tests__/runtimes.healthz.integration.test.d.ts +1 -0
- package/lib/api/__tests__/runtimes.healthz.integration.test.js +50 -0
- package/lib/api/__tests__/runtimes.integration.test.d.ts +1 -0
- package/lib/api/__tests__/runtimes.integration.test.js +369 -0
- package/lib/api/__tests__/spacer.healthz.integration.test.d.ts +1 -0
- package/lib/api/__tests__/spacer.healthz.integration.test.js +50 -0
- package/lib/api/__tests__/spacer.integration.test.d.ts +1 -0
- package/lib/api/__tests__/spacer.integration.test.js +519 -0
- package/lib/api/constants.d.ts +19 -0
- package/lib/api/constants.js +23 -0
- package/lib/api/iam/__tests__/authentication.unit.test.d.ts +1 -0
- package/lib/api/iam/__tests__/authentication.unit.test.js +63 -0
- package/lib/api/iam/__tests__/healthz.unit.test.d.ts +1 -0
- package/lib/api/iam/__tests__/healthz.unit.test.js +60 -0
- package/lib/api/iam/__tests__/profile.unit.test.d.ts +1 -0
- package/lib/api/iam/__tests__/profile.unit.test.js +57 -0
- package/lib/api/iam/authentication.d.ts +40 -0
- package/lib/api/iam/authentication.js +128 -0
- package/lib/api/iam/healthz.d.ts +15 -0
- package/lib/api/iam/healthz.js +43 -0
- package/lib/api/iam/index.d.ts +12 -0
- package/lib/api/iam/index.js +17 -0
- package/lib/api/iam/profile.d.ts +15 -0
- package/lib/api/iam/profile.js +41 -0
- package/lib/api/index.d.ts +20 -3
- package/lib/api/index.js +22 -3
- package/lib/api/runtimes/__tests__/environments.unit.test.d.ts +1 -0
- package/lib/api/runtimes/__tests__/environments.unit.test.js +77 -0
- package/lib/api/runtimes/__tests__/healthz.unit.test.d.ts +1 -0
- package/lib/api/runtimes/__tests__/healthz.unit.test.js +57 -0
- package/lib/api/runtimes/__tests__/runtimes.unit.test.d.ts +1 -0
- package/lib/api/runtimes/__tests__/runtimes.unit.test.js +139 -0
- package/lib/api/runtimes/__tests__/snapshots.unit.test.d.ts +1 -0
- package/lib/api/runtimes/__tests__/snapshots.unit.test.js +96 -0
- package/lib/api/runtimes/environments.d.ts +9 -0
- package/lib/api/runtimes/environments.js +28 -0
- package/lib/api/runtimes/healthz.d.ts +25 -0
- package/lib/api/runtimes/healthz.js +43 -0
- package/lib/api/runtimes/index.d.ts +10 -5
- package/lib/api/runtimes/index.js +10 -5
- package/lib/api/runtimes/runtimes.d.ts +54 -0
- package/lib/api/runtimes/runtimes.js +169 -0
- package/lib/api/runtimes/snapshots.d.ts +34 -21
- package/lib/api/runtimes/snapshots.js +69 -138
- package/lib/api/spacer/__tests__/healthz.unit.test.d.ts +1 -0
- package/lib/api/spacer/__tests__/healthz.unit.test.js +57 -0
- package/lib/api/spacer/__tests__/items.unit.test.d.ts +1 -0
- package/lib/api/spacer/__tests__/items.unit.test.js +165 -0
- package/lib/api/spacer/__tests__/lexicals.unit.test.d.ts +1 -0
- package/lib/api/spacer/__tests__/lexicals.unit.test.js +323 -0
- package/lib/api/spacer/__tests__/notebooks.unit.test.d.ts +1 -0
- package/lib/api/spacer/__tests__/notebooks.unit.test.js +224 -0
- package/lib/api/spacer/__tests__/users.unit.test.d.ts +1 -0
- package/lib/api/spacer/__tests__/users.unit.test.js +132 -0
- package/lib/api/spacer/healthz.d.ts +25 -0
- package/lib/api/spacer/healthz.js +43 -0
- package/lib/api/spacer/index.d.ts +13 -0
- package/lib/api/spacer/index.js +17 -0
- package/lib/api/spacer/items.d.ts +17 -0
- package/lib/api/spacer/items.js +40 -0
- package/lib/api/spacer/lexicals.d.ts +26 -0
- package/lib/api/spacer/lexicals.js +74 -0
- package/lib/api/spacer/notebooks.d.ts +26 -0
- package/lib/api/spacer/notebooks.js +74 -0
- package/lib/api/spacer/spaces.d.ts +9 -0
- package/lib/api/spacer/spaces.js +29 -0
- package/lib/api/spacer/users.d.ts +9 -0
- package/lib/api/spacer/users.js +28 -0
- package/lib/api/types/iam.d.ts +180 -0
- package/lib/api/types/index.d.ts +32 -0
- package/lib/api/types/index.js +36 -0
- package/lib/api/types/runtimes.d.ts +235 -0
- package/lib/api/types/runtimes.js +5 -0
- package/lib/api/types/spacer.d.ts +271 -0
- package/lib/api/types/spacer.js +5 -0
- package/lib/api/utils/__tests__/validation.test.d.ts +1 -0
- package/lib/api/utils/__tests__/validation.test.js +109 -0
- package/lib/api/utils/validation.d.ts +24 -0
- package/lib/api/utils/validation.js +133 -0
- package/lib/components/display/JupyterDialog.js +4 -8
- package/lib/components/progress/CreditsIndicator.d.ts +1 -1
- package/lib/components/runtimes/RuntimeCellVariablesDialog.js +2 -2
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +1 -1
- package/lib/components/runtimes/RuntimeLauncherDialog.js +5 -2
- package/lib/components/runtimes/RuntimePickerBase.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerBase.js +1 -1
- package/lib/components/runtimes/RuntimePickerCell.js +2 -1
- package/lib/components/runtimes/RuntimePickerNotebook.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerNotebook.js +1 -1
- package/lib/components/runtimes/RuntimeSimplePicker.js +2 -1
- package/lib/components/runtimes/RuntimeTransfer.d.ts +1 -1
- package/lib/components/runtimes/RuntimeUtils.d.ts +1 -1
- package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -1
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +2 -2
- package/lib/components/snippets/SnippetDialog.js +1 -1
- package/lib/components/storage/ContentsBrowser.js +2 -2
- package/lib/components/tables/DataTable.js +2 -1
- package/lib/hooks/useDatalayer.d.ts +1 -1
- package/lib/hooks/useDatalayer.js +1 -1
- package/lib/hooks/useIAM.js +1 -1
- package/lib/hooks/useRuntimes.js +1 -1
- package/lib/index.d.ts +9 -0
- package/lib/index.js +10 -0
- package/lib/sdk/client/__tests__/sdk.health.integration.test.d.ts +1 -0
- package/lib/sdk/client/__tests__/sdk.health.integration.test.js +110 -0
- package/lib/sdk/client/__tests__/sdk.iam.integration.test.d.ts +1 -0
- package/lib/sdk/client/__tests__/sdk.iam.integration.test.js +179 -0
- package/lib/sdk/client/__tests__/sdk.models.integration.test.d.ts +1 -0
- package/lib/sdk/client/__tests__/sdk.models.integration.test.js +376 -0
- package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.d.ts +1 -0
- package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.js +276 -0
- package/lib/sdk/client/__tests__/sdk.spacer.integration.test.d.ts +1 -0
- package/lib/sdk/client/__tests__/sdk.spacer.integration.test.js +361 -0
- package/lib/sdk/client/base.d.ts +88 -0
- package/lib/sdk/client/base.js +112 -0
- package/lib/sdk/client/index.d.ts +192 -0
- package/lib/sdk/client/index.js +128 -0
- package/lib/sdk/client/mixins/HealthMixin.d.ts +100 -0
- package/lib/sdk/client/mixins/HealthMixin.js +133 -0
- package/lib/sdk/client/mixins/IAMMixin.d.ts +59 -0
- package/lib/sdk/client/mixins/IAMMixin.js +83 -0
- package/lib/sdk/client/mixins/RuntimesMixin.d.ts +134 -0
- package/lib/sdk/client/mixins/RuntimesMixin.js +221 -0
- package/lib/sdk/client/mixins/SpacerMixin.d.ts +184 -0
- package/lib/sdk/client/mixins/SpacerMixin.js +278 -0
- package/lib/sdk/client/models/Lexical.d.ts +156 -0
- package/lib/sdk/client/models/Lexical.js +275 -0
- package/lib/sdk/client/models/Notebook.d.ts +174 -0
- package/lib/sdk/client/models/Notebook.js +311 -0
- package/lib/sdk/client/models/Runtime.d.ts +221 -0
- package/lib/sdk/client/models/Runtime.js +341 -0
- package/lib/sdk/client/models/Snapshot.d.ts +156 -0
- package/lib/sdk/client/models/Snapshot.js +244 -0
- package/lib/sdk/client/models/Space.d.ts +182 -0
- package/lib/sdk/client/models/Space.js +276 -0
- package/lib/sdk/client/models/__tests__/Lexical.test.d.ts +1 -0
- package/lib/sdk/client/models/__tests__/Lexical.test.js +288 -0
- package/lib/sdk/client/models/__tests__/Notebook.test.d.ts +1 -0
- package/lib/sdk/client/models/__tests__/Notebook.test.js +206 -0
- package/lib/sdk/client/models/__tests__/Runtime.test.d.ts +1 -0
- package/lib/sdk/client/models/__tests__/Runtime.test.js +133 -0
- package/lib/sdk/client/models/__tests__/Snapshot.test.d.ts +1 -0
- package/lib/sdk/client/models/__tests__/Snapshot.test.js +244 -0
- package/lib/sdk/client/models/__tests__/Space.test.d.ts +1 -0
- package/lib/sdk/client/models/__tests__/Space.test.js +334 -0
- package/lib/sdk/client/models/index.d.ts +30 -0
- package/lib/sdk/client/models/index.js +30 -0
- package/lib/sdk/client/utils/mixins.d.ts +42 -0
- package/lib/sdk/client/utils/mixins.js +47 -0
- package/lib/sdk/index.d.ts +26 -0
- package/lib/sdk/index.js +32 -0
- package/lib/sdk/stateful/index.d.ts +3 -0
- package/lib/sdk/stateful/index.js +7 -0
- package/lib/{api → sdk/stateful}/runtimes/actions.d.ts +1 -1
- package/lib/{api → sdk/stateful}/runtimes/actions.js +3 -3
- package/lib/{api → sdk/stateful}/runtimes/apis.d.ts +1 -1
- package/lib/sdk/stateful/runtimes/apis.js +5 -0
- package/lib/sdk/stateful/runtimes/index.d.ts +5 -0
- package/lib/sdk/stateful/runtimes/index.js +9 -0
- package/lib/sdk/stateful/runtimes/snapshots.d.ts +25 -0
- package/lib/sdk/stateful/runtimes/snapshots.js +150 -0
- package/lib/services/DatalayerServiceManager.js +1 -1
- package/lib/state/substates/IAMState.js +1 -1
- package/lib/state/substates/RuntimesState.d.ts +1 -1
- package/lib/state/substates/RuntimesState.js +1 -1
- package/lib/state/substates/SurveysState.js +1 -1
- package/lib/test-setup.js +1 -0
- package/package.json +19 -9
- /package/lib/api/{runtimes/apis.js → types/iam.js} +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/Python.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/Python.js +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/Snippets.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/Snippets.js +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/index.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/index.js +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/index.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/index.js +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/kernelsHandler.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/kernelsHandler.js +0 -0
- /package/lib/{api → sdk/stateful}/runtimes/settings.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/runtimes/settings.js +0 -0
- /package/lib/{api → sdk/stateful}/runtimes/utils.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/runtimes/utils.js +0 -0
|
@@ -9,7 +9,7 @@ import { Box } from '@datalayer/primer-addons';
|
|
|
9
9
|
import { AlertIcon } from '@primer/octicons-react';
|
|
10
10
|
import { JSONExt } from '@lumino/coreutils';
|
|
11
11
|
import { KernelExecutor } from '@datalayer/jupyter-react';
|
|
12
|
-
import { RuntimeSnippetsFacade } from '../../
|
|
12
|
+
import { RuntimeSnippetsFacade } from '../../sdk/stateful/jupyter';
|
|
13
13
|
import { ExternalTokenSilentLogin } from '../../components/iam';
|
|
14
14
|
import { useCoreStore, useIAMStore } from '../../state';
|
|
15
15
|
import { RuntimeReservationControl, MAXIMAL_RUNTIME_TIME_RESERVATION_MINUTES, } from './RuntimeReservationControl';
|
|
@@ -37,7 +37,8 @@ var RuntimeDialogCause;
|
|
|
37
37
|
export function RuntimeSimplePicker(props) {
|
|
38
38
|
const { assignRuntime, sessionConnection } = props;
|
|
39
39
|
const { runtimeModels, multiServiceManager } = useRuntimesStore();
|
|
40
|
-
const
|
|
40
|
+
const jupyterReactStore = useJupyterReactStore();
|
|
41
|
+
const jupyterLabAdapter = jupyterReactStore.jupyterLabAdapter;
|
|
41
42
|
const [runtimeLocation, setRuntimeLocation] = useState();
|
|
42
43
|
const [luminoServices, setLuminoServices] = useState({});
|
|
43
44
|
const [dialogCause, setDialogCause] = useState(RuntimeDialogCause.None);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SessionContext } from '@jupyterlab/apputils';
|
|
2
2
|
import { ITranslator } from '@jupyterlab/translation';
|
|
3
|
-
import { IMultiServiceManager } from '../../
|
|
3
|
+
import { IMultiServiceManager } from '../../sdk/stateful/runtimes';
|
|
4
4
|
import { IRuntimeDesc } from '../../models';
|
|
5
5
|
export type IDatalayerRuntimeDesc = IRuntimeDesc & {
|
|
6
6
|
gpu?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PropsWithChildren } from 'react';
|
|
2
2
|
import { Kernel } from '@jupyterlab/services';
|
|
3
|
-
import { IMultiServiceManager } from '../../
|
|
3
|
+
import { IMultiServiceManager } from '../../sdk/stateful/runtimes';
|
|
4
4
|
/**
|
|
5
5
|
* Runtime snapshot menu component properties
|
|
6
6
|
*/
|
|
@@ -8,7 +8,7 @@ import { CameraIcon } from '@datalayer/icons-react';
|
|
|
8
8
|
import { ActionList, ActionMenu, Box, Flash, FormControl, Select, Spinner, } from '@primer/react';
|
|
9
9
|
import { Dialog } from '@primer/react/experimental';
|
|
10
10
|
import { useToast } from '../../hooks';
|
|
11
|
-
import { createRuntimeSnapshot, getRuntimeSnapshots, loadBrowserRuntimeSnapshot, loadRuntimeSnapshot, } from '../../
|
|
11
|
+
import { createRuntimeSnapshot, getRuntimeSnapshots, loadBrowserRuntimeSnapshot, loadRuntimeSnapshot, } from '../../sdk/stateful/runtimes';
|
|
12
12
|
import { useRuntimesStore } from '../../state';
|
|
13
13
|
import { createRuntimeSnapshotName } from '../../utils';
|
|
14
14
|
/**
|
|
@@ -116,7 +116,7 @@ export function RuntimeSnapshotMenu(props) {
|
|
|
116
116
|
setTakingSnapshot(false);
|
|
117
117
|
}
|
|
118
118
|
}, [connection, podName, multiServiceManager]);
|
|
119
|
-
return (_jsxs(_Fragment, { children: [_jsxs(ActionMenu, { children: [_jsx(ActionMenu.Button, { leadingVisual: CameraIcon, variant: "invisible", size: "small", disabled: loadingKernelSnapshot || takingKernelSnapshot || disabled, children: children }), _jsx(ActionMenu.Overlay, { children: _jsxs(ActionList, { children: [_jsx(ActionList.Item, { onSelect: onLoadKernelSnapshot, disabled: loadingKernelSnapshot || runtimeSnapshots.length === 0, children: "Load a runtime snapshot\u2026" }), _jsx(ActionList.Item, { onSelect: onTakeKernelSnapshot, disabled: takingKernelSnapshot, children: "Take a runtime snapshot" })] }) })] }), openLoadDialog && (_jsx(Dialog, { title: "Choose a runtime snapshot to load", onClose: () => {
|
|
119
|
+
return (_jsxs(_Fragment, { children: [_jsxs(ActionMenu, { children: [_jsx(ActionMenu.Button, { leadingVisual: CameraIcon, variant: "invisible", size: "small", disabled: loadingKernelSnapshot || takingKernelSnapshot || disabled, children: children }), _jsx(ActionMenu.Overlay, { children: _jsxs(ActionList, { children: [_jsx(ActionList.Item, { onSelect: onLoadKernelSnapshot, disabled: loadingKernelSnapshot || runtimeSnapshots.length === 0, children: "Load a runtime snapshot\u2026" }), _jsx(ActionList.Item, { onSelect: onTakeKernelSnapshot, disabled: takingKernelSnapshot, children: "Take a runtime snapshot" })] }) })] }), openLoadDialog && (_jsx(Dialog, { title: _jsx("span", { style: { color: 'var(--fgColor-default)' }, children: "Choose a runtime snapshot to load" }), onClose: () => {
|
|
120
120
|
setOpenLoadDialog(false);
|
|
121
121
|
}, footerButtons: [
|
|
122
122
|
{
|
|
@@ -25,7 +25,7 @@ export function SnippetDialog(props) {
|
|
|
25
25
|
model.sharedModel.updateSource(size, size, '\n'.repeat(size ? 2 : 0) + selection.code);
|
|
26
26
|
onClose();
|
|
27
27
|
}, [model, selection, onClose]);
|
|
28
|
-
return (_jsx(Dialog, { title: 'Pick a snippet to inject
|
|
28
|
+
return (_jsx(Dialog, { title: _jsx("span", { style: { color: 'var(--fgColor-default)' }, children: "Pick a snippet to inject" }), onClose: onClose, footerButtons: [
|
|
29
29
|
{
|
|
30
30
|
buttonType: 'default',
|
|
31
31
|
content: trans.__('Cancel'),
|
|
@@ -223,7 +223,7 @@ export function ContentsBrowser(props) {
|
|
|
223
223
|
}, onContextMenu: onContextMenu }, child.name));
|
|
224
224
|
}) }), _jsx(ActionMenu, { anchorRef: contextMenuAnchor ?? undefined, open: contextMenuAnchor?.current !== null, onOpenChange: () => {
|
|
225
225
|
setContextMenuAnchor(null);
|
|
226
|
-
}, children: _jsx(ActionMenu.Overlay, { children: _jsxs(ActionList, { children: [_jsx(ActionList.Item, { title: "Delete the active item.", onSelect: onSelectDelete, children: "Delete\u2026" }), localContents && (_jsx(ActionList.Item, { title: "Copy the active item to the local drive.", onSelect: onSelectCopyToLocal, children: "Copy to local drive\u2026" }))] }) }) }), openDeleteConfirmation && (_jsx(Dialog, { title: "Confirm deletion", onClose: () => {
|
|
226
|
+
}, children: _jsx(ActionMenu.Overlay, { children: _jsxs(ActionList, { children: [_jsx(ActionList.Item, { title: "Delete the active item.", onSelect: onSelectDelete, children: "Delete\u2026" }), localContents && (_jsx(ActionList.Item, { title: "Copy the active item to the local drive.", onSelect: onSelectCopyToLocal, children: "Copy to local drive\u2026" }))] }) }) }), openDeleteConfirmation && (_jsx(Dialog, { title: _jsx("span", { style: { color: 'var(--fgColor-default)' }, children: "Confirm deletion" }), onClose: () => {
|
|
227
227
|
setOpenDeleteConfirmation(false);
|
|
228
228
|
}, footerButtons: [
|
|
229
229
|
{
|
|
@@ -240,7 +240,7 @@ export function ContentsBrowser(props) {
|
|
|
240
240
|
deleteItem();
|
|
241
241
|
},
|
|
242
242
|
},
|
|
243
|
-
], children: `Are you sure you want to delete ${selectedItem?.path}?` })), copyToLocalConfirmation && (_jsx(Dialog, { title: "Confirm copy to local", onClose: () => {
|
|
243
|
+
], children: `Are you sure you want to delete ${selectedItem?.path}?` })), copyToLocalConfirmation && (_jsx(Dialog, { title: _jsx("span", { style: { color: 'var(--fgColor-default)' }, children: "Confirm copy to local" }), onClose: () => {
|
|
244
244
|
setCopyToLocalConfirmation(false);
|
|
245
245
|
}, footerButtons: [
|
|
246
246
|
{
|
|
@@ -4,8 +4,9 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
6
|
import { useState } from 'react';
|
|
7
|
-
import {
|
|
7
|
+
import { Button, PageLayout } from '@primer/react';
|
|
8
8
|
import { Dialog } from '@primer/react/experimental';
|
|
9
|
+
import { Box } from '@datalayer/primer-addons';
|
|
9
10
|
const DataTableDetails = (props) => {
|
|
10
11
|
return (_jsx(PageLayout, { containerWidth: "full", padding: "normal", sx: { overflow: 'visible' }, children: _jsx(PageLayout.Content, {}) }));
|
|
11
12
|
};
|
|
@@ -7,7 +7,7 @@ import { useNavigate } from './useNavigate';
|
|
|
7
7
|
import { useToast } from './useToast';
|
|
8
8
|
// import { useRuMnock } from './../mocks';
|
|
9
9
|
import { useIAMStore } from '../state';
|
|
10
|
-
import { requestDatalayerAPI } from '../api';
|
|
10
|
+
import { requestDatalayerAPI } from '../api/DatalayerApi';
|
|
11
11
|
export function useDatalayer(props = {}) {
|
|
12
12
|
const { loginRoute = '/login', notifyOnError = true } = props;
|
|
13
13
|
const location = useLocation();
|
package/lib/hooks/useIAM.js
CHANGED
|
@@ -6,7 +6,7 @@ import { useEffect, useState } from 'react';
|
|
|
6
6
|
import { useCache } from './useCache';
|
|
7
7
|
import { coreStore, useIAMStore, useLayoutStore, useOrganizationStore, useSpaceStore, } from '../state';
|
|
8
8
|
import { asUser, ANONYMOUS_USER, ANONYMOUS_USER_TOKEN, } from '../models';
|
|
9
|
-
import { requestDatalayerAPI } from '../api';
|
|
9
|
+
import { requestDatalayerAPI, } from '../api/DatalayerApi';
|
|
10
10
|
export const useIAM = (props = { user: undefined, token: undefined }) => {
|
|
11
11
|
const { token } = props;
|
|
12
12
|
const [iamState, setIAMState] = useState(props);
|
package/lib/hooks/useRuntimes.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
import { requestJupyterKernelsExtension } from '../
|
|
5
|
+
import { requestJupyterKernelsExtension } from '../sdk/stateful/jupyter/kernelsHandler';
|
|
6
6
|
export const useRuntimes = () => {
|
|
7
7
|
// Folder Mounting ----------------------------------------------------------
|
|
8
8
|
const mountLocalFolder = (kernelId) => {
|
package/lib/index.d.ts
CHANGED
|
@@ -4,3 +4,12 @@ export * from './collaboration';
|
|
|
4
4
|
export * from './services';
|
|
5
5
|
export * from './navigation';
|
|
6
6
|
export * from './hooks';
|
|
7
|
+
export { requestDatalayerAPI, RunResponseError, NetworkError, } from './api/DatalayerApi';
|
|
8
|
+
export type { IRequestDatalayerAPIOptions } from './api/DatalayerApi';
|
|
9
|
+
export { API_BASE_PATHS } from './api/constants';
|
|
10
|
+
export * from './api/types';
|
|
11
|
+
export * as runtimesApi from './api/runtimes';
|
|
12
|
+
export * as iamApi from './api/iam';
|
|
13
|
+
export * as spacerApi from './api/spacer';
|
|
14
|
+
export { DatalayerSDK, type DatalayerSDKConfig } from './sdk/client';
|
|
15
|
+
export { getEnvironments, createRuntime, getRuntimes, deleteRuntime, snapshotRuntime, getRuntimeSnapshots, loadRuntimeSnapshot, } from './sdk/stateful/runtimes/actions';
|
package/lib/index.js
CHANGED
|
@@ -9,3 +9,13 @@ export * from './services';
|
|
|
9
9
|
// Export navigation before hooks to avoid conflicts
|
|
10
10
|
export * from './navigation';
|
|
11
11
|
export * from './hooks';
|
|
12
|
+
// Export API and SDK layers
|
|
13
|
+
export { requestDatalayerAPI, RunResponseError, NetworkError, } from './api/DatalayerApi';
|
|
14
|
+
export { API_BASE_PATHS } from './api/constants';
|
|
15
|
+
export * from './api/types';
|
|
16
|
+
export * as runtimesApi from './api/runtimes';
|
|
17
|
+
export * as iamApi from './api/iam';
|
|
18
|
+
export * as spacerApi from './api/spacer';
|
|
19
|
+
export { DatalayerSDK } from './sdk/client';
|
|
20
|
+
// Export commonly used SDK functions directly for convenience
|
|
21
|
+
export { getEnvironments, createRuntime, getRuntimes, deleteRuntime, snapshotRuntime, getRuntimeSnapshots, loadRuntimeSnapshot, } from './sdk/stateful/runtimes/actions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
import { describe, it, expect, beforeAll } from 'vitest';
|
|
6
|
+
import { DatalayerSDK } from '..';
|
|
7
|
+
import { testConfig } from '../../../__tests__/shared/test-config';
|
|
8
|
+
import { DEFAULT_SERVICE_URLS } from '../../../api/constants';
|
|
9
|
+
/**
|
|
10
|
+
* SDK Health Integration Tests
|
|
11
|
+
*
|
|
12
|
+
* Tests health check functionality across all Datalayer services
|
|
13
|
+
* using the SDK client.
|
|
14
|
+
*/
|
|
15
|
+
describe('SDK Health Integration Tests', () => {
|
|
16
|
+
let sdk;
|
|
17
|
+
beforeAll(() => {
|
|
18
|
+
if (!testConfig.hasToken()) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
sdk = new DatalayerSDK({
|
|
22
|
+
token: testConfig.getToken(),
|
|
23
|
+
iamRunUrl: DEFAULT_SERVICE_URLS.IAM,
|
|
24
|
+
runtimesRunUrl: DEFAULT_SERVICE_URLS.RUNTIMES,
|
|
25
|
+
spacerRunUrl: DEFAULT_SERVICE_URLS.SPACER,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
describe.skipIf(!testConfig.hasToken())('health check methods', () => {
|
|
29
|
+
describe('individual service health checks', () => {
|
|
30
|
+
it('should check IAM service health', async () => {
|
|
31
|
+
console.log('Testing IAM health check...');
|
|
32
|
+
const isHealthy = await sdk.isIAMHealthy();
|
|
33
|
+
expect(isHealthy).toBe(true);
|
|
34
|
+
console.log(`IAM service is ${isHealthy ? 'healthy' : 'unhealthy'}`);
|
|
35
|
+
});
|
|
36
|
+
it('should check Runtimes service health', async () => {
|
|
37
|
+
console.log('Testing Runtimes health check...');
|
|
38
|
+
const isHealthy = await sdk.isRuntimesHealthy();
|
|
39
|
+
expect(isHealthy).toBe(true);
|
|
40
|
+
console.log(`Runtimes service is ${isHealthy ? 'healthy' : 'unhealthy'}`);
|
|
41
|
+
});
|
|
42
|
+
it('should check Spacer service health', async () => {
|
|
43
|
+
console.log('Testing Spacer health check...');
|
|
44
|
+
const isHealthy = await sdk.isSpacerHealthy();
|
|
45
|
+
expect(isHealthy).toBe(true);
|
|
46
|
+
console.log(`Spacer service is ${isHealthy ? 'healthy' : 'unhealthy'}`);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
describe('combined health checks', () => {
|
|
50
|
+
it('should check all services health at once', async () => {
|
|
51
|
+
console.log('Testing all services health check...');
|
|
52
|
+
const allHealthy = await sdk.areAllServicesHealthy();
|
|
53
|
+
expect(allHealthy).toBe(true);
|
|
54
|
+
console.log(`All services are ${allHealthy ? 'healthy' : 'not all healthy'}`);
|
|
55
|
+
});
|
|
56
|
+
it('should get detailed health status for all services', async () => {
|
|
57
|
+
console.log('Getting detailed health status...');
|
|
58
|
+
const status = await sdk.getHealthStatus();
|
|
59
|
+
expect(status).toBeDefined();
|
|
60
|
+
expect(status.iam).toBeDefined();
|
|
61
|
+
expect(status.runtimes).toBeDefined();
|
|
62
|
+
expect(status.spacer).toBeDefined();
|
|
63
|
+
expect(status.allHealthy).toBeDefined();
|
|
64
|
+
console.log('Health Status:');
|
|
65
|
+
console.log(` IAM: ${status.iam.healthy ? '✅' : '❌'}`);
|
|
66
|
+
if (status.iam.version) {
|
|
67
|
+
console.log(` Version: ${status.iam.version}`);
|
|
68
|
+
}
|
|
69
|
+
console.log(` Runtimes: ${status.runtimes.healthy ? '✅' : '❌'}`);
|
|
70
|
+
if (status.runtimes.version) {
|
|
71
|
+
console.log(` Version: ${status.runtimes.version}`);
|
|
72
|
+
}
|
|
73
|
+
console.log(` Spacer: ${status.spacer.healthy ? '✅' : '❌'}`);
|
|
74
|
+
if (status.spacer.version) {
|
|
75
|
+
console.log(` Version: ${status.spacer.version}`);
|
|
76
|
+
}
|
|
77
|
+
console.log(` Overall: ${status.allHealthy ? '✅ All Healthy' : '⚠️ Some Issues'}`);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
describe('error handling', () => {
|
|
81
|
+
it('should handle network errors gracefully', async () => {
|
|
82
|
+
console.log('Testing health check with invalid URL...');
|
|
83
|
+
// Create SDK with invalid URL
|
|
84
|
+
const badSdk = new DatalayerSDK({
|
|
85
|
+
token: testConfig.getToken(),
|
|
86
|
+
iamRunUrl: 'https://invalid.example.com',
|
|
87
|
+
runtimesRunUrl: DEFAULT_SERVICE_URLS.RUNTIMES,
|
|
88
|
+
spacerRunUrl: DEFAULT_SERVICE_URLS.SPACER,
|
|
89
|
+
});
|
|
90
|
+
const isHealthy = await badSdk.isIAMHealthy();
|
|
91
|
+
expect(isHealthy).toBe(false);
|
|
92
|
+
const status = await badSdk.getHealthStatus();
|
|
93
|
+
expect(status.iam.healthy).toBe(false);
|
|
94
|
+
expect(status.allHealthy).toBe(false);
|
|
95
|
+
console.log('Network error handled correctly');
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
describe('configuration validation', () => {
|
|
99
|
+
it('should use configured service URLs', async () => {
|
|
100
|
+
console.log('Verifying SDK uses configured URLs...');
|
|
101
|
+
// The SDK should be using the URLs we configured
|
|
102
|
+
const config = sdk.getConfig();
|
|
103
|
+
expect(config.iamRunUrl).toBe(DEFAULT_SERVICE_URLS.IAM);
|
|
104
|
+
expect(config.runtimesRunUrl).toBe(DEFAULT_SERVICE_URLS.RUNTIMES);
|
|
105
|
+
expect(config.spacerRunUrl).toBe(DEFAULT_SERVICE_URLS.SPACER);
|
|
106
|
+
console.log('SDK configuration verified');
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
import { describe, it, expect, beforeAll } from 'vitest';
|
|
6
|
+
import { DatalayerSDK } from '..';
|
|
7
|
+
import { testConfig } from '../../../__tests__/shared/test-config';
|
|
8
|
+
import { DEFAULT_SERVICE_URLS } from '../../../api/constants';
|
|
9
|
+
/**
|
|
10
|
+
* SDK IAM Integration Tests
|
|
11
|
+
*
|
|
12
|
+
* Tests authentication and identity management functionality
|
|
13
|
+
* using the SDK client.
|
|
14
|
+
*/
|
|
15
|
+
describe('SDK IAM Integration Tests', () => {
|
|
16
|
+
let sdk;
|
|
17
|
+
beforeAll(() => {
|
|
18
|
+
if (!testConfig.hasToken()) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
sdk = new DatalayerSDK({
|
|
22
|
+
token: testConfig.getToken(),
|
|
23
|
+
iamRunUrl: DEFAULT_SERVICE_URLS.IAM,
|
|
24
|
+
runtimesRunUrl: DEFAULT_SERVICE_URLS.RUNTIMES,
|
|
25
|
+
spacerRunUrl: DEFAULT_SERVICE_URLS.SPACER,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
describe.skipIf(!testConfig.hasToken())('IAM authentication methods', () => {
|
|
29
|
+
describe('whoami', () => {
|
|
30
|
+
it('should get current user profile', async () => {
|
|
31
|
+
console.log('Testing whoami...');
|
|
32
|
+
const user = await sdk.whoami();
|
|
33
|
+
expect(user).toBeDefined();
|
|
34
|
+
expect(user.id).toBeDefined();
|
|
35
|
+
expect(user.uid).toBeDefined();
|
|
36
|
+
expect(user.handle).toBeDefined();
|
|
37
|
+
expect(user.roles).toBeDefined();
|
|
38
|
+
expect(Array.isArray(user.roles)).toBe(true);
|
|
39
|
+
console.log('Current user:');
|
|
40
|
+
console.log(` ID: ${user.id}`);
|
|
41
|
+
console.log(` UID: ${user.uid}`);
|
|
42
|
+
console.log(` Handle: ${user.handle}`);
|
|
43
|
+
console.log(` Email: ${user.email || 'Not provided'}`);
|
|
44
|
+
console.log(` Name: ${user.first_name} ${user.last_name}`);
|
|
45
|
+
console.log(` Roles: ${user.roles.join(', ')}`);
|
|
46
|
+
});
|
|
47
|
+
it('should include organization info if available', async () => {
|
|
48
|
+
console.log('Checking organization info...');
|
|
49
|
+
const user = await sdk.whoami();
|
|
50
|
+
if (user.organizationIds &&
|
|
51
|
+
user.organizationIds.length > 0) {
|
|
52
|
+
console.log(`User belongs to ${user.organizationIds.length} organization(s)`);
|
|
53
|
+
expect(Array.isArray(user.organizationIds)).toBe(true);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
console.log('User does not belong to any organizations');
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
it('should cache user profile for performance', async () => {
|
|
60
|
+
console.log('Testing user profile caching...');
|
|
61
|
+
const start1 = Date.now();
|
|
62
|
+
const user1 = await sdk.whoami();
|
|
63
|
+
const time1 = Date.now() - start1;
|
|
64
|
+
const start2 = Date.now();
|
|
65
|
+
const user2 = await sdk.whoami();
|
|
66
|
+
const time2 = Date.now() - start2;
|
|
67
|
+
// Second call should be same or faster (cached)
|
|
68
|
+
expect(user2.id).toBe(user1.id);
|
|
69
|
+
console.log(`First call: ${time1}ms, Second call: ${time2}ms`);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
describe('login', () => {
|
|
73
|
+
it('should handle invalid credentials properly', async () => {
|
|
74
|
+
console.log('Testing login with invalid credentials...');
|
|
75
|
+
try {
|
|
76
|
+
await sdk.login({
|
|
77
|
+
handle: 'invalid@example.com',
|
|
78
|
+
password: 'wrong-password',
|
|
79
|
+
});
|
|
80
|
+
// Should not reach here
|
|
81
|
+
expect(true).toBe(false);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
expect(error).toBeDefined();
|
|
85
|
+
console.log('Invalid login rejected correctly');
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
it('should validate login request structure', async () => {
|
|
89
|
+
console.log('Testing login validation...');
|
|
90
|
+
try {
|
|
91
|
+
// Missing required fields
|
|
92
|
+
await sdk.login({});
|
|
93
|
+
expect(true).toBe(false);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
expect(error).toBeDefined();
|
|
97
|
+
console.log('Invalid login request rejected');
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
describe('token management', () => {
|
|
102
|
+
it('should include token in all API requests', async () => {
|
|
103
|
+
console.log('Verifying token is included in requests...');
|
|
104
|
+
// Make a request and verify it succeeds (which means token was included)
|
|
105
|
+
const user = await sdk.whoami();
|
|
106
|
+
expect(user).toBeDefined();
|
|
107
|
+
// Verify token is stored in SDK
|
|
108
|
+
const token = sdk.getToken();
|
|
109
|
+
expect(token).toBe(testConfig.getToken());
|
|
110
|
+
console.log('Token management verified');
|
|
111
|
+
});
|
|
112
|
+
it('should handle expired tokens gracefully', async () => {
|
|
113
|
+
console.log('Testing expired token handling...');
|
|
114
|
+
const expiredSdk = new DatalayerSDK({
|
|
115
|
+
token: 'expired.invalid.token',
|
|
116
|
+
iamRunUrl: DEFAULT_SERVICE_URLS.IAM,
|
|
117
|
+
runtimesRunUrl: DEFAULT_SERVICE_URLS.RUNTIMES,
|
|
118
|
+
spacerRunUrl: DEFAULT_SERVICE_URLS.SPACER,
|
|
119
|
+
});
|
|
120
|
+
try {
|
|
121
|
+
await expiredSdk.whoami();
|
|
122
|
+
expect(true).toBe(false);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
expect(error).toBeDefined();
|
|
126
|
+
console.log('Expired token rejected correctly');
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
describe('logout', () => {
|
|
131
|
+
it('should handle logout operation', async () => {
|
|
132
|
+
console.log('Testing logout...');
|
|
133
|
+
// Create a separate SDK instance for logout test
|
|
134
|
+
const logoutSdk = new DatalayerSDK({
|
|
135
|
+
token: testConfig.getToken(),
|
|
136
|
+
iamRunUrl: DEFAULT_SERVICE_URLS.IAM,
|
|
137
|
+
runtimesRunUrl: DEFAULT_SERVICE_URLS.RUNTIMES,
|
|
138
|
+
spacerRunUrl: DEFAULT_SERVICE_URLS.SPACER,
|
|
139
|
+
});
|
|
140
|
+
// Verify we can make authenticated requests
|
|
141
|
+
const userBefore = await logoutSdk.whoami();
|
|
142
|
+
expect(userBefore).toBeDefined();
|
|
143
|
+
// Note: Actual logout may not invalidate the token server-side
|
|
144
|
+
// This tests the logout method exists and can be called
|
|
145
|
+
await logoutSdk.logout();
|
|
146
|
+
console.log('Logout completed');
|
|
147
|
+
// In a real scenario, subsequent requests might fail
|
|
148
|
+
// But with API tokens, they typically remain valid until expiry
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
describe('error handling', () => {
|
|
152
|
+
it('should provide clear error messages for auth failures', async () => {
|
|
153
|
+
console.log('Testing auth error messages...');
|
|
154
|
+
const invalidSdk = new DatalayerSDK({
|
|
155
|
+
token: 'invalid-token',
|
|
156
|
+
iamRunUrl: DEFAULT_SERVICE_URLS.IAM,
|
|
157
|
+
runtimesRunUrl: DEFAULT_SERVICE_URLS.RUNTIMES,
|
|
158
|
+
spacerRunUrl: DEFAULT_SERVICE_URLS.SPACER,
|
|
159
|
+
});
|
|
160
|
+
try {
|
|
161
|
+
await invalidSdk.whoami();
|
|
162
|
+
expect(true).toBe(false);
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
expect(error.message).toBeDefined();
|
|
166
|
+
// Error should mention authentication, token, or invalid
|
|
167
|
+
const errorLower = error.message.toLowerCase();
|
|
168
|
+
expect(errorLower.includes('auth') ||
|
|
169
|
+
errorLower.includes('unauth') ||
|
|
170
|
+
errorLower.includes('401') ||
|
|
171
|
+
errorLower.includes('403') ||
|
|
172
|
+
errorLower.includes('invalid') ||
|
|
173
|
+
errorLower.includes('token')).toBe(true);
|
|
174
|
+
console.log('Auth error message is clear and helpful');
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|