@datalayer/core 0.0.15 → 0.0.17
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/components/chat/ChatComponent.d.ts +4 -0
- package/lib/components/chat/ChatComponent.js +139 -0
- package/lib/components/chat/MessagePart.d.ts +11 -0
- package/lib/components/chat/MessagePart.js +23 -0
- package/lib/components/chat/display/DynamicToolPart.d.ts +6 -0
- package/lib/components/chat/display/DynamicToolPart.js +5 -0
- package/lib/components/chat/display/ReasoningPart.d.ts +6 -0
- package/lib/components/chat/display/ReasoningPart.js +54 -0
- package/lib/components/chat/display/TextPart.d.ts +9 -0
- package/lib/components/chat/display/TextPart.js +93 -0
- package/lib/components/chat/display/ToolPart.d.ts +6 -0
- package/lib/components/chat/display/ToolPart.js +144 -0
- package/lib/components/chat/display/index.d.ts +4 -0
- package/lib/components/chat/display/index.js +9 -0
- package/lib/components/chat/handler.d.ts +8 -0
- package/lib/components/chat/handler.js +39 -0
- package/lib/components/chat/index.d.ts +4 -0
- package/lib/components/chat/index.js +9 -0
- package/lib/components/index.d.ts +1 -1
- package/lib/components/index.js +1 -1
- package/lib/components/runtimes/RuntimeSimplePicker.d.ts +4 -0
- package/lib/components/runtimes/RuntimeSimplePicker.js +3 -3
- package/lib/examples/ChatExample.d.ts +8 -0
- package/lib/examples/ChatExample.js +51 -0
- package/lib/examples/example-selector.js +1 -0
- package/lib/hooks/useAIJupyterChat.d.ts +36 -0
- package/lib/hooks/useAIJupyterChat.js +49 -0
- package/lib/hooks/useCache.js +105 -45
- package/lib/hooks/useMobile.d.ts +1 -0
- package/lib/hooks/useMobile.js +22 -0
- package/lib/hooks/useUpload.js +29 -21
- package/lib/index.d.ts +1 -0
- package/lib/index.js +8 -4
- package/lib/stateful/index.d.ts +0 -1
- package/lib/stateful/index.js +0 -1
- package/lib/stateful/runtimes/actions.d.ts +1 -1
- package/lib/stateful/runtimes/actions.js +1 -1
- package/lib/theme/DatalayerTheme.d.ts +2 -2
- package/lib/theme/DatalayerTheme.js +4 -4
- package/lib/theme/DatalayerThemeProvider.js +2 -2
- package/lib/types.d.ts +5 -0
- package/lib/types.js +6 -0
- package/package.json +16 -2
- package/style/base.css +4 -0
- package/lib/sdk/index.d.ts +0 -27
- package/lib/sdk/index.js +0 -33
|
@@ -35,7 +35,7 @@ var RuntimeDialogCause;
|
|
|
35
35
|
* Runtime simple picker component.
|
|
36
36
|
*/
|
|
37
37
|
export function RuntimeSimplePicker(props) {
|
|
38
|
-
const { assignRuntime, sessionConnection } = props;
|
|
38
|
+
const { assignRuntime, sessionConnection, browserRuntimeAvailable = true, } = props;
|
|
39
39
|
const { runtimeModels, multiServiceManager } = useRuntimesStore();
|
|
40
40
|
const jupyterReactStore = useJupyterReactStore();
|
|
41
41
|
const jupyterLabAdapter = jupyterReactStore.jupyterLabAdapter;
|
|
@@ -120,7 +120,7 @@ export function RuntimeSimplePicker(props) {
|
|
|
120
120
|
sessionConnection === undefined, onSelect: () => {
|
|
121
121
|
setRuntimeLocation(undefined);
|
|
122
122
|
assignRuntime({ runtimeDesc: undefined });
|
|
123
|
-
}, children: [_jsx(ActionList.LeadingVisual, { children: _jsx(EyeIcon, {}) }), "Viewer", _jsx(ActionList.Description, { variant: "block", children: "A simple Notebook Viewer without Runtime." })] }), _jsxs(ActionList.Item, { selected: runtimeLocation === 'browser', onSelect: () => {
|
|
123
|
+
}, children: [_jsx(ActionList.LeadingVisual, { children: _jsx(EyeIcon, {}) }), "Viewer", _jsx(ActionList.Description, { variant: "block", children: "A simple Notebook Viewer without Runtime." })] }), browserRuntimeAvailable && (_jsxs(ActionList.Item, { selected: runtimeLocation === 'browser', onSelect: () => {
|
|
124
124
|
setRuntimeLocation('browser');
|
|
125
125
|
assignRuntime({
|
|
126
126
|
runtimeDesc: {
|
|
@@ -129,7 +129,7 @@ export function RuntimeSimplePicker(props) {
|
|
|
129
129
|
language: 'python',
|
|
130
130
|
},
|
|
131
131
|
});
|
|
132
|
-
}, children: [_jsx(ActionList.LeadingVisual, { children: _jsx(BrowserIcon, {}) }), "Browser Runtime", _jsx(ActionList.Description, { variant: "block", children: "A Browser Runtime based on Pyodide." })] })] }), runtimeModels.length > 0 && (_jsxs(ActionList.Group, { children: [_jsx(ActionList.GroupHeading, { children: "Cloud Runtimes" }), runtimeModels.map(kernelModel => {
|
|
132
|
+
}, children: [_jsx(ActionList.LeadingVisual, { children: _jsx(BrowserIcon, {}) }), "Browser Runtime", _jsx(ActionList.Description, { variant: "block", children: "A Browser Runtime based on Pyodide." })] }))] }), runtimeModels.length > 0 && (_jsxs(ActionList.Group, { children: [_jsx(ActionList.GroupHeading, { children: "Cloud Runtimes" }), runtimeModels.map(kernelModel => {
|
|
133
133
|
return (_jsxs(ActionList.Item, { selected: sessionConnection?.kernel?.id === kernelModel.id, onSelect: () => {
|
|
134
134
|
setRuntimeLocation('remote');
|
|
135
135
|
assignRuntime({
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024-2025 Datalayer, Inc.
|
|
4
|
+
*
|
|
5
|
+
* BSD 3-Clause License
|
|
6
|
+
*/
|
|
7
|
+
import { Text } from '@primer/react';
|
|
8
|
+
import { Box } from '@datalayer/primer-addons';
|
|
9
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
10
|
+
import { ChatComponent } from '../components/chat/ChatComponent';
|
|
11
|
+
import { datalayerTheme, DatalayerThemeProvider } from '@/theme';
|
|
12
|
+
// Create a query client for React Query
|
|
13
|
+
const queryClient = new QueryClient({
|
|
14
|
+
defaultOptions: {
|
|
15
|
+
queries: {
|
|
16
|
+
staleTime: 1000 * 60 * 5, // 5 minutes
|
|
17
|
+
gcTime: 1000 * 60 * 10, // 10 minutes
|
|
18
|
+
retry: 1,
|
|
19
|
+
refetchOnWindowFocus: false,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Chat Example Component
|
|
25
|
+
*
|
|
26
|
+
* Demonstrates the ChatComponent with all necessary providers:
|
|
27
|
+
* - QueryClientProvider for data fetching
|
|
28
|
+
*/
|
|
29
|
+
const ChatExample = () => {
|
|
30
|
+
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(DatalayerThemeProvider, { theme: datalayerTheme, children: _jsxs(Box, { sx: {
|
|
31
|
+
display: 'flex',
|
|
32
|
+
flexDirection: 'column',
|
|
33
|
+
height: '100vh',
|
|
34
|
+
backgroundColor: 'canvas.default',
|
|
35
|
+
}, children: [_jsxs(Box, { as: "header", sx: {
|
|
36
|
+
borderBottom: '1px solid',
|
|
37
|
+
borderColor: 'border.default',
|
|
38
|
+
padding: 3,
|
|
39
|
+
}, children: [_jsx(Text, { sx: {
|
|
40
|
+
fontSize: 3,
|
|
41
|
+
fontWeight: 'bold',
|
|
42
|
+
display: 'block',
|
|
43
|
+
marginBottom: 1,
|
|
44
|
+
}, children: "Chat Example" }), _jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "Interactive chat interface with AI assistance" })] }), _jsx(Box, { as: "main", sx: {
|
|
45
|
+
flex: 1,
|
|
46
|
+
overflow: 'hidden',
|
|
47
|
+
display: 'flex',
|
|
48
|
+
flexDirection: 'column',
|
|
49
|
+
}, children: _jsx(ChatComponent, {}) })] }) }) }));
|
|
50
|
+
};
|
|
51
|
+
export default ChatExample;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export const EXAMPLES = {
|
|
10
10
|
CellExample: () => import('./CellExample'),
|
|
11
|
+
ChatExample: () => import('./ChatExample'),
|
|
11
12
|
DatalayerNotebookExample: () => import('./DatalayerNotebookExample'),
|
|
12
13
|
NotebookExample: () => import('./NotebookExample'),
|
|
13
14
|
NotebookMutationsKernel: () => import('./NotebookMutationsKernel'),
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface IUseAIJupyterChatOptions {
|
|
2
|
+
apiUrl?: string;
|
|
3
|
+
initialMessages?: unknown[];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Hook to manage chat state with JupyterLab backend.
|
|
7
|
+
* Adapts Vercel AI SDK's useChat for Datalayer AI context.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useAIJupyterChat(_options?: IUseAIJupyterChatOptions): {
|
|
10
|
+
messages: import("ai").UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[];
|
|
11
|
+
sendMessage: (message?: (Omit<import("ai").UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>, "id" | "role"> & {
|
|
12
|
+
id?: string | undefined;
|
|
13
|
+
role?: "user" | "system" | "assistant" | undefined;
|
|
14
|
+
} & {
|
|
15
|
+
text?: never;
|
|
16
|
+
files?: never;
|
|
17
|
+
messageId?: string;
|
|
18
|
+
}) | {
|
|
19
|
+
text: string;
|
|
20
|
+
files?: FileList | import("ai").FileUIPart[];
|
|
21
|
+
metadata?: unknown;
|
|
22
|
+
parts?: never;
|
|
23
|
+
messageId?: string;
|
|
24
|
+
} | {
|
|
25
|
+
files: FileList | import("ai").FileUIPart[];
|
|
26
|
+
metadata?: unknown;
|
|
27
|
+
parts?: never;
|
|
28
|
+
messageId?: string;
|
|
29
|
+
} | undefined, options?: import("ai").ChatRequestOptions) => Promise<void>;
|
|
30
|
+
status: import("ai").ChatStatus;
|
|
31
|
+
setMessages: (messages: import("ai").UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[] | ((messages: import("ai").UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[]) => import("ai").UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[])) => void;
|
|
32
|
+
regenerate: ({ messageId, ...options }?: {
|
|
33
|
+
messageId?: string;
|
|
34
|
+
} & import("ai").ChatRequestOptions) => Promise<void>;
|
|
35
|
+
clearChat: () => void;
|
|
36
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024-2025 Datalayer, Inc.
|
|
3
|
+
*
|
|
4
|
+
* BSD 3-Clause License
|
|
5
|
+
*/
|
|
6
|
+
import { useCallback, useMemo } from 'react';
|
|
7
|
+
import { useChat } from '@ai-sdk/react';
|
|
8
|
+
import { DefaultChatTransport } from 'ai';
|
|
9
|
+
import { ServerConnection } from '@jupyterlab/services';
|
|
10
|
+
import { URLExt } from '@jupyterlab/coreutils';
|
|
11
|
+
/**
|
|
12
|
+
* Hook to manage chat state with JupyterLab backend.
|
|
13
|
+
* Adapts Vercel AI SDK's useChat for Datalayer AI context.
|
|
14
|
+
*/
|
|
15
|
+
export function useAIJupyterChat(_options = {}) {
|
|
16
|
+
// Build the full API URL for the chat endpoint
|
|
17
|
+
const settings = ServerConnection.makeSettings();
|
|
18
|
+
const chatEndpoint = URLExt.join(settings.baseUrl, 'datalayer', 'chat');
|
|
19
|
+
const { messages, sendMessage, status, setMessages, regenerate } = useChat({
|
|
20
|
+
id: 'ai-jupyter-chat',
|
|
21
|
+
transport: new DefaultChatTransport({
|
|
22
|
+
api: chatEndpoint,
|
|
23
|
+
credentials: settings.token ? 'include' : 'omit',
|
|
24
|
+
headers: {
|
|
25
|
+
Authorization: `token ${settings.token || ''}`,
|
|
26
|
+
'X-XSRFToken': settings.token || '',
|
|
27
|
+
},
|
|
28
|
+
fetch: async (input, init) => {
|
|
29
|
+
return fetch(input, {
|
|
30
|
+
...init,
|
|
31
|
+
mode: 'cors',
|
|
32
|
+
credentials: settings.token ? 'include' : 'omit',
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
37
|
+
// Clear chat history
|
|
38
|
+
const clearChat = useCallback(() => {
|
|
39
|
+
setMessages([]);
|
|
40
|
+
}, [setMessages]);
|
|
41
|
+
return useMemo(() => ({
|
|
42
|
+
messages,
|
|
43
|
+
sendMessage,
|
|
44
|
+
status,
|
|
45
|
+
setMessages,
|
|
46
|
+
regenerate,
|
|
47
|
+
clearChat,
|
|
48
|
+
}), [messages, sendMessage, status, setMessages, regenerate, clearChat]);
|
|
49
|
+
}
|
package/lib/hooks/useCache.js
CHANGED
|
@@ -696,6 +696,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
696
696
|
* ```
|
|
697
697
|
*/
|
|
698
698
|
const useLogin = () => {
|
|
699
|
+
const iamStore = useIAMStore();
|
|
699
700
|
return useMutation({
|
|
700
701
|
mutationFn: async ({ handle, password, }) => {
|
|
701
702
|
return requestDatalayer({
|
|
@@ -704,7 +705,11 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
704
705
|
body: { handle, password },
|
|
705
706
|
});
|
|
706
707
|
},
|
|
707
|
-
onSuccess: () => {
|
|
708
|
+
onSuccess: async (resp) => {
|
|
709
|
+
// Set the token in IAM state
|
|
710
|
+
if (resp.token) {
|
|
711
|
+
await iamStore.refreshUserByToken(resp.token);
|
|
712
|
+
}
|
|
708
713
|
// Invalidate all queries on successful login
|
|
709
714
|
queryClient.invalidateQueries();
|
|
710
715
|
},
|
|
@@ -983,7 +988,6 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
983
988
|
method: 'GET',
|
|
984
989
|
});
|
|
985
990
|
if (resp.success && resp.organizations) {
|
|
986
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
987
991
|
const orgs = resp.organizations.map((org) => {
|
|
988
992
|
const organization = toOrganization(org);
|
|
989
993
|
// Pre-populate caches
|
|
@@ -1512,6 +1516,9 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1512
1516
|
return useQuery({
|
|
1513
1517
|
queryKey: queryKeys.documents.bySpace(spaceId),
|
|
1514
1518
|
queryFn: async () => {
|
|
1519
|
+
if (!spaceId) {
|
|
1520
|
+
return [];
|
|
1521
|
+
}
|
|
1515
1522
|
const resp = await requestDatalayer({
|
|
1516
1523
|
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${spaceId}/items/types/document`,
|
|
1517
1524
|
method: 'GET',
|
|
@@ -2099,7 +2106,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2099
2106
|
});
|
|
2100
2107
|
};
|
|
2101
2108
|
// ============================================================================
|
|
2102
|
-
//
|
|
2109
|
+
// Core CRUD Operations - Refresh & Get Methods
|
|
2103
2110
|
// ============================================================================
|
|
2104
2111
|
/**
|
|
2105
2112
|
* Get single datasource by ID
|
|
@@ -2385,7 +2392,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2385
2392
|
});
|
|
2386
2393
|
};
|
|
2387
2394
|
// ============================================================================
|
|
2388
|
-
//
|
|
2395
|
+
// Member Management & User Extensions
|
|
2389
2396
|
// ============================================================================
|
|
2390
2397
|
/**
|
|
2391
2398
|
* Refresh user data by ID (re-fetch from API)
|
|
@@ -2686,7 +2693,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2686
2693
|
});
|
|
2687
2694
|
};
|
|
2688
2695
|
// ============================================================================
|
|
2689
|
-
//
|
|
2696
|
+
// Authentication, Roles, Schools, and Refresh Methods
|
|
2690
2697
|
// ============================================================================
|
|
2691
2698
|
/**
|
|
2692
2699
|
* Change user password
|
|
@@ -2896,9 +2903,8 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2896
2903
|
return useMutation({
|
|
2897
2904
|
mutationFn: async (organizationId) => {
|
|
2898
2905
|
return requestDatalayer({
|
|
2899
|
-
url: `${configuration.iamRunUrl}/api/iam/v1/teams`,
|
|
2906
|
+
url: `${configuration.iamRunUrl}/api/iam/v1/organizations/${organizationId}/teams`,
|
|
2900
2907
|
method: 'GET',
|
|
2901
|
-
body: { organizationId },
|
|
2902
2908
|
});
|
|
2903
2909
|
},
|
|
2904
2910
|
onSuccess: (resp, organizationId) => {
|
|
@@ -2950,7 +2956,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2950
2956
|
return useMutation({
|
|
2951
2957
|
mutationFn: async (organizationId) => {
|
|
2952
2958
|
return requestDatalayer({
|
|
2953
|
-
url: `${configuration.spacerRunUrl}/api/spacer/v1/organizations/${organizationId}
|
|
2959
|
+
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/organizations/${organizationId}`,
|
|
2954
2960
|
method: 'GET',
|
|
2955
2961
|
});
|
|
2956
2962
|
},
|
|
@@ -2996,7 +3002,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
2996
3002
|
});
|
|
2997
3003
|
};
|
|
2998
3004
|
// ============================================================================
|
|
2999
|
-
//
|
|
3005
|
+
// Courses, Space Items, and Advanced Features
|
|
3000
3006
|
// ============================================================================
|
|
3001
3007
|
/**
|
|
3002
3008
|
* Get course by ID
|
|
@@ -3215,24 +3221,30 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
3215
3221
|
},
|
|
3216
3222
|
onSuccess: (resp, variables) => {
|
|
3217
3223
|
if (resp.success) {
|
|
3224
|
+
// Transform raw API data to typed models
|
|
3225
|
+
const transformedUser = resp.user ? toUser(resp.user) : undefined;
|
|
3226
|
+
const transformedOrganization = resp.organization
|
|
3227
|
+
? toOrganization(resp.organization)
|
|
3228
|
+
: undefined;
|
|
3229
|
+
const transformedSpace = resp.space ? toSpace(resp.space) : undefined;
|
|
3218
3230
|
// Set data directly into cache instead of just invalidating
|
|
3219
|
-
if (
|
|
3220
|
-
queryClient.setQueryData(queryKeys.users.byHandle(variables.accountHandle),
|
|
3231
|
+
if (transformedUser) {
|
|
3232
|
+
queryClient.setQueryData(queryKeys.users.byHandle(variables.accountHandle), transformedUser);
|
|
3221
3233
|
queryClient.invalidateQueries({ queryKey: queryKeys.users.all() });
|
|
3222
3234
|
}
|
|
3223
|
-
if (
|
|
3224
|
-
queryClient.setQueryData(queryKeys.organizations.byHandle(variables.accountHandle),
|
|
3235
|
+
if (transformedOrganization) {
|
|
3236
|
+
queryClient.setQueryData(queryKeys.organizations.byHandle(variables.accountHandle), transformedOrganization);
|
|
3225
3237
|
queryClient.invalidateQueries({
|
|
3226
3238
|
queryKey: queryKeys.organizations.all(),
|
|
3227
3239
|
});
|
|
3228
3240
|
}
|
|
3229
|
-
if (
|
|
3241
|
+
if (transformedSpace) {
|
|
3230
3242
|
// Set both user and org space queries based on which type it is
|
|
3231
|
-
if (
|
|
3232
|
-
queryClient.setQueryData(queryKeys.spaces.byHandle(variables.spaceHandle),
|
|
3243
|
+
if (transformedUser && variables.spaceHandle) {
|
|
3244
|
+
queryClient.setQueryData(queryKeys.spaces.byHandle(variables.spaceHandle), transformedSpace);
|
|
3233
3245
|
}
|
|
3234
|
-
if (
|
|
3235
|
-
queryClient.setQueryData(queryKeys.spaces.orgSpaceByHandle(
|
|
3246
|
+
if (transformedOrganization && variables.spaceHandle) {
|
|
3247
|
+
queryClient.setQueryData(queryKeys.spaces.orgSpaceByHandle(transformedOrganization.id, variables.spaceHandle), transformedSpace);
|
|
3236
3248
|
}
|
|
3237
3249
|
queryClient.invalidateQueries({ queryKey: queryKeys.spaces.all() });
|
|
3238
3250
|
}
|
|
@@ -3254,7 +3266,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
3254
3266
|
});
|
|
3255
3267
|
};
|
|
3256
3268
|
// ============================================================================
|
|
3257
|
-
//
|
|
3269
|
+
// Cells, Datasets, Environments, and Lessons
|
|
3258
3270
|
// ============================================================================
|
|
3259
3271
|
/**
|
|
3260
3272
|
* Get cell by ID
|
|
@@ -3531,7 +3543,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
3531
3543
|
});
|
|
3532
3544
|
};
|
|
3533
3545
|
// ============================================================================
|
|
3534
|
-
//
|
|
3546
|
+
// Exercises, Assignments, Invites, and Contacts
|
|
3535
3547
|
// ============================================================================
|
|
3536
3548
|
/**
|
|
3537
3549
|
* Get exercise by ID
|
|
@@ -3763,7 +3775,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
3763
3775
|
});
|
|
3764
3776
|
};
|
|
3765
3777
|
// ============================================================================
|
|
3766
|
-
//
|
|
3778
|
+
// Assignment Student Operations
|
|
3767
3779
|
// ============================================================================
|
|
3768
3780
|
/**
|
|
3769
3781
|
* Fetch assignment from student perspective with enrollment data
|
|
@@ -3846,7 +3858,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
3846
3858
|
});
|
|
3847
3859
|
};
|
|
3848
3860
|
// ============================================================================
|
|
3849
|
-
//
|
|
3861
|
+
// Exercise Grading
|
|
3850
3862
|
// ============================================================================
|
|
3851
3863
|
/**
|
|
3852
3864
|
* Grade an exercise by assigning points to student code
|
|
@@ -3872,7 +3884,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
3872
3884
|
});
|
|
3873
3885
|
};
|
|
3874
3886
|
// ============================================================================
|
|
3875
|
-
//
|
|
3887
|
+
// Course Student & Course Items
|
|
3876
3888
|
// ============================================================================
|
|
3877
3889
|
/**
|
|
3878
3890
|
* Get a student in a course
|
|
@@ -3941,7 +3953,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
3941
3953
|
});
|
|
3942
3954
|
};
|
|
3943
3955
|
// ============================================================================
|
|
3944
|
-
//
|
|
3956
|
+
// Inbounds & Outbounds
|
|
3945
3957
|
// ============================================================================
|
|
3946
3958
|
/**
|
|
3947
3959
|
* Get all inbound leads
|
|
@@ -4020,7 +4032,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4020
4032
|
});
|
|
4021
4033
|
};
|
|
4022
4034
|
// ============================================================================
|
|
4023
|
-
//
|
|
4035
|
+
// Advanced Outbound Operations
|
|
4024
4036
|
// ============================================================================
|
|
4025
4037
|
/**
|
|
4026
4038
|
* Try bulk emails (test mode) for outbound campaign
|
|
@@ -4098,7 +4110,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4098
4110
|
});
|
|
4099
4111
|
};
|
|
4100
4112
|
// ============================================================================
|
|
4101
|
-
//
|
|
4113
|
+
// Outbound Subscriptions
|
|
4102
4114
|
// ============================================================================
|
|
4103
4115
|
/**
|
|
4104
4116
|
* Subscribe a user to outbound communications
|
|
@@ -4153,7 +4165,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4153
4165
|
});
|
|
4154
4166
|
};
|
|
4155
4167
|
// ============================================================================
|
|
4156
|
-
//
|
|
4168
|
+
// MFA (Multi-Factor Authentication)
|
|
4157
4169
|
// ============================================================================
|
|
4158
4170
|
/**
|
|
4159
4171
|
* Enable MFA for current user
|
|
@@ -4204,7 +4216,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4204
4216
|
});
|
|
4205
4217
|
};
|
|
4206
4218
|
// ============================================================================
|
|
4207
|
-
//
|
|
4219
|
+
// Checkout & Credits
|
|
4208
4220
|
// ============================================================================
|
|
4209
4221
|
/**
|
|
4210
4222
|
* Get Stripe pricing information
|
|
@@ -4259,7 +4271,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4259
4271
|
});
|
|
4260
4272
|
};
|
|
4261
4273
|
// ============================================================================
|
|
4262
|
-
//
|
|
4274
|
+
// Support & Surveys
|
|
4263
4275
|
// ============================================================================
|
|
4264
4276
|
/**
|
|
4265
4277
|
* Request platform support (first form)
|
|
@@ -4313,7 +4325,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4313
4325
|
});
|
|
4314
4326
|
};
|
|
4315
4327
|
// ============================================================================
|
|
4316
|
-
//
|
|
4328
|
+
// Join & Registration
|
|
4317
4329
|
// ============================================================================
|
|
4318
4330
|
/**
|
|
4319
4331
|
* Request to join platform (standard registration)
|
|
@@ -4385,7 +4397,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4385
4397
|
});
|
|
4386
4398
|
};
|
|
4387
4399
|
// ============================================================================
|
|
4388
|
-
//
|
|
4400
|
+
// Password Recovery
|
|
4389
4401
|
// ============================================================================
|
|
4390
4402
|
/**
|
|
4391
4403
|
* Create token for password change
|
|
@@ -4415,7 +4427,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4415
4427
|
});
|
|
4416
4428
|
};
|
|
4417
4429
|
// ============================================================================
|
|
4418
|
-
//
|
|
4430
|
+
// OAuth2 Authentication
|
|
4419
4431
|
// ============================================================================
|
|
4420
4432
|
/**
|
|
4421
4433
|
* Get OAuth2 authorization URL
|
|
@@ -4451,7 +4463,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4451
4463
|
});
|
|
4452
4464
|
};
|
|
4453
4465
|
// ============================================================================
|
|
4454
|
-
//
|
|
4466
|
+
// Contact Enrichment & Tagging
|
|
4455
4467
|
// ============================================================================
|
|
4456
4468
|
/**
|
|
4457
4469
|
* Assign tag to contact
|
|
@@ -4566,7 +4578,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4566
4578
|
});
|
|
4567
4579
|
};
|
|
4568
4580
|
// ============================================================================
|
|
4569
|
-
//
|
|
4581
|
+
// Contact-User Linking
|
|
4570
4582
|
// ============================================================================
|
|
4571
4583
|
/**
|
|
4572
4584
|
* Link user with contact
|
|
@@ -4613,7 +4625,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4613
4625
|
});
|
|
4614
4626
|
};
|
|
4615
4627
|
// ============================================================================
|
|
4616
|
-
//
|
|
4628
|
+
// Credits Quota & Usage
|
|
4617
4629
|
// ============================================================================
|
|
4618
4630
|
/**
|
|
4619
4631
|
* Update user credits quota
|
|
@@ -4650,7 +4662,23 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4650
4662
|
url: `${configuration.iamRunUrl}/api/iam/v1/usage/user`,
|
|
4651
4663
|
method: 'GET',
|
|
4652
4664
|
});
|
|
4653
|
-
|
|
4665
|
+
// Transform snake_case API response to camelCase IUsage interface
|
|
4666
|
+
const usages = (resp.usages || []).map((u) => ({
|
|
4667
|
+
id: u.resource_uid,
|
|
4668
|
+
accountId: u.account_uid,
|
|
4669
|
+
type: u.resource_type,
|
|
4670
|
+
burningRate: u.burning_rate,
|
|
4671
|
+
credits: u.credits,
|
|
4672
|
+
creditsLimit: u.credits_limit,
|
|
4673
|
+
startDate: u.start_date ? new Date(u.start_date) : new Date(),
|
|
4674
|
+
updatedAt: u.updated_at ? new Date(u.updated_at) : new Date(),
|
|
4675
|
+
endDate: u.end_date ? new Date(u.end_date) : undefined,
|
|
4676
|
+
givenName: u.given_name || u.resource_given_name || '',
|
|
4677
|
+
resourceState: u.resource_state,
|
|
4678
|
+
resources: u.pod_resources,
|
|
4679
|
+
metadata: new Map(Object.entries(u.metadata || {})),
|
|
4680
|
+
}));
|
|
4681
|
+
return usages;
|
|
4654
4682
|
},
|
|
4655
4683
|
...options,
|
|
4656
4684
|
});
|
|
@@ -4666,7 +4694,23 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4666
4694
|
url: `${configuration.iamRunUrl}/api/iam/v1/usage/users/${userId}`,
|
|
4667
4695
|
method: 'GET',
|
|
4668
4696
|
});
|
|
4669
|
-
|
|
4697
|
+
// Transform snake_case API response to camelCase IUsage interface
|
|
4698
|
+
const usages = (resp.usages || []).map((u) => ({
|
|
4699
|
+
id: u.resource_uid,
|
|
4700
|
+
accountId: u.account_uid,
|
|
4701
|
+
type: u.resource_type,
|
|
4702
|
+
burningRate: u.burning_rate,
|
|
4703
|
+
credits: u.credits,
|
|
4704
|
+
creditsLimit: u.credits_limit,
|
|
4705
|
+
startDate: u.start_date ? new Date(u.start_date) : new Date(),
|
|
4706
|
+
updatedAt: u.updated_at ? new Date(u.updated_at) : new Date(),
|
|
4707
|
+
endDate: u.end_date ? new Date(u.end_date) : undefined,
|
|
4708
|
+
givenName: u.given_name || u.resource_given_name || '',
|
|
4709
|
+
resourceState: u.resource_state,
|
|
4710
|
+
resources: u.pod_resources,
|
|
4711
|
+
metadata: new Map(Object.entries(u.metadata || {})),
|
|
4712
|
+
}));
|
|
4713
|
+
return usages;
|
|
4670
4714
|
},
|
|
4671
4715
|
enabled: !!userId,
|
|
4672
4716
|
...options,
|
|
@@ -4683,13 +4727,29 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4683
4727
|
url: `${configuration.iamRunUrl}/api/iam/v1/usage/platform`,
|
|
4684
4728
|
method: 'GET',
|
|
4685
4729
|
});
|
|
4686
|
-
|
|
4730
|
+
// Transform snake_case API response to camelCase IUsage interface
|
|
4731
|
+
const usages = (resp.usages || []).map((u) => ({
|
|
4732
|
+
id: u.resource_uid,
|
|
4733
|
+
accountId: u.account_uid,
|
|
4734
|
+
type: u.resource_type,
|
|
4735
|
+
burningRate: u.burning_rate,
|
|
4736
|
+
credits: u.credits,
|
|
4737
|
+
creditsLimit: u.credits_limit,
|
|
4738
|
+
startDate: u.start_date ? new Date(u.start_date) : new Date(),
|
|
4739
|
+
updatedAt: u.updated_at ? new Date(u.updated_at) : new Date(),
|
|
4740
|
+
endDate: u.end_date ? new Date(u.end_date) : undefined,
|
|
4741
|
+
givenName: u.given_name || u.resource_given_name || '',
|
|
4742
|
+
resourceState: u.resource_state,
|
|
4743
|
+
resources: u.pod_resources,
|
|
4744
|
+
metadata: new Map(Object.entries(u.metadata || {})),
|
|
4745
|
+
}));
|
|
4746
|
+
return usages;
|
|
4687
4747
|
},
|
|
4688
4748
|
...options,
|
|
4689
4749
|
});
|
|
4690
4750
|
};
|
|
4691
4751
|
// ============================================================================
|
|
4692
|
-
//
|
|
4752
|
+
// Search Operations
|
|
4693
4753
|
// ============================================================================
|
|
4694
4754
|
/**
|
|
4695
4755
|
* Search public items (notebooks, documents, etc.)
|
|
@@ -4717,7 +4777,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4717
4777
|
});
|
|
4718
4778
|
};
|
|
4719
4779
|
// ============================================================================
|
|
4720
|
-
//
|
|
4780
|
+
// Social Media Integrations
|
|
4721
4781
|
// ============================================================================
|
|
4722
4782
|
/**
|
|
4723
4783
|
* Get GitHub profile from access token
|
|
@@ -4869,7 +4929,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4869
4929
|
});
|
|
4870
4930
|
};
|
|
4871
4931
|
// ============================================================================
|
|
4872
|
-
//
|
|
4932
|
+
// Proxy Operations
|
|
4873
4933
|
// ============================================================================
|
|
4874
4934
|
/**
|
|
4875
4935
|
* Proxy GET request
|
|
@@ -4928,7 +4988,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4928
4988
|
});
|
|
4929
4989
|
};
|
|
4930
4990
|
// ============================================================================
|
|
4931
|
-
//
|
|
4991
|
+
// Waiting List & Growth
|
|
4932
4992
|
// ============================================================================
|
|
4933
4993
|
/**
|
|
4934
4994
|
* Register to waiting list
|
|
@@ -4966,7 +5026,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
4966
5026
|
});
|
|
4967
5027
|
};
|
|
4968
5028
|
// ============================================================================
|
|
4969
|
-
//
|
|
5029
|
+
// Refresh Operations & Additional Methods
|
|
4970
5030
|
// ============================================================================
|
|
4971
5031
|
/**
|
|
4972
5032
|
* Refresh a specific user space
|
|
@@ -5406,7 +5466,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
5406
5466
|
});
|
|
5407
5467
|
};
|
|
5408
5468
|
// ============================================================================
|
|
5409
|
-
//
|
|
5469
|
+
// Additional Refresh Operations
|
|
5410
5470
|
// ============================================================================
|
|
5411
5471
|
/**
|
|
5412
5472
|
* Refresh a specific environment
|
|
@@ -5641,7 +5701,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
5641
5701
|
});
|
|
5642
5702
|
};
|
|
5643
5703
|
// ============================================================================
|
|
5644
|
-
//
|
|
5704
|
+
// Invites, Contacts, Inbounds, Outbounds
|
|
5645
5705
|
// ============================================================================
|
|
5646
5706
|
/**
|
|
5647
5707
|
* Request an invite (mutation)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIsMobile(): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024-2025 Datalayer, Inc.
|
|
3
|
+
*
|
|
4
|
+
* BSD 3-Clause License
|
|
5
|
+
*/
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
const MOBILE_BREAKPOINT = 768;
|
|
8
|
+
export function useIsMobile() {
|
|
9
|
+
const [isMobile, setIsMobile] = React.useState(undefined);
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
12
|
+
const onChange = () => {
|
|
13
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
14
|
+
};
|
|
15
|
+
mql.addEventListener('change', onChange);
|
|
16
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
17
|
+
return () => {
|
|
18
|
+
mql.removeEventListener('change', onChange);
|
|
19
|
+
};
|
|
20
|
+
}, []);
|
|
21
|
+
return !!isMobile;
|
|
22
|
+
}
|