@datalayer/core 1.0.19 → 1.0.21
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 +27 -0
- package/lib/api/DatalayerApi.d.ts +5 -1
- package/lib/api/DatalayerApi.js +55 -8
- package/lib/api/iam/oauth2.d.ts +3 -3
- package/lib/api/iam/oauth2.js +2 -2
- package/lib/api/iam/profile.d.ts +9 -1
- package/lib/api/iam/profile.js +15 -0
- package/lib/api/runtimes/checkpoints.js +1 -1
- package/lib/api/runtimes/snapshots.d.ts +7 -7
- package/lib/api/runtimes/snapshots.js +9 -9
- package/lib/client/auth/storage.js +103 -12
- package/lib/client/index.d.ts +7 -7
- package/lib/client/index.js +1 -1
- package/lib/client/mixins/RuntimesMixin.d.ts +6 -6
- package/lib/client/mixins/RuntimesMixin.js +5 -5
- package/lib/client/mixins/SpacerMixin.js +22 -1
- package/lib/collaboration/DatalayerCollaborationProvider.d.ts +4 -3
- package/lib/components/avatars/DLAvatar.d.ts +24 -0
- package/lib/components/avatars/DLAvatar.js +26 -0
- package/lib/components/avatars/UserProfileAvatar.js +4 -4
- package/lib/components/avatars/index.d.ts +1 -0
- package/lib/components/avatars/index.js +1 -0
- package/lib/components/checkout/StripeCheckout.d.ts +24 -3
- package/lib/components/checkout/StripeCheckout.js +1116 -55
- package/lib/components/display/DatalayerBox.js +6 -1
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +2 -2
- package/lib/components/snapshots/{RuntimeSnapshotMenu.d.ts → SandboxSnapshotMenu.d.ts} +4 -4
- package/lib/components/snapshots/{RuntimeSnapshotMenu.js → SandboxSnapshotMenu.js} +33 -33
- package/lib/components/snapshots/index.d.ts +1 -1
- package/lib/components/snapshots/index.js +1 -1
- package/lib/components/storage/ContentsBrowser.js +2 -2
- package/lib/components/tokens/SpaceVariantToken.d.ts +1 -1
- package/lib/components/tokens/SpaceVariantToken.js +7 -4
- package/lib/components/users/PeerIndicator.js +5 -4
- package/lib/hooks/useCache.d.ts +125 -18
- package/lib/hooks/useCache.js +893 -120
- package/lib/hooks/useDatalayer.js +31 -3
- package/lib/hooks/useIAM.js +1 -8
- package/lib/hooks/useProjects.d.ts +44 -0
- package/lib/hooks/useProjects.js +26 -2
- package/lib/index.d.ts +2 -2
- package/lib/index.js +1 -1
- package/lib/mocks/components/FlashMock.js +8 -2
- package/lib/models/{RuntimeSnapshot.d.ts → CodeSandboxSnapshot.d.ts} +5 -5
- package/lib/models/{RuntimeSnapshot.js → CodeSandboxSnapshot.js} +1 -1
- package/lib/models/{RuntimeSnapshotDTO.d.ts → CodeSandboxSnapshotDTO.d.ts} +30 -30
- package/lib/models/{RuntimeSnapshotDTO.js → CodeSandboxSnapshotDTO.js} +6 -6
- package/lib/models/Environment.d.ts +4 -0
- package/lib/models/IAM.d.ts +66 -0
- package/lib/models/Organization.d.ts +1 -0
- package/lib/models/Organization.js +1 -0
- package/lib/models/Page.d.ts +2 -2
- package/lib/models/Page.js +2 -2
- package/lib/models/Profile.d.ts +1 -1
- package/lib/models/RuntimeDTO.d.ts +2 -2
- package/lib/models/Space.d.ts +1 -0
- package/lib/models/Space.js +29 -5
- package/lib/models/SpaceDTO.d.ts +4 -0
- package/lib/models/SpaceDTO.js +5 -0
- package/lib/models/Usage.d.ts +15 -0
- package/lib/models/Usage.js +9 -0
- package/lib/models/User.d.ts +21 -0
- package/lib/models/User.js +6 -2
- package/lib/models/index.d.ts +2 -2
- package/lib/models/index.js +2 -2
- package/lib/otel/auth.js +0 -4
- package/lib/services/index.d.ts +1 -1
- package/lib/services/index.js +1 -1
- package/lib/state/substates/IAMState.js +0 -7
- package/lib/state/substates/RuntimesState.d.ts +9 -9
- package/lib/state/substates/RuntimesState.js +3 -3
- package/lib/stateful/runtimes/actions.d.ts +17 -17
- package/lib/stateful/runtimes/actions.js +35 -55
- package/lib/stateful/runtimes/apis.d.ts +3 -3
- package/lib/stateful/runtimes/snapshots.d.ts +2 -2
- package/lib/stateful/runtimes/snapshots.js +7 -7
- package/lib/utils/Format.d.ts +6 -0
- package/lib/utils/Format.js +17 -0
- package/lib/utils/Snapshot.d.ts +1 -1
- package/lib/utils/Snapshot.js +1 -1
- package/lib/views/datasources/DatasourceDetail.d.ts +7 -1
- package/lib/views/datasources/DatasourceDetail.js +61 -23
- package/lib/views/datasources/DatasourceNew.d.ts +8 -1
- package/lib/views/datasources/DatasourceNew.js +23 -10
- package/lib/views/datasources/Datasources.d.ts +5 -1
- package/lib/views/datasources/Datasources.js +38 -30
- package/lib/views/iam/SignInSimple.d.ts +1 -1
- package/lib/views/iam/SignInSimple.js +52 -28
- package/lib/views/iam-tokens/IAMTokenNew.d.ts +3 -1
- package/lib/views/iam-tokens/IAMTokenNew.js +2 -2
- package/lib/views/iam-tokens/IAMTokens.d.ts +3 -1
- package/lib/views/iam-tokens/IAMTokens.js +2 -2
- package/lib/views/otel/OtelHeader.d.ts +5 -0
- package/lib/views/otel/OtelHeader.js +3 -3
- package/lib/views/profile/UserBadge.d.ts +21 -0
- package/lib/views/profile/UserBadge.js +100 -8
- package/lib/views/secrets/Secrets.js +21 -21
- package/package.json +8 -7
|
@@ -15,7 +15,12 @@ export const DatalayerBox = (props) => {
|
|
|
15
15
|
alignItems: 'center',
|
|
16
16
|
justifyContent: 'space-between',
|
|
17
17
|
paddingRight: 4,
|
|
18
|
-
}, children: [_jsx(Text, { as: "h2", sx: { borderLeft: '6px solid #28b899', paddingLeft: 2 }, children: title }), linkRoute && linkLabel && (_jsxs(Link, { href: "javascript: return false;", onClick: e => navigate(linkRoute),
|
|
18
|
+
}, children: [_jsx(Text, { as: "h2", sx: { borderLeft: '6px solid #28b899', paddingLeft: 2 }, children: title }), linkRoute && linkLabel && (_jsxs(Link, { href: "javascript: return false;", onClick: e => navigate(linkRoute), sx: {
|
|
19
|
+
display: 'inline-flex',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
gap: 1,
|
|
22
|
+
whiteSpace: 'nowrap',
|
|
23
|
+
}, children: [linkLabel, _jsx(ArrowRightIcon, {})] }))] }), _jsx(Box, { sx: {
|
|
19
24
|
borderColor: 'border.default',
|
|
20
25
|
borderStyle: 'solid',
|
|
21
26
|
borderWidth: '1',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IMarkdownParser, IRenderMime } from '@jupyterlab/rendermime';
|
|
2
2
|
import type { IRemoteServicesManager } from '../../stateful/runtimes';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ICodeSandboxSnapshot, IRuntimeDesc } from '../../models';
|
|
4
4
|
/**
|
|
5
5
|
* {@link RuntimeLauncherDialog} properties.
|
|
6
6
|
*/
|
|
@@ -37,7 +37,7 @@ export interface IRuntimeLauncherDialogProps {
|
|
|
37
37
|
* If provided the kernel will be started and will
|
|
38
38
|
* restore the provided snapshot in the kernel.
|
|
39
39
|
*/
|
|
40
|
-
kernelSnapshot?:
|
|
40
|
+
kernelSnapshot?: ICodeSandboxSnapshot;
|
|
41
41
|
/**
|
|
42
42
|
* HTML sanitizer
|
|
43
43
|
*/
|
|
@@ -2,9 +2,9 @@ import { type PropsWithChildren } from 'react';
|
|
|
2
2
|
import { Kernel } from '@jupyterlab/services';
|
|
3
3
|
import { IMultiServiceManager } from '../../stateful/runtimes';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Code Sandbox snapshot menu component properties
|
|
6
6
|
*/
|
|
7
|
-
type
|
|
7
|
+
type ICodeSandboxSnapshotMenu = {
|
|
8
8
|
/**
|
|
9
9
|
* Application multi service manager.
|
|
10
10
|
*/
|
|
@@ -27,7 +27,7 @@ type IRuntimeSnapshotMenu = {
|
|
|
27
27
|
disabled: boolean;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Code Sandbox Snapshot menu component.
|
|
31
31
|
*/
|
|
32
|
-
export declare function
|
|
32
|
+
export declare function SandboxSnapshotMenu({ children, connection, podName, multiServiceManager, disabled, }: PropsWithChildren<ICodeSandboxSnapshotMenu>): JSX.Element;
|
|
33
33
|
export {};
|
|
@@ -4,29 +4,29 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
6
|
import { useCallback, useEffect, useState, } from 'react';
|
|
7
|
-
import {
|
|
7
|
+
import { DeviceCameraIcon } from '@primer/octicons-react';
|
|
8
8
|
import { ActionList, ActionMenu, Flash, FormControl, Select, Spinner, } from '@primer/react';
|
|
9
9
|
import { Dialog } from '@primer/react/experimental';
|
|
10
10
|
import { Box } from '@datalayer/primer-addons';
|
|
11
11
|
import { useToast } from '../../hooks/index.js';
|
|
12
|
-
import {
|
|
12
|
+
import { createSandboxSnapshot, getSandboxSnapshots, loadBrowserSandboxSnapshot, loadSandboxSnapshot, } from '../../stateful/runtimes/index.js';
|
|
13
13
|
import { useRuntimesStore } from '../../state/index.js';
|
|
14
|
-
import {
|
|
14
|
+
import { createSandboxSnapshotName } from '../../utils/index.js';
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Code Sandbox Snapshot menu component.
|
|
17
17
|
*/
|
|
18
|
-
export function
|
|
19
|
-
const {
|
|
18
|
+
export function SandboxSnapshotMenu({ children, connection, podName, multiServiceManager, disabled = false, }) {
|
|
19
|
+
const { addSandboxSnapshot, runtimesRunUrl, runtimeSnapshots, setSandboxSnapshots, } = useRuntimesStore();
|
|
20
20
|
const { enqueueToast, trackAsyncTask } = useToast();
|
|
21
21
|
const [openLoadDialog, setOpenLoadDialog] = useState(false);
|
|
22
|
-
const [
|
|
23
|
-
const [
|
|
22
|
+
const [loadingSandboxSnapshot, setLoadingSandboxSnapshot] = useState(false);
|
|
23
|
+
const [takingSandboxSnapshot, setTakingSandboxSnapshot] = useState(false);
|
|
24
24
|
const [selection, setSelection] = useState(runtimeSnapshots[0]?.id ?? '');
|
|
25
25
|
const [error, setError] = useState();
|
|
26
26
|
useEffect(() => {
|
|
27
|
-
|
|
27
|
+
getSandboxSnapshots()
|
|
28
28
|
.then(snapshots => {
|
|
29
|
-
|
|
29
|
+
setSandboxSnapshots(snapshots);
|
|
30
30
|
if (!selection && snapshots.length > 0) {
|
|
31
31
|
setSelection(snapshots[0].id);
|
|
32
32
|
}
|
|
@@ -35,36 +35,36 @@ export function RuntimeSnapshotMenu({ children, connection, podName, multiServic
|
|
|
35
35
|
console.error(`Failed to fetch remote kernel snapshots; ${reason}`);
|
|
36
36
|
});
|
|
37
37
|
}, [runtimesRunUrl]);
|
|
38
|
-
const
|
|
38
|
+
const onLoadSandboxSnapshot = useCallback(() => {
|
|
39
39
|
setError(undefined);
|
|
40
40
|
setOpenLoadDialog(true);
|
|
41
41
|
}, []);
|
|
42
|
-
const
|
|
42
|
+
const onSandboxSnapshotChanged = useCallback(event => {
|
|
43
43
|
setSelection(event.target.value);
|
|
44
44
|
}, []);
|
|
45
|
-
const
|
|
45
|
+
const onLoadSandboxSnapshotSubmit = useCallback(async ({ id, connection, podName, }) => {
|
|
46
46
|
if (podName) {
|
|
47
|
-
await
|
|
48
|
-
enqueueToast(`
|
|
47
|
+
await loadSandboxSnapshot({ id: podName, from: id });
|
|
48
|
+
enqueueToast(`Code Sandbox snapshot ${podName} is loaded.`, {
|
|
49
49
|
variant: 'success',
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
else if (connection) {
|
|
53
|
-
await
|
|
54
|
-
enqueueToast(`
|
|
53
|
+
await loadBrowserSandboxSnapshot({ connection, id });
|
|
54
|
+
enqueueToast(`Code Sandbox snapshot ${id} is loaded.`, {
|
|
55
55
|
variant: 'success',
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
}, []);
|
|
59
|
-
const
|
|
59
|
+
const onTakeSandboxSnapshot = useCallback(async () => {
|
|
60
60
|
try {
|
|
61
|
-
|
|
61
|
+
setTakingSandboxSnapshot(true);
|
|
62
62
|
let snapshot;
|
|
63
63
|
let task;
|
|
64
64
|
let ref = '';
|
|
65
65
|
let snapshotName = '';
|
|
66
66
|
if (podName && multiServiceManager?.remote) {
|
|
67
|
-
snapshotName =
|
|
67
|
+
snapshotName = createSandboxSnapshotName('cloud');
|
|
68
68
|
task = multiServiceManager.remote.runtimesManager.snapshotRuntime({
|
|
69
69
|
podName,
|
|
70
70
|
name: snapshotName,
|
|
@@ -79,9 +79,9 @@ export function RuntimeSnapshotMenu({ children, connection, podName, multiServic
|
|
|
79
79
|
else if (connection && multiServiceManager?.browser) {
|
|
80
80
|
const model = connection.model;
|
|
81
81
|
ref = model.id;
|
|
82
|
-
snapshotName =
|
|
82
|
+
snapshotName = createSandboxSnapshotName('browser');
|
|
83
83
|
let isPending = true;
|
|
84
|
-
task =
|
|
84
|
+
task = createSandboxSnapshot({
|
|
85
85
|
connection: multiServiceManager.browser.kernels.connectTo({
|
|
86
86
|
model,
|
|
87
87
|
}),
|
|
@@ -90,7 +90,7 @@ export function RuntimeSnapshotMenu({ children, connection, podName, multiServic
|
|
|
90
90
|
if (isPending) {
|
|
91
91
|
isPending = false;
|
|
92
92
|
// Get the kernel snapshot uid.
|
|
93
|
-
|
|
93
|
+
getSandboxSnapshots().then(snapshots => {
|
|
94
94
|
snapshot = snapshots.find(s => s.name === snapshotName);
|
|
95
95
|
});
|
|
96
96
|
}
|
|
@@ -114,15 +114,15 @@ export function RuntimeSnapshotMenu({ children, connection, podName, multiServic
|
|
|
114
114
|
});
|
|
115
115
|
await task;
|
|
116
116
|
if (snapshot) {
|
|
117
|
-
|
|
117
|
+
addSandboxSnapshot(snapshot);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
finally {
|
|
122
|
-
|
|
122
|
+
setTakingSandboxSnapshot(false);
|
|
123
123
|
}
|
|
124
124
|
}, [connection, podName, multiServiceManager]);
|
|
125
|
-
return (_jsxs(_Fragment, { children: [_jsxs(ActionMenu, { children: [_jsx(ActionMenu.Button, { leadingVisual:
|
|
125
|
+
return (_jsxs(_Fragment, { children: [_jsxs(ActionMenu, { children: [_jsx(ActionMenu.Button, { leadingVisual: DeviceCameraIcon, variant: "invisible", size: "small", disabled: loadingSandboxSnapshot || takingSandboxSnapshot || disabled, children: children }), _jsx(ActionMenu.Overlay, { children: _jsxs(ActionList, { children: [_jsx(ActionList.Item, { onSelect: onLoadSandboxSnapshot, disabled: loadingSandboxSnapshot || runtimeSnapshots.length === 0, children: "Load a code sandbox snapshot\u2026" }), _jsx(ActionList.Item, { onSelect: onTakeSandboxSnapshot, disabled: takingSandboxSnapshot, children: "Take a code sandbox snapshot" })] }) })] }), openLoadDialog && (_jsx(Dialog, { title: _jsx("span", { style: { color: 'var(--fgColor-default)' }, children: "Choose a code sandbox snapshot to load" }), onClose: () => {
|
|
126
126
|
setOpenLoadDialog(false);
|
|
127
127
|
}, footerButtons: [
|
|
128
128
|
{
|
|
@@ -137,33 +137,33 @@ export function RuntimeSnapshotMenu({ children, connection, podName, multiServic
|
|
|
137
137
|
},
|
|
138
138
|
{
|
|
139
139
|
buttonType: 'primary',
|
|
140
|
-
content:
|
|
141
|
-
disabled:
|
|
140
|
+
content: loadingSandboxSnapshot ? (_jsx(Spinner, { size: "small" })) : ('Load'),
|
|
141
|
+
disabled: loadingSandboxSnapshot,
|
|
142
142
|
onClick: async (event) => {
|
|
143
143
|
if (!event.defaultPrevented) {
|
|
144
144
|
event.preventDefault();
|
|
145
|
-
|
|
145
|
+
setLoadingSandboxSnapshot(true);
|
|
146
146
|
try {
|
|
147
147
|
setError(undefined);
|
|
148
148
|
const snapshot = runtimeSnapshots.find(s => s.id === selection);
|
|
149
149
|
if (snapshot && (connection || podName)) {
|
|
150
|
-
await
|
|
150
|
+
await onLoadSandboxSnapshotSubmit({
|
|
151
151
|
connection,
|
|
152
152
|
id: snapshot.id,
|
|
153
153
|
podName,
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
else {
|
|
157
|
-
setError('No
|
|
157
|
+
setError('No code sandbox snapshot found.');
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
finally {
|
|
161
|
-
|
|
161
|
+
setLoadingSandboxSnapshot(false);
|
|
162
162
|
setOpenLoadDialog(false);
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
},
|
|
166
166
|
autoFocus: true,
|
|
167
167
|
},
|
|
168
|
-
], children: _jsxs(Box, { as: "form", children: [_jsxs(FormControl, { children: [_jsx(FormControl.Label, { children: "Snapshot" }), _jsx(Select, { name: "snapshot", value: selection, onChange:
|
|
168
|
+
], children: _jsxs(Box, { as: "form", children: [_jsxs(FormControl, { children: [_jsx(FormControl.Label, { children: "Snapshot" }), _jsx(Select, { name: "snapshot", value: selection, onChange: onSandboxSnapshotChanged, 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 })] }) }))] }));
|
|
169
169
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './SandboxSnapshotMenu';
|
|
@@ -9,7 +9,7 @@ import { PromiseDelegate } from '@lumino/coreutils';
|
|
|
9
9
|
import { ActionList, ActionMenu, Heading, IconButton, Spinner, TreeView, } from '@primer/react';
|
|
10
10
|
import { Box } from '@datalayer/primer-addons';
|
|
11
11
|
import { Blankslate, Dialog } from '@primer/react/experimental';
|
|
12
|
-
import {
|
|
12
|
+
import { SyncIcon } from '@primer/octicons-react';
|
|
13
13
|
import { useIsMounted } from 'usehooks-ts';
|
|
14
14
|
import { useToast } from '../../hooks/index.js';
|
|
15
15
|
import { UploadIconButton } from '../buttons/index.js';
|
|
@@ -225,7 +225,7 @@ export function ContentsBrowser(props) {
|
|
|
225
225
|
alignItems: 'center',
|
|
226
226
|
flexWrap: 'nowrap',
|
|
227
227
|
flexShrink: 0,
|
|
228
|
-
}, children: [_jsx(IconButton, { variant: "invisible", "aria-label": 'Refresh contents browser.', title: 'Refresh contents browser.', icon:
|
|
228
|
+
}, children: [_jsx(IconButton, { variant: "invisible", "aria-label": 'Refresh contents browser.', title: 'Refresh contents browser.', icon: SyncIcon, onClick: refresh }), _jsx(UploadIconButton, { label: 'Upload a file', multiple: true, upload: upload })] })] }), isLoading ? (_jsx(Box, { sx: {
|
|
229
229
|
gridArea: 'content',
|
|
230
230
|
display: 'flex',
|
|
231
231
|
alignItems: 'center',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
/*
|
|
3
3
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
@@ -7,14 +7,17 @@ import { Token } from '@primer/react';
|
|
|
7
7
|
import { ProjectIcon } from '@primer/octicons-react';
|
|
8
8
|
import { StudentIcon } from '@datalayer/icons-react';
|
|
9
9
|
export const SpaceVariantToken = (props) => {
|
|
10
|
-
const
|
|
10
|
+
const variant = String(props.variant || 'default').toLowerCase();
|
|
11
|
+
if (variant.includes('project')) {
|
|
12
|
+
return _jsx(Token, { text: "project", leadingVisual: ProjectIcon });
|
|
13
|
+
}
|
|
11
14
|
switch (variant) {
|
|
12
15
|
case 'default':
|
|
13
|
-
return _jsx(Token, { text: "default"
|
|
16
|
+
return _jsx(Token, { text: "default" });
|
|
14
17
|
case 'course':
|
|
15
18
|
return _jsx(Token, { text: "course", leadingVisual: StudentIcon });
|
|
16
19
|
default:
|
|
17
|
-
return _jsx(
|
|
20
|
+
return _jsx(Token, { text: String(variant || 'default') });
|
|
18
21
|
}
|
|
19
22
|
};
|
|
20
23
|
export default SpaceVariantToken;
|
|
@@ -4,8 +4,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
6
|
import { useEffect, useState } from 'react';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { AvatarStack } from '@primer/react';
|
|
8
|
+
import { getRelativeTime } from '../../utils/index.js';
|
|
9
|
+
import { DLAvatar } from '../avatars/index.js';
|
|
9
10
|
const AVATAR_SIZE = 28;
|
|
10
11
|
const SPACER_USER_AGENT = 'DatalayerSpacer';
|
|
11
12
|
const AWARENESS_NOTIFICATION_TIMEOUT_MS = 30_000;
|
|
@@ -89,12 +90,12 @@ export function PeersIndicator({ awareness, currentUserHandle, }) {
|
|
|
89
90
|
if (peer.notification) {
|
|
90
91
|
title += `\n${peer.notification}`;
|
|
91
92
|
}
|
|
92
|
-
return (_jsx(
|
|
93
|
+
return (_jsx(DLAvatar, { sx: {
|
|
93
94
|
border: peer.notificationType
|
|
94
95
|
? `var(--borderWidth-thick) solid ${peer.notificationType}`
|
|
95
96
|
: 'none',
|
|
96
97
|
}, title: title, src: peer.avatarUrl
|
|
97
|
-
?
|
|
98
|
+
? peer.avatarUrl
|
|
98
99
|
: defaultAvatarSrc(peer.color, peer.initials), size: AVATAR_SIZE }, peer.displayName));
|
|
99
100
|
}) }));
|
|
100
101
|
}
|
package/lib/hooks/useCache.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TanStack Query-based cache hook for Datalayer API
|
|
3
|
+
* for automatic cache management, background refetching,
|
|
4
|
+
* and optimistic updates.
|
|
3
5
|
*
|
|
4
|
-
* This is a modernized replacement for useCache.tsx that leverages TanStack Query
|
|
5
|
-
* for automatic cache management, background refetching, and optimistic updates.
|
|
6
|
-
*
|
|
7
|
-
* Key improvements over useCache:
|
|
8
6
|
* - Automatic cache management (no manual Map objects)
|
|
9
7
|
* - Built-in loading/error states
|
|
10
8
|
* - Automatic refetching and deduplication
|
|
@@ -64,7 +62,9 @@ export declare const queryKeys: {
|
|
|
64
62
|
readonly details: () => readonly ["users", "detail"];
|
|
65
63
|
readonly detail: (id: string) => readonly ["users", "detail", string];
|
|
66
64
|
readonly byHandle: (handle: string) => readonly ["users", "handle", string];
|
|
65
|
+
readonly publicProfileByHandle: (handle: string) => readonly ["users", "public-profile", string];
|
|
67
66
|
readonly search: (pattern: string) => readonly ["users", "search", string];
|
|
67
|
+
readonly bulk: (userIdsKey: string) => readonly ["users", "bulk", string];
|
|
68
68
|
readonly settings: (userId: string) => readonly ["users", "detail", string, "settings"];
|
|
69
69
|
readonly onboarding: (userId: string) => readonly ["users", "detail", string, "onboarding"];
|
|
70
70
|
readonly surveys: (userId: string) => readonly ["users", "detail", string, "surveys"];
|
|
@@ -76,6 +76,7 @@ export declare const queryKeys: {
|
|
|
76
76
|
readonly details: () => readonly ["organizations", "detail"];
|
|
77
77
|
readonly detail: (id: string) => readonly ["organizations", "detail", string];
|
|
78
78
|
readonly byHandle: (handle: string) => readonly ["organizations", "handle", string];
|
|
79
|
+
readonly publicProfileByHandle: (handle: string) => readonly ["organizations", "public-profile", string];
|
|
79
80
|
readonly userOrgs: () => readonly ["organizations", "user"];
|
|
80
81
|
readonly members: (orgId: string) => readonly ["organizations", "detail", string, "members"];
|
|
81
82
|
};
|
|
@@ -220,6 +221,12 @@ export declare const queryKeys: {
|
|
|
220
221
|
readonly userById: (userId: string) => readonly ["usages", "user", string];
|
|
221
222
|
readonly platform: () => readonly ["usages", "platform"];
|
|
222
223
|
};
|
|
224
|
+
readonly credits: {
|
|
225
|
+
readonly organizationOverview: (organizationUid: string) => readonly ["credits", "allocations", "organization", string];
|
|
226
|
+
readonly organizationHistory: (organizationUid: string) => readonly ["credits", "allocations", "organization", string, "history"];
|
|
227
|
+
readonly teamOverview: (teamUid: string) => readonly ["credits", "allocations", "team", string];
|
|
228
|
+
readonly teamHistory: (teamUid: string) => readonly ["credits", "allocations", "team", string, "history"];
|
|
229
|
+
};
|
|
223
230
|
readonly prices: {
|
|
224
231
|
readonly stripe: () => readonly ["prices", "stripe"];
|
|
225
232
|
};
|
|
@@ -342,7 +349,9 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
342
349
|
}, unknown>;
|
|
343
350
|
useUser: (userId: string) => import("@tanstack/react-query").UseQueryResult<IUser | undefined, Error>;
|
|
344
351
|
useUserByHandle: (handle: string) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
352
|
+
useUserPublicProfileByHandle: (handle: string) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
345
353
|
useSearchUsers: (namingPattern: string) => import("@tanstack/react-query").UseQueryResult<IUser[], Error>;
|
|
354
|
+
useUsersByUids: (userIds: string[]) => import("@tanstack/react-query").UseQueryResult<IUser[], Error>;
|
|
346
355
|
useUpdateUserOnboarding: () => import("@tanstack/react-query").UseMutationResult<any, Error, IUserOnboarding, unknown>;
|
|
347
356
|
useUpdateUserSettings: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
348
357
|
userId: string;
|
|
@@ -363,15 +372,42 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
363
372
|
userId: string;
|
|
364
373
|
roleName: string;
|
|
365
374
|
}, unknown>;
|
|
375
|
+
useOrganizationAllocationOverview: (organizationUid: string) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
376
|
+
useOrganizationAllocationHistory: (organizationUid: string) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
377
|
+
useTeamAllocationOverview: (teamUid: string) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
378
|
+
useTeamAllocationHistory: (teamUid: string) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
379
|
+
useAllocateOrganizationCreditsToTeam: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
380
|
+
organizationUid: string;
|
|
381
|
+
teamUid: string;
|
|
382
|
+
amount: number;
|
|
383
|
+
}, unknown>;
|
|
384
|
+
useAllocateTeamCreditsToMember: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
385
|
+
teamUid: string;
|
|
386
|
+
memberUid: string;
|
|
387
|
+
amount: number;
|
|
388
|
+
}, unknown>;
|
|
389
|
+
useRevokeOrganizationCreditsFromTeam: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
390
|
+
organizationUid: string;
|
|
391
|
+
teamUid: string;
|
|
392
|
+
amount: number;
|
|
393
|
+
}, unknown>;
|
|
394
|
+
useRevokeTeamCreditsFromMember: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
395
|
+
teamUid: string;
|
|
396
|
+
memberUid: string;
|
|
397
|
+
amount: number;
|
|
398
|
+
}, unknown>;
|
|
366
399
|
useUpdateUserCreditsQuota: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
367
400
|
userId: string;
|
|
368
401
|
quota?: number;
|
|
369
402
|
}, unknown>;
|
|
370
|
-
useUsages: (
|
|
403
|
+
useUsages: (scopeOrOptions?: {
|
|
404
|
+
accountUid?: string;
|
|
405
|
+
} | Omit<UseQueryOptions<unknown[]>, "queryKey" | "queryFn">, options?: Omit<UseQueryOptions<unknown[]>, "queryKey" | "queryFn">) => import("@tanstack/react-query").UseQueryResult<unknown[], Error>;
|
|
371
406
|
useUsagesForUser: (userId: string, options?: Omit<UseQueryOptions<unknown[]>, "queryKey" | "queryFn">) => import("@tanstack/react-query").UseQueryResult<unknown[], Error>;
|
|
372
407
|
usePlatformUsages: (options?: Omit<UseQueryOptions<unknown[]>, "queryKey" | "queryFn">) => import("@tanstack/react-query").UseQueryResult<unknown[], Error>;
|
|
373
408
|
useOrganization: (organizationId: string) => import("@tanstack/react-query").UseQueryResult<IOrganization, Error>;
|
|
374
409
|
useOrganizationByHandle: (handle: string) => import("@tanstack/react-query").UseQueryResult<IOrganization | null, Error>;
|
|
410
|
+
useOrganizationPublicProfileByHandle: (handle: string) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
375
411
|
useUserOrganizations: () => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
376
412
|
useCreateOrganization: () => import("@tanstack/react-query").UseMutationResult<any, Error, Partial<IOrganization>, unknown>;
|
|
377
413
|
useUpdateOrganization: () => import("@tanstack/react-query").UseMutationResult<any, Error, Partial<IAnyOrganization>, unknown>;
|
|
@@ -437,10 +473,17 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
437
473
|
useOrganizationSpaces: (organizationId: string) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
438
474
|
useUserSpace: (spaceId: string) => import("@tanstack/react-query").UseQueryResult<IAnySpace | null, Error>;
|
|
439
475
|
useUserSpaceByHandle: (handle: string) => import("@tanstack/react-query").UseQueryResult<{} | null, Error>;
|
|
440
|
-
useUserSpaces: (
|
|
476
|
+
useUserSpaces: (scope?: {
|
|
477
|
+
selectedPrincipalUid?: string;
|
|
478
|
+
selectedPrincipalKind?: "user" | "organization" | "team";
|
|
479
|
+
}) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
441
480
|
useCreateSpace: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
442
481
|
space: Partial<IAnySpace>;
|
|
443
482
|
organization?: IAnyOrganization;
|
|
483
|
+
team?: {
|
|
484
|
+
id?: string;
|
|
485
|
+
handle?: string;
|
|
486
|
+
};
|
|
444
487
|
}, unknown>;
|
|
445
488
|
useUpdateSpace: () => import("@tanstack/react-query").UseMutationResult<any, Error, Partial<IAnySpace> & Record<string, unknown>, unknown>;
|
|
446
489
|
useDeleteSpace: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
@@ -659,24 +702,53 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
659
702
|
useClearCachedPublicItems: (options?: UseMutationOptions<void, Error, void>) => import("@tanstack/react-query").UseMutationResult<void, Error, void, unknown>;
|
|
660
703
|
useClearCachedItems: (options?: UseMutationOptions<void, Error, void>) => import("@tanstack/react-query").UseMutationResult<void, Error, void, unknown>;
|
|
661
704
|
usePage: (pageId: string) => import("@tanstack/react-query").UseQueryResult<IPage | undefined, Error>;
|
|
662
|
-
usePages: (
|
|
705
|
+
usePages: (scope?: {
|
|
706
|
+
selectedPrincipalUid?: string;
|
|
707
|
+
selectedPrincipalKind?: "user" | "organization" | "team";
|
|
708
|
+
}) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
663
709
|
useCreatePage: () => import("@tanstack/react-query").UseMutationResult<any, Error, Omit<IPage, "id">, unknown>;
|
|
664
710
|
useUpdatePage: () => import("@tanstack/react-query").UseMutationResult<any, Error, Pick<IPage, "id" | "name" | "tags" | "description">, unknown>;
|
|
665
711
|
useDeletePage: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
666
|
-
useDatasource: (datasourceId: string
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
712
|
+
useDatasource: (datasourceId: string, options?: {
|
|
713
|
+
principalUid?: string;
|
|
714
|
+
principalKind?: "user" | "organization" | "team";
|
|
715
|
+
}) => import("@tanstack/react-query").UseQueryResult<IDatasource | null | undefined, Error>;
|
|
716
|
+
useDatasources: (options?: {
|
|
717
|
+
principalUid?: string;
|
|
718
|
+
principalKind?: "user" | "organization" | "team";
|
|
719
|
+
}) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
720
|
+
useCreateDatasource: (options?: {
|
|
721
|
+
principalUid?: string;
|
|
722
|
+
principalKind?: "user" | "organization" | "team";
|
|
723
|
+
}) => import("@tanstack/react-query").UseMutationResult<any, Error, Omit<IDatasource, "id">, unknown>;
|
|
724
|
+
useUpdateDatasource: (options?: {
|
|
725
|
+
principalUid?: string;
|
|
726
|
+
principalKind?: "user" | "organization" | "team";
|
|
727
|
+
}) => import("@tanstack/react-query").UseMutationResult<any, Error, IDatasource, unknown>;
|
|
670
728
|
useSecret: (secretId: string, options?: {
|
|
729
|
+
principalUid?: string;
|
|
730
|
+
principalKind?: "user" | "organization" | "team";
|
|
671
731
|
enabled?: boolean;
|
|
672
732
|
refetchOnMount?: boolean | "always";
|
|
673
733
|
staleTime?: number;
|
|
674
734
|
gcTime?: number;
|
|
675
735
|
}) => import("@tanstack/react-query").UseQueryResult<ISecret | null | undefined, Error>;
|
|
676
|
-
useSecrets: (
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
736
|
+
useSecrets: (options?: {
|
|
737
|
+
principalUid?: string;
|
|
738
|
+
principalKind?: "user" | "organization" | "team";
|
|
739
|
+
}) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
740
|
+
useCreateSecret: (options?: {
|
|
741
|
+
principalUid?: string;
|
|
742
|
+
principalKind?: "user" | "organization" | "team";
|
|
743
|
+
}) => import("@tanstack/react-query").UseMutationResult<any, Error, Omit<ISecret, "id">, unknown>;
|
|
744
|
+
useUpdateSecret: (options?: {
|
|
745
|
+
principalUid?: string;
|
|
746
|
+
principalKind?: "user" | "organization" | "team";
|
|
747
|
+
}) => import("@tanstack/react-query").UseMutationResult<any, Error, ISecret, unknown>;
|
|
748
|
+
useDeleteSecret: (options?: {
|
|
749
|
+
principalUid?: string;
|
|
750
|
+
principalKind?: "user" | "organization" | "team";
|
|
751
|
+
}) => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
680
752
|
useToken: (tokenId: string) => import("@tanstack/react-query").UseQueryResult<IIAMToken | null | undefined, Error>;
|
|
681
753
|
useTokens: () => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
682
754
|
useCreateToken: () => import("@tanstack/react-query").UseMutationResult<any, Error, Omit<IIAMToken, "id" | "value">, unknown>;
|
|
@@ -780,12 +852,37 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
780
852
|
userUid: string;
|
|
781
853
|
code: string;
|
|
782
854
|
}, unknown>;
|
|
783
|
-
|
|
855
|
+
useCreateTopUpPaymentIntent: (scope?: {
|
|
856
|
+
accountUid?: string;
|
|
857
|
+
}) => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
784
858
|
product: any;
|
|
785
|
-
location: Location;
|
|
786
859
|
}, unknown>;
|
|
860
|
+
useCreateSubscriptionPaymentIntent: (scope?: {
|
|
861
|
+
accountUid?: string;
|
|
862
|
+
}) => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
863
|
+
plan: any;
|
|
864
|
+
}, unknown>;
|
|
865
|
+
useCreateResumeSetupIntent: (scope?: {
|
|
866
|
+
accountUid?: string;
|
|
867
|
+
}) => import("@tanstack/react-query").UseMutationResult<any, Error, void, unknown>;
|
|
868
|
+
useSubscriptionStatus: (scope?: {
|
|
869
|
+
accountUid?: string;
|
|
870
|
+
}, options?: Omit<UseQueryOptions<any>, "queryKey" | "queryFn">) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
871
|
+
useSubscriptionPlans: (scope?: {
|
|
872
|
+
accountUid?: string;
|
|
873
|
+
}, options?: Omit<UseQueryOptions<unknown[]>, "queryKey" | "queryFn">) => import("@tanstack/react-query").UseQueryResult<unknown[], Error>;
|
|
874
|
+
useEligibleSubscriptionAccounts: (options?: Omit<UseQueryOptions<any[]>, "queryKey" | "queryFn">) => import("@tanstack/react-query").UseQueryResult<any[], Error>;
|
|
875
|
+
useSubscriptionAccountsDetails: (accountUids: string[], options?: Omit<UseQueryOptions<any[]>, "queryKey" | "queryFn" | "enabled">) => import("@tanstack/react-query").UseQueryResult<any[], Error>;
|
|
876
|
+
useCancelSubscription: (scope?: {
|
|
877
|
+
accountUid?: string;
|
|
878
|
+
}) => import("@tanstack/react-query").UseMutationResult<any, Error, void, unknown>;
|
|
879
|
+
useResumeSubscription: (scope?: {
|
|
880
|
+
accountUid?: string;
|
|
881
|
+
}) => import("@tanstack/react-query").UseMutationResult<any, Error, void, unknown>;
|
|
882
|
+
useUserSubscription: (userId: string | undefined, options?: Omit<UseQueryOptions<any>, "queryKey" | "queryFn">) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
883
|
+
useResetUserSubscription: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
787
884
|
useBurnCredit: () => import("@tanstack/react-query").UseMutationResult<any, Error, number, unknown>;
|
|
788
|
-
|
|
885
|
+
useTopUpPrices: (options?: Omit<UseQueryOptions<unknown[]>, "queryKey" | "queryFn">) => import("@tanstack/react-query").UseQueryResult<unknown[], Error>;
|
|
789
886
|
useRequestPlatformSupport: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
790
887
|
subject: string;
|
|
791
888
|
message: string;
|
|
@@ -801,6 +898,7 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
801
898
|
}, unknown>;
|
|
802
899
|
useUserSurveys: (userId: string, options?: Omit<UseQueryOptions<unknown>, "queryKey" | "queryFn">) => import("@tanstack/react-query").UseQueryResult<unknown, Error>;
|
|
803
900
|
useGrowthKPI: (options?: Omit<UseQueryOptions<unknown>, "queryKey" | "queryFn">) => import("@tanstack/react-query").UseQueryResult<unknown, Error>;
|
|
901
|
+
useGrowthContactsKPI: (options?: Omit<UseQueryOptions<unknown>, "queryKey" | "queryFn">) => import("@tanstack/react-query").UseQueryResult<unknown, Error>;
|
|
804
902
|
queryKeys: {
|
|
805
903
|
readonly auth: {
|
|
806
904
|
readonly me: () => readonly ["auth", "me"];
|
|
@@ -815,7 +913,9 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
815
913
|
readonly details: () => readonly ["users", "detail"];
|
|
816
914
|
readonly detail: (id: string) => readonly ["users", "detail", string];
|
|
817
915
|
readonly byHandle: (handle: string) => readonly ["users", "handle", string];
|
|
916
|
+
readonly publicProfileByHandle: (handle: string) => readonly ["users", "public-profile", string];
|
|
818
917
|
readonly search: (pattern: string) => readonly ["users", "search", string];
|
|
918
|
+
readonly bulk: (userIdsKey: string) => readonly ["users", "bulk", string];
|
|
819
919
|
readonly settings: (userId: string) => readonly ["users", "detail", string, "settings"];
|
|
820
920
|
readonly onboarding: (userId: string) => readonly ["users", "detail", string, "onboarding"];
|
|
821
921
|
readonly surveys: (userId: string) => readonly ["users", "detail", string, "surveys"];
|
|
@@ -827,6 +927,7 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
827
927
|
readonly details: () => readonly ["organizations", "detail"];
|
|
828
928
|
readonly detail: (id: string) => readonly ["organizations", "detail", string];
|
|
829
929
|
readonly byHandle: (handle: string) => readonly ["organizations", "handle", string];
|
|
930
|
+
readonly publicProfileByHandle: (handle: string) => readonly ["organizations", "public-profile", string];
|
|
830
931
|
readonly userOrgs: () => readonly ["organizations", "user"];
|
|
831
932
|
readonly members: (orgId: string) => readonly ["organizations", "detail", string, "members"];
|
|
832
933
|
};
|
|
@@ -971,6 +1072,12 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
971
1072
|
readonly userById: (userId: string) => readonly ["usages", "user", string];
|
|
972
1073
|
readonly platform: () => readonly ["usages", "platform"];
|
|
973
1074
|
};
|
|
1075
|
+
readonly credits: {
|
|
1076
|
+
readonly organizationOverview: (organizationUid: string) => readonly ["credits", "allocations", "organization", string];
|
|
1077
|
+
readonly organizationHistory: (organizationUid: string) => readonly ["credits", "allocations", "organization", string, "history"];
|
|
1078
|
+
readonly teamOverview: (teamUid: string) => readonly ["credits", "allocations", "team", string];
|
|
1079
|
+
readonly teamHistory: (teamUid: string) => readonly ["credits", "allocations", "team", string, "history"];
|
|
1080
|
+
};
|
|
974
1081
|
readonly prices: {
|
|
975
1082
|
readonly stripe: () => readonly ["prices", "stripe"];
|
|
976
1083
|
};
|