@datalayer/core 0.0.12 → 0.0.14
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 +2 -2
- package/lib/api/DatalayerApi.d.ts +38 -26
- package/lib/api/DatalayerApi.js +52 -13
- package/lib/api/iam/authentication.d.ts +9 -8
- package/lib/api/iam/authentication.js +14 -15
- package/lib/api/iam/healthz.d.ts +3 -2
- package/lib/api/iam/healthz.js +5 -3
- package/lib/api/iam/index.d.ts +9 -4
- package/lib/api/iam/index.js +9 -4
- package/lib/api/iam/oauth2.d.ts +115 -0
- package/lib/api/iam/oauth2.js +309 -0
- package/lib/api/iam/profile.d.ts +8 -1
- package/lib/api/iam/profile.js +17 -2
- package/lib/api/iam/usage.d.ts +18 -0
- package/lib/api/iam/usage.js +39 -0
- package/lib/api/index.d.ts +6 -6
- package/lib/api/index.js +6 -7
- package/lib/api/runtimes/environments.d.ts +2 -2
- package/lib/api/runtimes/environments.js +3 -2
- package/lib/api/runtimes/healthz.d.ts +3 -13
- package/lib/api/runtimes/healthz.js +4 -3
- package/lib/api/runtimes/index.d.ts +3 -2
- package/lib/api/runtimes/index.js +3 -2
- package/lib/api/runtimes/runtimes.d.ts +4 -4
- package/lib/api/runtimes/runtimes.js +17 -6
- package/lib/api/runtimes/snapshots.d.ts +4 -4
- package/lib/api/runtimes/snapshots.js +3 -2
- package/lib/api/spacer/documents.d.ts +12 -0
- package/lib/api/spacer/documents.js +43 -0
- package/lib/api/spacer/healthz.d.ts +3 -13
- package/lib/api/spacer/healthz.js +4 -3
- package/lib/api/spacer/index.d.ts +4 -2
- package/lib/api/spacer/index.js +4 -2
- package/lib/api/spacer/items.d.ts +9 -1
- package/lib/api/spacer/items.js +17 -2
- package/lib/api/spacer/lexicals.d.ts +1 -1
- package/lib/api/spacer/lexicals.js +3 -2
- package/lib/api/spacer/notebooks.d.ts +1 -1
- package/lib/api/spacer/notebooks.js +3 -2
- package/lib/api/spacer/spaces.d.ts +1 -1
- package/lib/api/spacer/spaces.js +3 -2
- package/lib/api/spacer/users.d.ts +1 -1
- package/lib/api/spacer/users.js +3 -2
- package/lib/api/utils/validation.d.ts +24 -1
- package/lib/api/utils/validation.js +62 -1
- package/lib/client/base.d.ts +75 -0
- package/lib/client/base.js +199 -0
- package/lib/client/constants.d.ts +22 -0
- package/lib/client/constants.js +22 -0
- package/lib/client/index.d.ts +108 -0
- package/lib/client/index.js +79 -0
- package/lib/client/mixins/IAMMixin.d.ts +54 -0
- package/lib/client/mixins/IAMMixin.js +181 -0
- package/lib/client/mixins/RuntimesMixin.d.ts +93 -0
- package/lib/client/mixins/RuntimesMixin.js +229 -0
- package/lib/client/mixins/SpacerMixin.d.ts +111 -0
- package/lib/client/mixins/SpacerMixin.js +340 -0
- package/lib/client/utils/mixins.d.ts +12 -0
- package/lib/{sdk/client → client}/utils/mixins.js +0 -28
- package/lib/client/utils/spacerUtils.d.ts +18 -0
- package/lib/client/utils/spacerUtils.js +32 -0
- package/lib/collaboration/DatalayerCollaboration.d.ts +6 -1
- package/lib/collaboration/DatalayerCollaboration.js +2 -2
- package/lib/collaboration/DatalayerCollaborationProvider.d.ts +5 -0
- package/lib/collaboration/DatalayerCollaborationProvider.js +10 -9
- package/lib/components/progress/CreditsIndicator.d.ts +1 -1
- package/lib/components/runtimes/RuntimeCellVariablesDialog.js +1 -1
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +1 -1
- package/lib/components/runtimes/RuntimeLauncherDialog.js +2 -2
- package/lib/components/runtimes/RuntimePickerBase.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerBase.js +1 -1
- package/lib/components/runtimes/RuntimePickerCell.js +3 -3
- package/lib/components/runtimes/RuntimePickerNotebook.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerNotebook.js +2 -2
- package/lib/components/runtimes/RuntimeTransfer.d.ts +2 -2
- package/lib/components/runtimes/RuntimeUtils.d.ts +1 -1
- package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -1
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +27 -20
- package/lib/config/Configuration.d.ts +8 -0
- package/lib/hooks/useDatalayer.js +1 -1
- package/lib/hooks/useRuntimes.js +1 -1
- package/lib/hooks/useToast.js +1 -1
- package/lib/index.d.ts +2 -3
- package/lib/index.js +4 -3
- package/lib/models/Common.d.ts +64 -0
- package/lib/models/CreditsDTO.d.ts +124 -0
- package/lib/models/CreditsDTO.js +135 -0
- package/lib/models/Environment.d.ts +1 -1
- package/lib/models/EnvironmentDTO.d.ts +125 -0
- package/lib/models/EnvironmentDTO.js +88 -0
- package/lib/models/HealthCheck.d.ts +72 -0
- package/lib/models/HealthCheck.js +107 -0
- package/lib/{api/types/iam.d.ts → models/IAM.d.ts} +15 -78
- package/lib/models/ItemDTO.d.ts +74 -0
- package/lib/models/ItemDTO.js +186 -0
- package/lib/models/LexicalDTO.d.ts +155 -0
- package/lib/models/LexicalDTO.js +157 -0
- package/lib/models/NotebookDTO.d.ts +96 -0
- package/lib/models/NotebookDTO.js +153 -0
- package/lib/models/Profile.d.ts +65 -0
- package/lib/models/RuntimeDTO.d.ts +191 -0
- package/lib/models/RuntimeDTO.js +204 -0
- package/lib/models/RuntimeSnapshotDTO.d.ts +173 -0
- package/lib/models/RuntimeSnapshotDTO.js +139 -0
- package/lib/models/SpaceDTO.d.ts +280 -0
- package/lib/models/SpaceDTO.js +239 -0
- package/lib/models/UserDTO.d.ts +86 -0
- package/lib/models/UserDTO.js +84 -0
- package/lib/models/index.d.ts +45 -4
- package/lib/models/index.js +45 -4
- package/lib/sdk/index.d.ts +5 -4
- package/lib/sdk/index.js +6 -5
- package/lib/services/DatalayerServiceManager.js +1 -1
- package/lib/state/substates/CoreState.js +2 -0
- package/lib/state/substates/RuntimesState.d.ts +1 -1
- package/lib/state/substates/RuntimesState.js +1 -1
- package/lib/{sdk/stateful → stateful}/index.d.ts +1 -1
- package/lib/{sdk/stateful → stateful}/index.js +1 -1
- package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.d.ts +1 -41
- package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.js +1 -20
- package/lib/{sdk/stateful → stateful}/runtimes/actions.d.ts +3 -3
- package/lib/{sdk/stateful → stateful}/runtimes/actions.js +8 -8
- package/lib/{sdk/stateful → stateful}/runtimes/apis.d.ts +8 -8
- package/package.json +13 -10
- package/lib/__tests__/hooks.test.d.ts +0 -1
- package/lib/__tests__/hooks.test.js +0 -19
- package/lib/__tests__/index.test.d.ts +0 -1
- package/lib/__tests__/index.test.js +0 -27
- package/lib/__tests__/integration.test.d.ts +0 -1
- package/lib/__tests__/integration.test.js +0 -57
- package/lib/__tests__/shared/cleanup-shared.d.ts +0 -4
- package/lib/__tests__/shared/cleanup-shared.js +0 -228
- package/lib/__tests__/shared/test-config.d.ts +0 -51
- package/lib/__tests__/shared/test-config.js +0 -110
- package/lib/__tests__/shared/test-constants.d.ts +0 -66
- package/lib/__tests__/shared/test-constants.js +0 -79
- package/lib/__tests__/utils.test.d.ts +0 -1
- package/lib/__tests__/utils.test.js +0 -59
- package/lib/api/__tests__/iam.authentication.integration.test.d.ts +0 -1
- package/lib/api/__tests__/iam.authentication.integration.test.js +0 -247
- package/lib/api/__tests__/iam.healthz.integration.test.d.ts +0 -1
- package/lib/api/__tests__/iam.healthz.integration.test.js +0 -63
- package/lib/api/__tests__/iam.profile.integration.test.d.ts +0 -1
- package/lib/api/__tests__/iam.profile.integration.test.js +0 -252
- package/lib/api/__tests__/runtimes.environments.integration.test.d.ts +0 -1
- package/lib/api/__tests__/runtimes.environments.integration.test.js +0 -122
- package/lib/api/__tests__/runtimes.healthz.integration.test.d.ts +0 -1
- package/lib/api/__tests__/runtimes.healthz.integration.test.js +0 -50
- package/lib/api/__tests__/runtimes.integration.test.d.ts +0 -1
- package/lib/api/__tests__/runtimes.integration.test.js +0 -369
- package/lib/api/__tests__/spacer.healthz.integration.test.d.ts +0 -1
- package/lib/api/__tests__/spacer.healthz.integration.test.js +0 -50
- package/lib/api/__tests__/spacer.integration.test.d.ts +0 -1
- package/lib/api/__tests__/spacer.integration.test.js +0 -519
- package/lib/api/iam/__tests__/authentication.unit.test.d.ts +0 -1
- package/lib/api/iam/__tests__/authentication.unit.test.js +0 -63
- package/lib/api/iam/__tests__/healthz.unit.test.d.ts +0 -1
- package/lib/api/iam/__tests__/healthz.unit.test.js +0 -60
- package/lib/api/iam/__tests__/profile.unit.test.d.ts +0 -1
- package/lib/api/iam/__tests__/profile.unit.test.js +0 -57
- package/lib/api/runtimes/__tests__/environments.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/environments.unit.test.js +0 -77
- package/lib/api/runtimes/__tests__/healthz.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/healthz.unit.test.js +0 -57
- package/lib/api/runtimes/__tests__/runtimes.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/runtimes.unit.test.js +0 -139
- package/lib/api/runtimes/__tests__/snapshots.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/snapshots.unit.test.js +0 -96
- package/lib/api/spacer/__tests__/healthz.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/healthz.unit.test.js +0 -57
- package/lib/api/spacer/__tests__/items.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/items.unit.test.js +0 -165
- package/lib/api/spacer/__tests__/lexicals.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/lexicals.unit.test.js +0 -323
- package/lib/api/spacer/__tests__/notebooks.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/notebooks.unit.test.js +0 -224
- package/lib/api/spacer/__tests__/users.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/users.unit.test.js +0 -132
- package/lib/api/types/index.d.ts +0 -32
- package/lib/api/types/index.js +0 -36
- package/lib/api/types/runtimes.d.ts +0 -235
- package/lib/api/types/spacer.d.ts +0 -271
- package/lib/api/types/spacer.js +0 -5
- package/lib/api/utils/__tests__/validation.test.d.ts +0 -1
- package/lib/api/utils/__tests__/validation.test.js +0 -109
- package/lib/sdk/client/__tests__/sdk.health.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.health.integration.test.js +0 -110
- package/lib/sdk/client/__tests__/sdk.iam.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.iam.integration.test.js +0 -179
- package/lib/sdk/client/__tests__/sdk.models.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.models.integration.test.js +0 -376
- package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.js +0 -276
- package/lib/sdk/client/__tests__/sdk.spacer.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.spacer.integration.test.js +0 -361
- package/lib/sdk/client/base.d.ts +0 -88
- package/lib/sdk/client/base.js +0 -112
- package/lib/sdk/client/index.d.ts +0 -192
- package/lib/sdk/client/index.js +0 -128
- package/lib/sdk/client/mixins/HealthMixin.d.ts +0 -100
- package/lib/sdk/client/mixins/HealthMixin.js +0 -133
- package/lib/sdk/client/mixins/IAMMixin.d.ts +0 -59
- package/lib/sdk/client/mixins/IAMMixin.js +0 -83
- package/lib/sdk/client/mixins/RuntimesMixin.d.ts +0 -134
- package/lib/sdk/client/mixins/RuntimesMixin.js +0 -221
- package/lib/sdk/client/mixins/SpacerMixin.d.ts +0 -184
- package/lib/sdk/client/mixins/SpacerMixin.js +0 -278
- package/lib/sdk/client/models/Lexical.d.ts +0 -156
- package/lib/sdk/client/models/Lexical.js +0 -275
- package/lib/sdk/client/models/Notebook.d.ts +0 -174
- package/lib/sdk/client/models/Notebook.js +0 -311
- package/lib/sdk/client/models/Runtime.d.ts +0 -221
- package/lib/sdk/client/models/Runtime.js +0 -341
- package/lib/sdk/client/models/Snapshot.d.ts +0 -156
- package/lib/sdk/client/models/Snapshot.js +0 -244
- package/lib/sdk/client/models/Space.d.ts +0 -182
- package/lib/sdk/client/models/Space.js +0 -276
- package/lib/sdk/client/models/__tests__/Lexical.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Lexical.test.js +0 -288
- package/lib/sdk/client/models/__tests__/Notebook.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Notebook.test.js +0 -206
- package/lib/sdk/client/models/__tests__/Runtime.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Runtime.test.js +0 -133
- package/lib/sdk/client/models/__tests__/Snapshot.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Snapshot.test.js +0 -244
- package/lib/sdk/client/models/__tests__/Space.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Space.test.js +0 -334
- package/lib/sdk/client/models/index.d.ts +0 -30
- package/lib/sdk/client/models/index.js +0 -30
- package/lib/sdk/client/utils/mixins.d.ts +0 -42
- /package/lib/{api/types/iam.js → models/Common.js} +0 -0
- /package/lib/{api/types/runtimes.js → models/IAM.js} +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.js +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.js +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/index.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/index.js +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/apis.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/index.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/index.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/settings.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/settings.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/utils.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/utils.js +0 -0
|
@@ -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 '../../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 '../../stateful/runtimes';
|
|
4
4
|
/**
|
|
5
5
|
* Runtime snapshot menu component properties
|
|
6
6
|
*/
|
|
@@ -5,10 +5,11 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
5
5
|
*/
|
|
6
6
|
import { useCallback, useEffect, useState, } from 'react';
|
|
7
7
|
import { CameraIcon } from '@datalayer/icons-react';
|
|
8
|
-
import { ActionList, ActionMenu,
|
|
8
|
+
import { ActionList, ActionMenu, Flash, FormControl, Select, Spinner, } from '@primer/react';
|
|
9
9
|
import { Dialog } from '@primer/react/experimental';
|
|
10
|
+
import { Box } from '@datalayer/primer-addons';
|
|
10
11
|
import { useToast } from '../../hooks';
|
|
11
|
-
import { createRuntimeSnapshot, getRuntimeSnapshots, loadBrowserRuntimeSnapshot, loadRuntimeSnapshot, } from '../../
|
|
12
|
+
import { createRuntimeSnapshot, getRuntimeSnapshots, loadBrowserRuntimeSnapshot, loadRuntimeSnapshot, } from '../../stateful/runtimes';
|
|
12
13
|
import { useRuntimesStore } from '../../state';
|
|
13
14
|
import { createRuntimeSnapshotName } from '../../utils';
|
|
14
15
|
/**
|
|
@@ -17,10 +18,10 @@ import { createRuntimeSnapshotName } from '../../utils';
|
|
|
17
18
|
export function RuntimeSnapshotMenu(props) {
|
|
18
19
|
const { children, connection, podName, multiServiceManager, disabled } = props;
|
|
19
20
|
const { addRuntimeSnapshot, runtimesRunUrl, runtimeSnapshots, setRuntimeSnapshots, } = useRuntimesStore();
|
|
20
|
-
const { trackAsyncTask } = useToast();
|
|
21
|
+
const { enqueueToast, trackAsyncTask } = useToast();
|
|
21
22
|
const [openLoadDialog, setOpenLoadDialog] = useState(false);
|
|
22
|
-
const [
|
|
23
|
-
const [
|
|
23
|
+
const [loadingRuntimeSnapshot, setLoadingRuntimeSnapshot] = useState(false);
|
|
24
|
+
const [takingRuntimeSnapshot, setTakingRuntimeSnapshot] = useState(false);
|
|
24
25
|
const [selection, setSelection] = useState(runtimeSnapshots[0]?.id ?? '');
|
|
25
26
|
const [error, setError] = useState();
|
|
26
27
|
useEffect(() => {
|
|
@@ -35,31 +36,37 @@ export function RuntimeSnapshotMenu(props) {
|
|
|
35
36
|
console.error(`Failed to fetch remote kernel snapshots; ${reason}`);
|
|
36
37
|
});
|
|
37
38
|
}, [runtimesRunUrl]);
|
|
38
|
-
const
|
|
39
|
+
const onLoadRuntimeSnapshot = useCallback(() => {
|
|
39
40
|
setError(undefined);
|
|
40
41
|
setOpenLoadDialog(true);
|
|
41
42
|
}, []);
|
|
42
|
-
const
|
|
43
|
+
const onRuntimeSnapshotChanged = useCallback(event => {
|
|
43
44
|
setSelection(event.target.value);
|
|
44
45
|
}, []);
|
|
45
|
-
const
|
|
46
|
+
const onLoadRuntimeSnapshotSubmit = useCallback(async ({ id, connection, podName, }) => {
|
|
46
47
|
if (podName) {
|
|
47
48
|
await loadRuntimeSnapshot({ id: podName, from: id });
|
|
49
|
+
enqueueToast(`Runtime snapshot ${podName} is loaded.`, {
|
|
50
|
+
variant: 'success',
|
|
51
|
+
});
|
|
48
52
|
}
|
|
49
53
|
else if (connection) {
|
|
50
54
|
await loadBrowserRuntimeSnapshot({ connection, id });
|
|
55
|
+
enqueueToast(`Runtime snapshot ${id} is loaded.`, {
|
|
56
|
+
variant: 'success',
|
|
57
|
+
});
|
|
51
58
|
}
|
|
52
59
|
}, []);
|
|
53
|
-
const
|
|
60
|
+
const onTakeRuntimeSnapshot = useCallback(async () => {
|
|
54
61
|
try {
|
|
55
|
-
|
|
62
|
+
setTakingRuntimeSnapshot(true);
|
|
56
63
|
let snapshot;
|
|
57
64
|
let task;
|
|
58
65
|
let ref = '';
|
|
59
66
|
let snapshotName = '';
|
|
60
67
|
if (podName && multiServiceManager?.remote) {
|
|
61
68
|
snapshotName = createRuntimeSnapshotName('cloud');
|
|
62
|
-
task = multiServiceManager.remote.runtimesManager.
|
|
69
|
+
task = multiServiceManager.remote.runtimesManager.snapshotRuntime({
|
|
63
70
|
podName,
|
|
64
71
|
name: snapshotName,
|
|
65
72
|
description: snapshotName,
|
|
@@ -97,7 +104,7 @@ export function RuntimeSnapshotMenu(props) {
|
|
|
97
104
|
message: (reason, data) => {
|
|
98
105
|
const msg = reason === 'Empty snapshot'
|
|
99
106
|
? `Runtime ${ref} will not be snapshotted as it does not contain any serializable state.`
|
|
100
|
-
: `Failed to
|
|
107
|
+
: `Failed to snapshot runtime ${ref} - ${reason}`;
|
|
101
108
|
return msg;
|
|
102
109
|
},
|
|
103
110
|
},
|
|
@@ -113,10 +120,10 @@ export function RuntimeSnapshotMenu(props) {
|
|
|
113
120
|
}
|
|
114
121
|
}
|
|
115
122
|
finally {
|
|
116
|
-
|
|
123
|
+
setTakingRuntimeSnapshot(false);
|
|
117
124
|
}
|
|
118
125
|
}, [connection, podName, multiServiceManager]);
|
|
119
|
-
return (_jsxs(_Fragment, { children: [_jsxs(ActionMenu, { children: [_jsx(ActionMenu.Button, { leadingVisual: CameraIcon, variant: "invisible", size: "small", disabled:
|
|
126
|
+
return (_jsxs(_Fragment, { children: [_jsxs(ActionMenu, { children: [_jsx(ActionMenu.Button, { leadingVisual: CameraIcon, variant: "invisible", size: "small", disabled: loadingRuntimeSnapshot || takingRuntimeSnapshot || disabled, children: children }), _jsx(ActionMenu.Overlay, { children: _jsxs(ActionList, { children: [_jsx(ActionList.Item, { onSelect: onLoadRuntimeSnapshot, disabled: loadingRuntimeSnapshot || runtimeSnapshots.length === 0, children: "Load a runtime snapshot\u2026" }), _jsx(ActionList.Item, { onSelect: onTakeRuntimeSnapshot, disabled: takingRuntimeSnapshot, 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
127
|
setOpenLoadDialog(false);
|
|
121
128
|
}, footerButtons: [
|
|
122
129
|
{
|
|
@@ -131,17 +138,17 @@ export function RuntimeSnapshotMenu(props) {
|
|
|
131
138
|
},
|
|
132
139
|
{
|
|
133
140
|
buttonType: 'primary',
|
|
134
|
-
content:
|
|
135
|
-
disabled:
|
|
141
|
+
content: loadingRuntimeSnapshot ? (_jsx(Spinner, { size: "small" })) : ('Load'),
|
|
142
|
+
disabled: loadingRuntimeSnapshot,
|
|
136
143
|
onClick: async (event) => {
|
|
137
144
|
if (!event.defaultPrevented) {
|
|
138
145
|
event.preventDefault();
|
|
139
|
-
|
|
146
|
+
setLoadingRuntimeSnapshot(true);
|
|
140
147
|
try {
|
|
141
148
|
setError(undefined);
|
|
142
149
|
const snapshot = runtimeSnapshots.find(s => s.id === selection);
|
|
143
150
|
if (snapshot && (connection || podName)) {
|
|
144
|
-
await
|
|
151
|
+
await onLoadRuntimeSnapshotSubmit({
|
|
145
152
|
connection,
|
|
146
153
|
id: snapshot.id,
|
|
147
154
|
podName,
|
|
@@ -152,14 +159,14 @@ export function RuntimeSnapshotMenu(props) {
|
|
|
152
159
|
}
|
|
153
160
|
}
|
|
154
161
|
finally {
|
|
155
|
-
|
|
162
|
+
setLoadingRuntimeSnapshot(false);
|
|
156
163
|
setOpenLoadDialog(false);
|
|
157
164
|
}
|
|
158
165
|
}
|
|
159
166
|
},
|
|
160
167
|
autoFocus: true,
|
|
161
168
|
},
|
|
162
|
-
], children: _jsxs(Box, { as: "form", children: [_jsxs(FormControl, { children: [_jsx(FormControl.Label, { children: "Snapshot" }), _jsx(Select, { name: "snapshot", value: selection, onChange:
|
|
169
|
+
], children: _jsxs(Box, { as: "form", children: [_jsxs(FormControl, { children: [_jsx(FormControl.Label, { children: "Snapshot" }), _jsx(Select, { name: "snapshot", value: selection, onChange: onRuntimeSnapshotChanged, block: true, children: runtimeSnapshots.map(s => (_jsx(Select.Option, { value: s.id, children: s.name ? `${s.name} (${s.id})` : s.id }, s.id))) })] }), error && _jsx(Flash, { variant: "danger", children: error })] }) }))] }));
|
|
163
170
|
}
|
|
164
171
|
RuntimeSnapshotMenu.defaultProps = {
|
|
165
172
|
disabled: false,
|
|
@@ -63,6 +63,14 @@ export type IDatalayerCoreConfig = {
|
|
|
63
63
|
* AI Agents API URL.
|
|
64
64
|
*/
|
|
65
65
|
aiagentsRunUrl: string;
|
|
66
|
+
/**
|
|
67
|
+
* AI Inference API URL.
|
|
68
|
+
*/
|
|
69
|
+
aiinferenceRunUrl: string;
|
|
70
|
+
/**
|
|
71
|
+
* MCP Servers API URL.
|
|
72
|
+
*/
|
|
73
|
+
mcpserversRunUrl: string;
|
|
66
74
|
/**
|
|
67
75
|
* Growth API URL.
|
|
68
76
|
*/
|
|
@@ -36,7 +36,7 @@ export function useDatalayer(props = {}) {
|
|
|
36
36
|
if (error.name === 'RunResponseError') {
|
|
37
37
|
const responseError = error;
|
|
38
38
|
if (responseError.response.status === 401) {
|
|
39
|
-
console.log('Datalayer
|
|
39
|
+
console.log('Datalayer sent a 401 return code.');
|
|
40
40
|
if (location.pathname !== loginRoute_) {
|
|
41
41
|
iamStore.logout();
|
|
42
42
|
navigate(loginRoute_);
|
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 '../stateful/jupyter/kernelsHandler';
|
|
6
6
|
export const useRuntimes = () => {
|
|
7
7
|
// Folder Mounting ----------------------------------------------------------
|
|
8
8
|
const mountLocalFolder = (kernelId) => {
|
package/lib/hooks/useToast.js
CHANGED
|
@@ -41,7 +41,7 @@ function createContent(message, closeHandler, actions) {
|
|
|
41
41
|
})] }))] }));
|
|
42
42
|
}
|
|
43
43
|
export const useToast = () => {
|
|
44
|
-
// This CANNOT use React hooks as it
|
|
44
|
+
// This CANNOT use Jupyter React hooks as it may be used outside Jupyter React context.
|
|
45
45
|
const insideJupyterLab = isInsideJupyterLab();
|
|
46
46
|
const enqueueToast = (message, options = { variant: 'info' }) => {
|
|
47
47
|
const { actions, autoClose } = options;
|
package/lib/index.d.ts
CHANGED
|
@@ -7,9 +7,8 @@ export * from './hooks';
|
|
|
7
7
|
export { requestDatalayerAPI, RunResponseError, NetworkError, } from './api/DatalayerApi';
|
|
8
8
|
export type { IRequestDatalayerAPIOptions } from './api/DatalayerApi';
|
|
9
9
|
export { API_BASE_PATHS } from './api/constants';
|
|
10
|
-
export * from './api/types';
|
|
11
10
|
export * as runtimesApi from './api/runtimes';
|
|
12
11
|
export * as iamApi from './api/iam';
|
|
13
12
|
export * as spacerApi from './api/spacer';
|
|
14
|
-
export {
|
|
15
|
-
export { getEnvironments, createRuntime, getRuntimes, deleteRuntime, snapshotRuntime, getRuntimeSnapshots, loadRuntimeSnapshot, } from './
|
|
13
|
+
export { DatalayerClient, type DatalayerClientConfig, type SDKHandlers, User, Runtime, Environment, Snapshot, Space, Notebook, LexicalDTO, Credits, Item, type RuntimeJSON, type EnvironmentJSON, type UserJSON, } from './client';
|
|
14
|
+
export { getEnvironments, createRuntime, getRuntimes, deleteRuntime, snapshotRuntime, getRuntimeSnapshots, loadRuntimeSnapshot, } from './stateful/runtimes/actions';
|
package/lib/index.js
CHANGED
|
@@ -12,10 +12,11 @@ export * from './hooks';
|
|
|
12
12
|
// Export API and SDK layers
|
|
13
13
|
export { requestDatalayerAPI, RunResponseError, NetworkError, } from './api/DatalayerApi';
|
|
14
14
|
export { API_BASE_PATHS } from './api/constants';
|
|
15
|
-
export * from './api/types';
|
|
16
15
|
export * as runtimesApi from './api/runtimes';
|
|
17
16
|
export * as iamApi from './api/iam';
|
|
18
17
|
export * as spacerApi from './api/spacer';
|
|
19
|
-
export {
|
|
18
|
+
export { DatalayerClient,
|
|
19
|
+
// Export SDK models
|
|
20
|
+
User, Runtime, Environment, Snapshot, Space, Notebook, LexicalDTO, Credits, Item, } from './client';
|
|
20
21
|
// Export commonly used SDK functions directly for convenience
|
|
21
|
-
export { getEnvironments, createRuntime, getRuntimes, deleteRuntime, snapshotRuntime, getRuntimeSnapshots, loadRuntimeSnapshot, } from './
|
|
22
|
+
export { getEnvironments, createRuntime, getRuntimes, deleteRuntime, snapshotRuntime, getRuntimeSnapshots, loadRuntimeSnapshot, } from './stateful/runtimes/actions';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common types shared across all Datalayer API services.
|
|
3
|
+
*
|
|
4
|
+
* @module api/types/common
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Standard health check response used by all services.
|
|
8
|
+
* @interface HealthzPingResponse
|
|
9
|
+
*/
|
|
10
|
+
export interface HealthzPingResponse {
|
|
11
|
+
/** Whether the request was successful */
|
|
12
|
+
success: boolean;
|
|
13
|
+
/** Response message from the server */
|
|
14
|
+
message: string;
|
|
15
|
+
/** Service status information */
|
|
16
|
+
status?: {
|
|
17
|
+
/** Status indicator (e.g., "OK") */
|
|
18
|
+
status: string;
|
|
19
|
+
};
|
|
20
|
+
/** API version */
|
|
21
|
+
version?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Standard error response structure.
|
|
25
|
+
* @interface ErrorResponse
|
|
26
|
+
*/
|
|
27
|
+
export interface ErrorResponse {
|
|
28
|
+
/** Whether the request was successful (always false for errors) */
|
|
29
|
+
success: false;
|
|
30
|
+
/** Error message */
|
|
31
|
+
message: string;
|
|
32
|
+
/** Optional error code */
|
|
33
|
+
code?: string;
|
|
34
|
+
/** Optional additional error details */
|
|
35
|
+
details?: any;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Standard pagination parameters.
|
|
39
|
+
* @interface PaginationParams
|
|
40
|
+
*/
|
|
41
|
+
export interface PaginationParams {
|
|
42
|
+
/** Page number (1-based) */
|
|
43
|
+
page?: number;
|
|
44
|
+
/** Items per page */
|
|
45
|
+
limit?: number;
|
|
46
|
+
/** Sort field */
|
|
47
|
+
sort?: string;
|
|
48
|
+
/** Sort order */
|
|
49
|
+
order?: 'asc' | 'desc';
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Standard pagination response metadata.
|
|
53
|
+
* @interface PaginationMeta
|
|
54
|
+
*/
|
|
55
|
+
export interface PaginationMeta {
|
|
56
|
+
/** Current page */
|
|
57
|
+
page: number;
|
|
58
|
+
/** Items per page */
|
|
59
|
+
limit: number;
|
|
60
|
+
/** Total number of items */
|
|
61
|
+
total: number;
|
|
62
|
+
/** Total number of pages */
|
|
63
|
+
totalPages: number;
|
|
64
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credit information for a user.
|
|
3
|
+
*/
|
|
4
|
+
export interface CreditsInfo {
|
|
5
|
+
/** Available credits */
|
|
6
|
+
credits: number;
|
|
7
|
+
/** Credit quota (null if unlimited) */
|
|
8
|
+
quota: number | null;
|
|
9
|
+
/** Last update timestamp */
|
|
10
|
+
last_update: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Credit reservation information.
|
|
14
|
+
*/
|
|
15
|
+
export interface CreditReservation {
|
|
16
|
+
/** Reservation ID */
|
|
17
|
+
id: string;
|
|
18
|
+
/** Reserved credits */
|
|
19
|
+
credits: number;
|
|
20
|
+
/** Resource ID (e.g., runtime ID) */
|
|
21
|
+
resource: string;
|
|
22
|
+
/** Last update timestamp */
|
|
23
|
+
last_update: string;
|
|
24
|
+
/** Burning rate (credits per hour) for this reservation */
|
|
25
|
+
burning_rate: number;
|
|
26
|
+
/** Start date of the reservation */
|
|
27
|
+
start_date: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Response from the credits endpoint.
|
|
31
|
+
*/
|
|
32
|
+
export interface CreditsResponse {
|
|
33
|
+
/** Operation success status */
|
|
34
|
+
success: boolean;
|
|
35
|
+
/** Credit information */
|
|
36
|
+
credits: CreditsInfo;
|
|
37
|
+
/** Active credit reservations */
|
|
38
|
+
reservations: CreditReservation[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Credits model representing user's available credits and usage.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const credits = await sdk.getCredits();
|
|
46
|
+
* console.log(`Available: ${credits.available}`);
|
|
47
|
+
* console.log(`Quota: ${credits.quota || 'unlimited'}`);
|
|
48
|
+
*
|
|
49
|
+
* // Calculate maximum runtime for an environment
|
|
50
|
+
* const maxMinutes = credits.calculateMaxRuntimeMinutes(environment.burningRate);
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare class CreditsDTO {
|
|
54
|
+
/** @internal */
|
|
55
|
+
_data: CreditsInfo;
|
|
56
|
+
private _reservations;
|
|
57
|
+
constructor(data: CreditsInfo, reservations?: CreditReservation[]);
|
|
58
|
+
/**
|
|
59
|
+
* Available credits for the user.
|
|
60
|
+
*/
|
|
61
|
+
get available(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Credit quota for the user.
|
|
64
|
+
* Returns null if unlimited.
|
|
65
|
+
*/
|
|
66
|
+
get quota(): number | null;
|
|
67
|
+
/**
|
|
68
|
+
* Last update timestamp.
|
|
69
|
+
*/
|
|
70
|
+
get lastUpdate(): string;
|
|
71
|
+
/**
|
|
72
|
+
* Active credit reservations.
|
|
73
|
+
*/
|
|
74
|
+
get reservations(): CreditReservation[];
|
|
75
|
+
/**
|
|
76
|
+
* Total reserved credits across all reservations.
|
|
77
|
+
*/
|
|
78
|
+
get totalReserved(): number;
|
|
79
|
+
/**
|
|
80
|
+
* Net available credits (available minus reserved).
|
|
81
|
+
*/
|
|
82
|
+
get netAvailable(): number;
|
|
83
|
+
/**
|
|
84
|
+
* Get runtime reservations (reservations that start with 'runtime-').
|
|
85
|
+
*/
|
|
86
|
+
get runtimeReservations(): CreditReservation[];
|
|
87
|
+
/**
|
|
88
|
+
* Check if there are any active runtime reservations.
|
|
89
|
+
*/
|
|
90
|
+
get hasActiveRuntimes(): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Calculate maximum runtime in minutes based on environment burning rate.
|
|
93
|
+
*
|
|
94
|
+
* @param burningRate - Credits consumed per hour
|
|
95
|
+
* @returns Maximum runtime in minutes
|
|
96
|
+
*/
|
|
97
|
+
calculateMaxRuntimeMinutes(burningRate: number): number;
|
|
98
|
+
/**
|
|
99
|
+
* Calculate credits needed for runtime duration.
|
|
100
|
+
*
|
|
101
|
+
* @param minutes - Runtime duration in minutes
|
|
102
|
+
* @param burningRate - Credits consumed per hour
|
|
103
|
+
* @returns Credits needed
|
|
104
|
+
*/
|
|
105
|
+
calculateCreditsFromMinutes(minutes: number, burningRate: number): number;
|
|
106
|
+
/**
|
|
107
|
+
* Check if user has enough credits for runtime.
|
|
108
|
+
*
|
|
109
|
+
* @param minutes - Runtime duration in minutes
|
|
110
|
+
* @param burningRate - Credits consumed per hour
|
|
111
|
+
* @returns True if user has enough credits
|
|
112
|
+
*/
|
|
113
|
+
hasEnoughCreditsForRuntime(minutes: number, burningRate: number): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Convert to JSON representation.
|
|
116
|
+
*/
|
|
117
|
+
toJSON(): CreditsInfo & {
|
|
118
|
+
reservations: CreditReservation[];
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* String representation of credits.
|
|
122
|
+
*/
|
|
123
|
+
toString(): string;
|
|
124
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Credits model for the Datalayer SDK.
|
|
7
|
+
*
|
|
8
|
+
* @module models/CreditsDTO
|
|
9
|
+
*/
|
|
10
|
+
import { validateJSON } from '../api/utils/validation';
|
|
11
|
+
/**
|
|
12
|
+
* Credits model representing user's available credits and usage.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const credits = await sdk.getCredits();
|
|
17
|
+
* console.log(`Available: ${credits.available}`);
|
|
18
|
+
* console.log(`Quota: ${credits.quota || 'unlimited'}`);
|
|
19
|
+
*
|
|
20
|
+
* // Calculate maximum runtime for an environment
|
|
21
|
+
* const maxMinutes = credits.calculateMaxRuntimeMinutes(environment.burningRate);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export class CreditsDTO {
|
|
25
|
+
/** @internal */
|
|
26
|
+
_data;
|
|
27
|
+
_reservations;
|
|
28
|
+
constructor(data, reservations = []) {
|
|
29
|
+
this._data = data;
|
|
30
|
+
this._reservations = reservations;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Available credits for the user.
|
|
34
|
+
*/
|
|
35
|
+
get available() {
|
|
36
|
+
return this._data.credits;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Credit quota for the user.
|
|
40
|
+
* Returns null if unlimited.
|
|
41
|
+
*/
|
|
42
|
+
get quota() {
|
|
43
|
+
return this._data.quota;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Last update timestamp.
|
|
47
|
+
*/
|
|
48
|
+
get lastUpdate() {
|
|
49
|
+
return this._data.last_update;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Active credit reservations.
|
|
53
|
+
*/
|
|
54
|
+
get reservations() {
|
|
55
|
+
return [...this._reservations];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Total reserved credits across all reservations.
|
|
59
|
+
*/
|
|
60
|
+
get totalReserved() {
|
|
61
|
+
return this._reservations.reduce((sum, r) => sum + r.credits, 0);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Net available credits (available minus reserved).
|
|
65
|
+
*/
|
|
66
|
+
get netAvailable() {
|
|
67
|
+
return Math.max(0, this.available - this.totalReserved);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get runtime reservations (reservations that start with 'runtime-').
|
|
71
|
+
*/
|
|
72
|
+
get runtimeReservations() {
|
|
73
|
+
return this._reservations.filter(r => r.id.startsWith('runtime-'));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Check if there are any active runtime reservations.
|
|
77
|
+
*/
|
|
78
|
+
get hasActiveRuntimes() {
|
|
79
|
+
return this.runtimeReservations.length > 0;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Calculate maximum runtime in minutes based on environment burning rate.
|
|
83
|
+
*
|
|
84
|
+
* @param burningRate - Credits consumed per hour
|
|
85
|
+
* @returns Maximum runtime in minutes
|
|
86
|
+
*/
|
|
87
|
+
calculateMaxRuntimeMinutes(burningRate) {
|
|
88
|
+
if (burningRate <= 0)
|
|
89
|
+
return 0;
|
|
90
|
+
const burningRatePerMinute = burningRate * 60;
|
|
91
|
+
return Math.floor(this.netAvailable / burningRatePerMinute);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Calculate credits needed for runtime duration.
|
|
95
|
+
*
|
|
96
|
+
* @param minutes - Runtime duration in minutes
|
|
97
|
+
* @param burningRate - Credits consumed per hour
|
|
98
|
+
* @returns Credits needed
|
|
99
|
+
*/
|
|
100
|
+
calculateCreditsFromMinutes(minutes, burningRate) {
|
|
101
|
+
const burningRatePerMinute = burningRate * 60;
|
|
102
|
+
return minutes * burningRatePerMinute;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Check if user has enough credits for runtime.
|
|
106
|
+
*
|
|
107
|
+
* @param minutes - Runtime duration in minutes
|
|
108
|
+
* @param burningRate - Credits consumed per hour
|
|
109
|
+
* @returns True if user has enough credits
|
|
110
|
+
*/
|
|
111
|
+
hasEnoughCreditsForRuntime(minutes, burningRate) {
|
|
112
|
+
const creditsNeeded = this.calculateCreditsFromMinutes(minutes, burningRate);
|
|
113
|
+
return this.netAvailable >= creditsNeeded;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Convert to JSON representation.
|
|
117
|
+
*/
|
|
118
|
+
toJSON() {
|
|
119
|
+
// FIXME
|
|
120
|
+
const obj = {
|
|
121
|
+
...this._data,
|
|
122
|
+
reservations: this._reservations,
|
|
123
|
+
};
|
|
124
|
+
validateJSON(obj, 'Credits');
|
|
125
|
+
return obj;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* String representation of credits.
|
|
129
|
+
*/
|
|
130
|
+
toString() {
|
|
131
|
+
const quotaStr = this.quota !== null ? ` of ${this.quota}` : '';
|
|
132
|
+
const reservedStr = this.totalReserved > 0 ? ` (${this.totalReserved} reserved)` : '';
|
|
133
|
+
return `Credits: ${this.available}${quotaStr}${reservedStr}`;
|
|
134
|
+
}
|
|
135
|
+
}
|