@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
|
@@ -11,6 +11,23 @@ import { requestDatalayerAPI } from '../api/DatalayerApi.js';
|
|
|
11
11
|
export function useDatalayer(props = {}) {
|
|
12
12
|
const { loginRoute = '/login', notifyOnError = true } = props;
|
|
13
13
|
const location = useLocation();
|
|
14
|
+
const resolveLoginRoute = (candidateRoute) => {
|
|
15
|
+
if (candidateRoute !== '/login') {
|
|
16
|
+
return candidateRoute;
|
|
17
|
+
}
|
|
18
|
+
const pathname = location.pathname || '';
|
|
19
|
+
const kernelsPrefix = '/jupyter/kernels';
|
|
20
|
+
const iamPrefix = '/jupyter/iam';
|
|
21
|
+
if (pathname.includes(kernelsPrefix)) {
|
|
22
|
+
const [base] = pathname.split(kernelsPrefix);
|
|
23
|
+
return `${base}${kernelsPrefix}/login`;
|
|
24
|
+
}
|
|
25
|
+
if (pathname.includes(iamPrefix)) {
|
|
26
|
+
const [base] = pathname.split(iamPrefix);
|
|
27
|
+
return `${base}${iamPrefix}/login`;
|
|
28
|
+
}
|
|
29
|
+
return candidateRoute;
|
|
30
|
+
};
|
|
14
31
|
/*
|
|
15
32
|
// TODO Fix the conditional hook call.
|
|
16
33
|
const coreStore = useCoreStore();
|
|
@@ -35,15 +52,19 @@ export function useDatalayer(props = {}) {
|
|
|
35
52
|
.catch(error => {
|
|
36
53
|
if (error.name === 'RunResponseError') {
|
|
37
54
|
const responseError = error;
|
|
55
|
+
const isForbidden = responseError.response.status === 403;
|
|
38
56
|
if (responseError.response.status === 401) {
|
|
39
57
|
console.log('Datalayer sent a 401 return code.');
|
|
40
|
-
|
|
58
|
+
const resolvedLoginRoute = resolveLoginRoute(loginRoute_);
|
|
59
|
+
const alreadyOnLoginRoute = location.pathname === resolvedLoginRoute ||
|
|
60
|
+
location.pathname.endsWith('/login');
|
|
61
|
+
if (!alreadyOnLoginRoute) {
|
|
41
62
|
iamStore.logout();
|
|
42
|
-
navigate(
|
|
63
|
+
navigate(resolvedLoginRoute);
|
|
43
64
|
}
|
|
44
65
|
}
|
|
45
66
|
else {
|
|
46
|
-
if (notifyOnError_) {
|
|
67
|
+
if (notifyOnError_ && !isForbidden) {
|
|
47
68
|
if (responseError.warnings) {
|
|
48
69
|
responseError.warnings.forEach(warning => enqueueToast(`${warning}`, { variant: 'warning' }));
|
|
49
70
|
}
|
|
@@ -64,9 +85,16 @@ export function useDatalayer(props = {}) {
|
|
|
64
85
|
}
|
|
65
86
|
}
|
|
66
87
|
const response = {
|
|
88
|
+
success: false,
|
|
67
89
|
sucess: false,
|
|
68
90
|
message: responseError.message,
|
|
69
91
|
errors: responseError.errors,
|
|
92
|
+
warnings: responseError.warnings,
|
|
93
|
+
detail: responseError.detail,
|
|
94
|
+
status: responseError.response.status,
|
|
95
|
+
code: responseError.response.status === 403
|
|
96
|
+
? 'FORBIDDEN'
|
|
97
|
+
: `HTTP_${responseError.response.status}`,
|
|
70
98
|
};
|
|
71
99
|
return response;
|
|
72
100
|
}
|
package/lib/hooks/useIAM.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
6
|
import { useCache } from './useCache.js';
|
|
7
|
-
import {
|
|
7
|
+
import { useIAMStore, useLayoutStore, useOrganizationStore, useSpaceStore, } from '../state/index.js';
|
|
8
8
|
import { asUser, ANONYMOUS_USER, ANONYMOUS_USER_TOKEN, } from '../models/index.js';
|
|
9
9
|
import { requestDatalayerAPI, } from '../api/DatalayerApi.js';
|
|
10
10
|
export const useIAM = (props = { user: undefined, token: undefined }) => {
|
|
@@ -72,13 +72,6 @@ export const useIAM = (props = { user: undefined, token: undefined }) => {
|
|
|
72
72
|
const user = asUser(whoamiData.profile);
|
|
73
73
|
setIAMState({ user, token });
|
|
74
74
|
iamStore.setLogin(user, token);
|
|
75
|
-
// TODO centralize user settings management.
|
|
76
|
-
const aiagentsRunUrl = user.settings?.aiAgentsUrl;
|
|
77
|
-
if (aiagentsRunUrl) {
|
|
78
|
-
coreStore.getState().setConfiguration({
|
|
79
|
-
aiagentsRunUrl,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
75
|
}
|
|
83
76
|
}
|
|
84
77
|
}, [token, whoamiData, iamStore]);
|
|
@@ -385,6 +385,10 @@ export declare function useCreateProject(): {
|
|
|
385
385
|
mutate: import("@tanstack/react-query").UseMutateFunction<any, Error, {
|
|
386
386
|
space: Partial<import("..").IAnySpace>;
|
|
387
387
|
organization?: import("..").IAnyOrganization;
|
|
388
|
+
team?: {
|
|
389
|
+
id?: string;
|
|
390
|
+
handle?: string;
|
|
391
|
+
};
|
|
388
392
|
}, unknown>;
|
|
389
393
|
reset: () => void;
|
|
390
394
|
context: unknown;
|
|
@@ -395,6 +399,10 @@ export declare function useCreateProject(): {
|
|
|
395
399
|
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<any, Error, {
|
|
396
400
|
space: Partial<import("..").IAnySpace>;
|
|
397
401
|
organization?: import("..").IAnyOrganization;
|
|
402
|
+
team?: {
|
|
403
|
+
id?: string;
|
|
404
|
+
handle?: string;
|
|
405
|
+
};
|
|
398
406
|
}, unknown>;
|
|
399
407
|
} | {
|
|
400
408
|
createProject: (request: CreateProjectRequest) => Promise<any>;
|
|
@@ -402,6 +410,10 @@ export declare function useCreateProject(): {
|
|
|
402
410
|
variables: {
|
|
403
411
|
space: Partial<import("..").IAnySpace>;
|
|
404
412
|
organization?: import("..").IAnyOrganization;
|
|
413
|
+
team?: {
|
|
414
|
+
id?: string;
|
|
415
|
+
handle?: string;
|
|
416
|
+
};
|
|
405
417
|
};
|
|
406
418
|
error: null;
|
|
407
419
|
isError: false;
|
|
@@ -412,6 +424,10 @@ export declare function useCreateProject(): {
|
|
|
412
424
|
mutate: import("@tanstack/react-query").UseMutateFunction<any, Error, {
|
|
413
425
|
space: Partial<import("..").IAnySpace>;
|
|
414
426
|
organization?: import("..").IAnyOrganization;
|
|
427
|
+
team?: {
|
|
428
|
+
id?: string;
|
|
429
|
+
handle?: string;
|
|
430
|
+
};
|
|
415
431
|
}, unknown>;
|
|
416
432
|
reset: () => void;
|
|
417
433
|
context: unknown;
|
|
@@ -422,6 +438,10 @@ export declare function useCreateProject(): {
|
|
|
422
438
|
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<any, Error, {
|
|
423
439
|
space: Partial<import("..").IAnySpace>;
|
|
424
440
|
organization?: import("..").IAnyOrganization;
|
|
441
|
+
team?: {
|
|
442
|
+
id?: string;
|
|
443
|
+
handle?: string;
|
|
444
|
+
};
|
|
425
445
|
}, unknown>;
|
|
426
446
|
} | {
|
|
427
447
|
createProject: (request: CreateProjectRequest) => Promise<any>;
|
|
@@ -430,6 +450,10 @@ export declare function useCreateProject(): {
|
|
|
430
450
|
variables: {
|
|
431
451
|
space: Partial<import("..").IAnySpace>;
|
|
432
452
|
organization?: import("..").IAnyOrganization;
|
|
453
|
+
team?: {
|
|
454
|
+
id?: string;
|
|
455
|
+
handle?: string;
|
|
456
|
+
};
|
|
433
457
|
};
|
|
434
458
|
isError: true;
|
|
435
459
|
isIdle: false;
|
|
@@ -439,6 +463,10 @@ export declare function useCreateProject(): {
|
|
|
439
463
|
mutate: import("@tanstack/react-query").UseMutateFunction<any, Error, {
|
|
440
464
|
space: Partial<import("..").IAnySpace>;
|
|
441
465
|
organization?: import("..").IAnyOrganization;
|
|
466
|
+
team?: {
|
|
467
|
+
id?: string;
|
|
468
|
+
handle?: string;
|
|
469
|
+
};
|
|
442
470
|
}, unknown>;
|
|
443
471
|
reset: () => void;
|
|
444
472
|
context: unknown;
|
|
@@ -449,6 +477,10 @@ export declare function useCreateProject(): {
|
|
|
449
477
|
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<any, Error, {
|
|
450
478
|
space: Partial<import("..").IAnySpace>;
|
|
451
479
|
organization?: import("..").IAnyOrganization;
|
|
480
|
+
team?: {
|
|
481
|
+
id?: string;
|
|
482
|
+
handle?: string;
|
|
483
|
+
};
|
|
452
484
|
}, unknown>;
|
|
453
485
|
} | {
|
|
454
486
|
createProject: (request: CreateProjectRequest) => Promise<any>;
|
|
@@ -457,6 +489,10 @@ export declare function useCreateProject(): {
|
|
|
457
489
|
variables: {
|
|
458
490
|
space: Partial<import("..").IAnySpace>;
|
|
459
491
|
organization?: import("..").IAnyOrganization;
|
|
492
|
+
team?: {
|
|
493
|
+
id?: string;
|
|
494
|
+
handle?: string;
|
|
495
|
+
};
|
|
460
496
|
};
|
|
461
497
|
isError: false;
|
|
462
498
|
isIdle: false;
|
|
@@ -466,6 +502,10 @@ export declare function useCreateProject(): {
|
|
|
466
502
|
mutate: import("@tanstack/react-query").UseMutateFunction<any, Error, {
|
|
467
503
|
space: Partial<import("..").IAnySpace>;
|
|
468
504
|
organization?: import("..").IAnyOrganization;
|
|
505
|
+
team?: {
|
|
506
|
+
id?: string;
|
|
507
|
+
handle?: string;
|
|
508
|
+
};
|
|
469
509
|
}, unknown>;
|
|
470
510
|
reset: () => void;
|
|
471
511
|
context: unknown;
|
|
@@ -476,6 +516,10 @@ export declare function useCreateProject(): {
|
|
|
476
516
|
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<any, Error, {
|
|
477
517
|
space: Partial<import("..").IAnySpace>;
|
|
478
518
|
organization?: import("..").IAnyOrganization;
|
|
519
|
+
team?: {
|
|
520
|
+
id?: string;
|
|
521
|
+
handle?: string;
|
|
522
|
+
};
|
|
479
523
|
}, unknown>;
|
|
480
524
|
};
|
|
481
525
|
/**
|
package/lib/hooks/useProjects.js
CHANGED
|
@@ -16,6 +16,31 @@ import { useMemo, useCallback } from 'react';
|
|
|
16
16
|
import { useCache } from './useCache.js';
|
|
17
17
|
/** The space type value used to identify project spaces in Solr */
|
|
18
18
|
export const PROJECT_SPACE_VARIANT = 'project';
|
|
19
|
+
const normalizeProjectItems = (items) => {
|
|
20
|
+
if (Array.isArray(items)) {
|
|
21
|
+
return items;
|
|
22
|
+
}
|
|
23
|
+
if (items && typeof items === 'object') {
|
|
24
|
+
return [items];
|
|
25
|
+
}
|
|
26
|
+
return [];
|
|
27
|
+
};
|
|
28
|
+
const isProjectSpace = (space) => {
|
|
29
|
+
const variant = space?.variant ?? space?.variant_s;
|
|
30
|
+
if (variant !== PROJECT_SPACE_VARIANT) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const items = normalizeProjectItems(space?.items);
|
|
34
|
+
if (items.length === 0) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
const hasNotebook = items.some(item => (item?.type_s ?? item?.type) === 'notebook');
|
|
38
|
+
const hasDocument = items.some(item => {
|
|
39
|
+
const type = item?.type_s ?? item?.type;
|
|
40
|
+
return type === 'document' || type === 'lexical';
|
|
41
|
+
});
|
|
42
|
+
return hasNotebook && hasDocument;
|
|
43
|
+
};
|
|
19
44
|
/**
|
|
20
45
|
* Hook to fetch user's projects (spaces with type "project").
|
|
21
46
|
*
|
|
@@ -29,8 +54,7 @@ export function useProjects() {
|
|
|
29
54
|
if (!allSpaces)
|
|
30
55
|
return [];
|
|
31
56
|
return allSpaces
|
|
32
|
-
.filter((space) => space
|
|
33
|
-
space.type_s === PROJECT_SPACE_VARIANT)
|
|
57
|
+
.filter((space) => isProjectSpace(space))
|
|
34
58
|
.map((space) => ({
|
|
35
59
|
uid: space.uid,
|
|
36
60
|
id: space.id ?? space.uid,
|
package/lib/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { API_BASE_PATHS } from './api/constants';
|
|
|
11
11
|
export * as runtimesApi from './api/runtimes';
|
|
12
12
|
export * as iamApi from './api/iam';
|
|
13
13
|
export * as spacerApi from './api/spacer';
|
|
14
|
-
export { DatalayerClient, type DatalayerClientConfig, type ClientHandlers, User, Runtime, Environment, Snapshot, Space, Project, Notebook, LexicalDTO, Secret, Credits, Item, type RuntimeJSON, type EnvironmentJSON, type UserJSON, type RuntimeData, type EnvironmentData, type UserData, type SpaceData, type SpaceItem, type NotebookData, type LexicalData, type
|
|
15
|
-
export { getEnvironments, createRuntime, getRuntimes, deleteRuntime, snapshotRuntime,
|
|
14
|
+
export { DatalayerClient, type DatalayerClientConfig, type ClientHandlers, User, Runtime, Environment, Snapshot, Space, Project, Notebook, LexicalDTO, Secret, Credits, Item, type RuntimeJSON, type EnvironmentJSON, type UserJSON, type RuntimeData, type EnvironmentData, type UserData, type SpaceData, type SpaceItem, type NotebookData, type LexicalData, type CodeSandboxSnapshotData, type CreditsInfo, type CreditReservation, type CreateRuntimeRequest, type CreateRuntimeResponse, type ListRuntimesResponse, type ListEnvironmentsResponse, type CreateCodeSandboxSnapshotRequest, type CreateCodeSandboxSnapshotResponse, type GetCodeSandboxSnapshotResponse, type ListCodeSandboxSnapshotsResponse, type CreateSpaceRequest, type CreateSpaceResponse, type SpacesForUserResponse, type CollaborationSessionResponse, type DeleteSpaceItemResponse, type GetSpaceItemResponse, type GetSpaceItemsResponse, type CreateNotebookRequest, type CreateNotebookResponse, type GetNotebookResponse, type UpdateNotebookRequest, type UpdateNotebookResponse, type CreateLexicalRequest, type CreateLexicalResponse, type GetLexicalResponse, type UpdateLexicalRequest, type UpdateLexicalResponse, type CreditsResponse, type CreateDatasourceResponse, type GetDatasourceResponse, type ListDatasourcesResponse, type UpdateDatasourceResponse, type CreateSecretRequest, type CreateSecretResponse, type GetSecretResponse, type ListSecretsResponse, type UpdateSecretRequest, type UpdateSecretResponse, type SpaceJSON, type ProjectJSON, type ProjectDefaultItems, type UpdateSpaceRequest, type GetSpaceResponse, type UpdateSpaceResponse, type DeleteSpaceResponse, type GetSpaceDefaultItemsResponse, type GetSpacesByTypeResponse, type NotebookJSON, type LexicalJSON, type CodeSandboxSnapshotJSON, HealthCheck, type HealthCheckJSON, type LoginRequest, type LoginResponse, type UserMeResponse, type MembershipsResponse, type WhoAmIResponse, type HealthzPingResponse, AuthenticationManager, type IUser, type IBaseUser, type ICell, type IDatasource, type IDatasourceVariant, type ICredits, type ICreditsReservation, type ISpaceItem, type ISurvey, type ISpace, type IBaseSpace, type IAnySpace, type ISpaceVariant, type IBaseTeam, type IAnyTeam, type IOrganization, type IAnyOrganization, type IBaseOrganization, type IRuntimeModel, type IRuntimePod, type IRuntimeType, type IRuntimeLocation, type IRuntimeCapabilities, type ICodeSandboxSnapshot, type IDatalayerEnvironment, type IResources, type ISnippet, type IRole, type IAssignment, type IContact, type ICourse, type IOrganizationMember, type IPage, type PageTagName, type PageTheme, type PageVariant, type ISecret, type ISecretVariant, type SecretData, type SecretJSON, type DatasourceData, type DatasourceJSON, type DatasourceType, type CreateDatasourceRequest, type UpdateDatasourceRequest, Datasource, type IIAMToken, type IIAMTokenVariant, type IDocument, type IBaseDocument, type IEnvironment, type IExercise, type ICode, type IHelp, type IInvite, type ILesson, type INotebook, type IBaseNotebook, type ISchool, type ITeam, type TeamMember, type IUserOnboarding, type IClient, type IOnboardingPosition, type IOnboardingTours, type ITour, type ITourStatus, type IUserSettings, type IDataset, type IUsage, type IItem, type IItemType, type Member, type Profile, type SpaceMember, type IContactEvent, type IContactIAMProvider, type IStudentItem, type Instructor, type IStudent, type IDean, type IUserEvent, type IIAMProviderLinked, type IContent, type AuthResult, type TokenValidationResult, type AuthOptions, type TokenStorage, type IRuntimeOptions, type IMultiServiceManager, type IRemoteServicesManager, type IEnvironmentsManager, type IRemoteRuntimesManager, type NavigationLinkProps, type IDatalayerCoreConfig, type IRuntimesConfiguration, type IIAMProviderName, } from './client';
|
|
15
|
+
export { getEnvironments, createRuntime, getRuntimes, deleteRuntime, snapshotRuntime, getSandboxSnapshots, loadSandboxSnapshot, } from './stateful/runtimes/actions';
|
|
16
16
|
export * from './otel';
|
|
17
17
|
export * from './views';
|
package/lib/index.js
CHANGED
|
@@ -25,7 +25,7 @@ User, Runtime, Environment, Snapshot, Space, Project, Notebook, LexicalDTO, Secr
|
|
|
25
25
|
// Export auth
|
|
26
26
|
AuthenticationManager, Datasource, } from './client/index.js';
|
|
27
27
|
// Export commonly used functions directly for convenience
|
|
28
|
-
export { getEnvironments, createRuntime, getRuntimes, deleteRuntime, snapshotRuntime,
|
|
28
|
+
export { getEnvironments, createRuntime, getRuntimes, deleteRuntime, snapshotRuntime, getSandboxSnapshots, loadSandboxSnapshot, } from './stateful/runtimes/actions.js';
|
|
29
29
|
// OTEL observability components, hooks, and types
|
|
30
30
|
export * from './otel/index.js';
|
|
31
31
|
// Reusable views (sign-in pages, etc.)
|
|
@@ -4,10 +4,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
6
|
import { AlertIcon } from '@primer/octicons-react';
|
|
7
|
-
import {
|
|
7
|
+
import { Box, Button, Flash } from '@primer/react';
|
|
8
8
|
import { useNavigate } from '../../hooks/index.js';
|
|
9
9
|
export const FlashMock = () => {
|
|
10
10
|
const navigate = useNavigate();
|
|
11
|
-
return (
|
|
11
|
+
return (_jsx(Flash, { variant: "warning", style: { marginBottom: 10 }, children: _jsxs(Box, { sx: {
|
|
12
|
+
display: 'flex',
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
justifyContent: 'space-between',
|
|
15
|
+
gap: 3,
|
|
16
|
+
width: '100%',
|
|
17
|
+
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: [_jsx(AlertIcon, {}), _jsx("span", { children: "This is placeholder content. Contact us to learn more about this feature." })] }), _jsx(Button, { size: "small", onClick: () => navigate('/contact'), children: "Contact Us" })] }) }));
|
|
12
18
|
};
|
|
13
19
|
export default FlashMock;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Code Sandbox snapshot from API.
|
|
3
3
|
*/
|
|
4
|
-
export interface
|
|
4
|
+
export interface IAPICodeSandboxSnapshot {
|
|
5
5
|
/**
|
|
6
6
|
* Snapshot UID
|
|
7
7
|
*/
|
|
@@ -44,9 +44,9 @@ export interface IAPIRuntimeSnapshot {
|
|
|
44
44
|
status: string;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
47
|
+
* Code Sandbox snapshot model.
|
|
48
48
|
*/
|
|
49
|
-
export interface
|
|
49
|
+
export interface ICodeSandboxSnapshot {
|
|
50
50
|
/**
|
|
51
51
|
* Snapshot UID
|
|
52
52
|
*/
|
|
@@ -89,4 +89,4 @@ export interface IRuntimeSnapshot {
|
|
|
89
89
|
*/
|
|
90
90
|
status: string;
|
|
91
91
|
}
|
|
92
|
-
export declare function
|
|
92
|
+
export declare function asCodeSandboxSnapshot(s: IAPICodeSandboxSnapshot): ICodeSandboxSnapshot;
|
|
@@ -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
|
-
export function
|
|
5
|
+
export function asCodeSandboxSnapshot(s) {
|
|
6
6
|
const { uid, updated_at, format_version, ...others } = s;
|
|
7
7
|
return {
|
|
8
8
|
...others,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Snapshot domain model for the Datalayer Client.
|
|
3
3
|
*
|
|
4
|
-
* @module models/
|
|
4
|
+
* @module models/CodeSandboxSnapshotDTO
|
|
5
5
|
*/
|
|
6
6
|
import type { DatalayerClient } from '../index';
|
|
7
7
|
import { RuntimeDTO } from './RuntimeDTO';
|
|
8
8
|
/**
|
|
9
9
|
* Represents a runthime snapshot of a runtime's state and files.
|
|
10
|
-
* @interface
|
|
10
|
+
* @interface CodeSandboxSnapshotData
|
|
11
11
|
*/
|
|
12
|
-
export interface
|
|
12
|
+
export interface CodeSandboxSnapshotData {
|
|
13
13
|
/** Unique identifier for the snapshot */
|
|
14
14
|
uid: string;
|
|
15
15
|
/** Name of the snapshot */
|
|
@@ -42,7 +42,7 @@ export interface RuntimeSnapshotData {
|
|
|
42
42
|
* This is the contract that Client consumers can rely on.
|
|
43
43
|
* The raw API may change, but this interface remains stable.
|
|
44
44
|
*/
|
|
45
|
-
export interface
|
|
45
|
+
export interface CodeSandboxSnapshotJSON {
|
|
46
46
|
/** Unique identifier for the snapshot */
|
|
47
47
|
uid: string;
|
|
48
48
|
/** Name of the snapshot */
|
|
@@ -55,10 +55,10 @@ export interface RuntimeSnapshotJSON {
|
|
|
55
55
|
updatedAt: string;
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
* Request payload for creating a
|
|
59
|
-
* @interface
|
|
58
|
+
* Request payload for creating a code sandbox snapshot
|
|
59
|
+
* @interface CreateCodeSandboxSnapshotRequest
|
|
60
60
|
*/
|
|
61
|
-
export interface
|
|
61
|
+
export interface CreateCodeSandboxSnapshotRequest {
|
|
62
62
|
/** Pod name of the runtime to snapshot */
|
|
63
63
|
pod_name: string;
|
|
64
64
|
/** Name for the snapshot */
|
|
@@ -69,44 +69,44 @@ export interface CreateRuntimeSnapshotRequest {
|
|
|
69
69
|
stop: boolean;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
* Response for getting a specific
|
|
73
|
-
* @interface
|
|
72
|
+
* Response for getting a specific code snapshot snapshot
|
|
73
|
+
* @interface GetCodeSandboxSnapshotResponse
|
|
74
74
|
*/
|
|
75
|
-
export interface
|
|
75
|
+
export interface GetCodeSandboxSnapshotResponse {
|
|
76
76
|
/** Indicates if the request was successful */
|
|
77
77
|
success: boolean;
|
|
78
78
|
/** Response message */
|
|
79
79
|
message: string;
|
|
80
80
|
/** The snapshot details */
|
|
81
|
-
snapshot:
|
|
81
|
+
snapshot: CodeSandboxSnapshotData;
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
|
-
* Response for creating a
|
|
85
|
-
* @interface
|
|
84
|
+
* Response for creating a code sandbox snapshot
|
|
85
|
+
* @interface CreateCodeSandboxSnapshotResponse
|
|
86
86
|
*/
|
|
87
|
-
export interface
|
|
87
|
+
export interface CreateCodeSandboxSnapshotResponse {
|
|
88
88
|
/** Indicates if the request was successful */
|
|
89
89
|
success: boolean;
|
|
90
90
|
/** Response message */
|
|
91
91
|
message: string;
|
|
92
92
|
/** The created snapshot details */
|
|
93
|
-
snapshot:
|
|
93
|
+
snapshot: CodeSandboxSnapshotData;
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
|
-
* Response from listing
|
|
97
|
-
* @interface
|
|
96
|
+
* Response from listing code sandbox snapshots
|
|
97
|
+
* @interface ListCodeSandboxSnapshotsResponse
|
|
98
98
|
*/
|
|
99
|
-
export interface
|
|
99
|
+
export interface ListCodeSandboxSnapshotsResponse {
|
|
100
100
|
/** Whether the request was successful */
|
|
101
101
|
success: boolean;
|
|
102
102
|
/** Response message from the server */
|
|
103
103
|
message: string;
|
|
104
|
-
/** Array of
|
|
105
|
-
snapshots:
|
|
104
|
+
/** Array of code sandbox snapshots */
|
|
105
|
+
snapshots: CodeSandboxSnapshotData[];
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Snapshot domain model that wraps API responses with convenient methods.
|
|
109
|
-
* Provides
|
|
109
|
+
* Provides code sandbox snapshot management with data refresh and lifecycle operations.
|
|
110
110
|
*
|
|
111
111
|
* @example
|
|
112
112
|
* ```typescript
|
|
@@ -114,17 +114,17 @@ export interface ListRuntimeSnapshotsResponse {
|
|
|
114
114
|
* const runtime = await snapshot.restore();
|
|
115
115
|
* ```
|
|
116
116
|
*/
|
|
117
|
-
export declare class
|
|
118
|
-
protected _data:
|
|
117
|
+
export declare class CodeSandboxSnapshotDTO {
|
|
118
|
+
protected _data: CodeSandboxSnapshotData;
|
|
119
119
|
private _client;
|
|
120
120
|
private _deleted;
|
|
121
121
|
/**
|
|
122
|
-
* Create a
|
|
122
|
+
* Create a Code Sandbox Snapshot instance.
|
|
123
123
|
*
|
|
124
124
|
* @param data - Snapshot data from API
|
|
125
125
|
* @param client - Client instance
|
|
126
126
|
*/
|
|
127
|
-
constructor(data:
|
|
127
|
+
constructor(data: CodeSandboxSnapshotData, client: DatalayerClient);
|
|
128
128
|
/**
|
|
129
129
|
* Check if this snapshot has been deleted and throw error if so.
|
|
130
130
|
* @throws Error if deleted
|
|
@@ -146,28 +146,28 @@ export declare class RuntimeSnapshotDTO {
|
|
|
146
146
|
*/
|
|
147
147
|
delete(): Promise<void>;
|
|
148
148
|
/**
|
|
149
|
-
* Create a
|
|
149
|
+
* Create a code sandbox from this snapshot (restore functionality).
|
|
150
150
|
*
|
|
151
151
|
* @param minutesLimit - Time limit in minutes for the restored runtime
|
|
152
152
|
* @returns Created Runtime instance
|
|
153
153
|
*/
|
|
154
154
|
restore(minutesLimit: number): Promise<RuntimeDTO>;
|
|
155
155
|
/**
|
|
156
|
-
* Get snapshot data in camelCase format.
|
|
156
|
+
* Get code snapshot snapshot data in camelCase format.
|
|
157
157
|
* Returns only the core fields that consumers need.
|
|
158
158
|
* This provides a stable interface regardless of API changes.
|
|
159
159
|
* Note: Returns current cached state - call getStatus() first if you need fresh data.
|
|
160
160
|
*
|
|
161
|
-
* @returns Core snapshot data with camelCase properties
|
|
161
|
+
* @returns Core code snapshot snapshot data with camelCase properties
|
|
162
162
|
*/
|
|
163
|
-
toJSON():
|
|
163
|
+
toJSON(): CodeSandboxSnapshotJSON;
|
|
164
164
|
/**
|
|
165
165
|
* Get the raw snapshot data exactly as received from the API.
|
|
166
166
|
* This preserves the original snake_case naming from the API response.
|
|
167
167
|
*
|
|
168
168
|
* @returns Raw snapshot data from API
|
|
169
169
|
*/
|
|
170
|
-
rawData():
|
|
170
|
+
rawData(): CodeSandboxSnapshotData;
|
|
171
171
|
/** String representation of the snapshot. */
|
|
172
172
|
toString(): string;
|
|
173
173
|
}
|
|
@@ -6,7 +6,7 @@ import { snapshots } from '../api/runtimes/index.js';
|
|
|
6
6
|
import { validateJSON } from '../api/utils/validation.js';
|
|
7
7
|
/**
|
|
8
8
|
* Snapshot domain model that wraps API responses with convenient methods.
|
|
9
|
-
* Provides
|
|
9
|
+
* Provides code sandbox snapshot management with data refresh and lifecycle operations.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```typescript
|
|
@@ -14,12 +14,12 @@ import { validateJSON } from '../api/utils/validation.js';
|
|
|
14
14
|
* const runtime = await snapshot.restore();
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
export class
|
|
17
|
+
export class CodeSandboxSnapshotDTO {
|
|
18
18
|
_data;
|
|
19
19
|
_client;
|
|
20
20
|
_deleted = false;
|
|
21
21
|
/**
|
|
22
|
-
* Create a
|
|
22
|
+
* Create a Code Sandbox Snapshot instance.
|
|
23
23
|
*
|
|
24
24
|
* @param data - Snapshot data from API
|
|
25
25
|
* @param client - Client instance
|
|
@@ -83,7 +83,7 @@ export class RuntimeSnapshotDTO {
|
|
|
83
83
|
this._deleted = true;
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
|
-
* Create a
|
|
86
|
+
* Create a code sandbox from this snapshot (restore functionality).
|
|
87
87
|
*
|
|
88
88
|
* @param minutesLimit - Time limit in minutes for the restored runtime
|
|
89
89
|
* @returns Created Runtime instance
|
|
@@ -102,12 +102,12 @@ export class RuntimeSnapshotDTO {
|
|
|
102
102
|
// Utility Methods
|
|
103
103
|
// ========================================================================
|
|
104
104
|
/**
|
|
105
|
-
* Get snapshot data in camelCase format.
|
|
105
|
+
* Get code snapshot snapshot data in camelCase format.
|
|
106
106
|
* Returns only the core fields that consumers need.
|
|
107
107
|
* This provides a stable interface regardless of API changes.
|
|
108
108
|
* Note: Returns current cached state - call getStatus() first if you need fresh data.
|
|
109
109
|
*
|
|
110
|
-
* @returns Core snapshot data with camelCase properties
|
|
110
|
+
* @returns Core code snapshot snapshot data with camelCase properties
|
|
111
111
|
*/
|
|
112
112
|
toJSON() {
|
|
113
113
|
this._checkDeleted();
|
package/lib/models/IAM.d.ts
CHANGED
|
@@ -115,3 +115,69 @@ export interface MembershipsResponse {
|
|
|
115
115
|
/** Memberships information */
|
|
116
116
|
memberships: any[];
|
|
117
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* A principal (self / member organization / member team) the authenticated
|
|
120
|
+
* user can share artifacts with.
|
|
121
|
+
*/
|
|
122
|
+
export interface ShareablePrincipal {
|
|
123
|
+
kind: 'user' | 'organization' | 'team';
|
|
124
|
+
uid: string;
|
|
125
|
+
handle: string;
|
|
126
|
+
name?: string | null;
|
|
127
|
+
description?: string | null;
|
|
128
|
+
email?: string | null;
|
|
129
|
+
avatar_url?: string | null;
|
|
130
|
+
/** Parent organization UID — set when kind === 'team'. */
|
|
131
|
+
organization_uid?: string | null;
|
|
132
|
+
/** Parent organization handle — set when kind === 'team'. */
|
|
133
|
+
organization_handle?: string | null;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Response from the /principals/shareable endpoint.
|
|
137
|
+
*/
|
|
138
|
+
export interface ShareablePrincipalsResponse {
|
|
139
|
+
success: boolean;
|
|
140
|
+
message?: string;
|
|
141
|
+
principals: ShareablePrincipal[];
|
|
142
|
+
}
|
|
143
|
+
export interface PrincipalSearchUser {
|
|
144
|
+
uid: string;
|
|
145
|
+
handle_s: string;
|
|
146
|
+
first_name_t?: string;
|
|
147
|
+
last_name_t?: string;
|
|
148
|
+
display_name_t?: string;
|
|
149
|
+
display_name?: string;
|
|
150
|
+
origin_s?: string;
|
|
151
|
+
origin?: string;
|
|
152
|
+
avatar_url_s?: string;
|
|
153
|
+
avatarUrl?: string;
|
|
154
|
+
[key: string]: any;
|
|
155
|
+
}
|
|
156
|
+
export interface PrincipalSearchTeam {
|
|
157
|
+
uid: string;
|
|
158
|
+
handle_s: string;
|
|
159
|
+
name_t?: string;
|
|
160
|
+
description_t?: string;
|
|
161
|
+
organization_uid?: string;
|
|
162
|
+
organization_handle_s?: string;
|
|
163
|
+
[key: string]: any;
|
|
164
|
+
}
|
|
165
|
+
export interface PrincipalSearchOrganization {
|
|
166
|
+
uid: string;
|
|
167
|
+
handle_s: string;
|
|
168
|
+
name_t?: string;
|
|
169
|
+
description_t?: string;
|
|
170
|
+
[key: string]: any;
|
|
171
|
+
}
|
|
172
|
+
export interface PrincipalSearchResponseData {
|
|
173
|
+
users: PrincipalSearchUser[];
|
|
174
|
+
teams: PrincipalSearchTeam[];
|
|
175
|
+
organizations: PrincipalSearchOrganization[];
|
|
176
|
+
principalTypes: string[];
|
|
177
|
+
total: number;
|
|
178
|
+
}
|
|
179
|
+
export interface PrincipalSearchResponse {
|
|
180
|
+
success: boolean;
|
|
181
|
+
message: string;
|
|
182
|
+
data: PrincipalSearchResponseData;
|
|
183
|
+
}
|
package/lib/models/Page.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { INotebookContent } from '@jupyterlab/nbformat';
|
|
2
2
|
import { IUser } from './User';
|
|
3
3
|
import { PageTagName } from './PageTag';
|
|
4
|
-
import {
|
|
4
|
+
import { ICodeSandboxSnapshot } from './CodeSandboxSnapshot';
|
|
5
5
|
export type PageTheme = 'default';
|
|
6
6
|
export type PageVariant = 'document' | 'cell' | 'notebook';
|
|
7
7
|
/**
|
|
@@ -29,7 +29,7 @@ export type IPage = {
|
|
|
29
29
|
screenCapture?: string;
|
|
30
30
|
creator?: IUser;
|
|
31
31
|
creatorId?: string;
|
|
32
|
-
kernelSnapshot?:
|
|
32
|
+
kernelSnapshot?: ICodeSandboxSnapshot;
|
|
33
33
|
kernelSnapshotId?: string;
|
|
34
34
|
createdAt?: string;
|
|
35
35
|
updatedAt?: string;
|