@datalayer/core 0.0.13 → 0.0.15
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/api/DatalayerApi.js +17 -5
- package/lib/api/iam/authentication.d.ts +1 -1
- package/lib/api/iam/healthz.d.ts +1 -1
- package/lib/api/iam/index.d.ts +1 -1
- package/lib/api/iam/index.js +1 -1
- package/lib/api/iam/profile.d.ts +1 -1
- package/lib/api/iam/usage.d.ts +1 -39
- package/lib/api/index.d.ts +0 -1
- package/lib/api/index.js +0 -2
- package/lib/api/runtimes/environments.d.ts +2 -2
- package/lib/api/runtimes/healthz.d.ts +1 -1
- package/lib/api/runtimes/runtimes.d.ts +4 -4
- package/lib/api/runtimes/snapshots.d.ts +4 -4
- package/lib/api/spacer/documents.d.ts +1 -1
- package/lib/api/spacer/healthz.d.ts +1 -1
- package/lib/api/spacer/items.d.ts +1 -1
- package/lib/api/spacer/lexicals.d.ts +1 -1
- package/lib/api/spacer/notebooks.d.ts +1 -1
- package/lib/api/spacer/spaces.d.ts +1 -1
- package/lib/api/spacer/users.d.ts +1 -1
- package/lib/client/base.d.ts +2 -2
- package/lib/client/index.d.ts +44 -44
- package/lib/client/index.js +10 -10
- package/lib/client/mixins/IAMMixin.d.ts +7 -7
- package/lib/client/mixins/IAMMixin.js +5 -5
- package/lib/client/mixins/RuntimesMixin.d.ts +13 -13
- package/lib/client/mixins/RuntimesMixin.js +11 -11
- package/lib/client/mixins/SpacerMixin.d.ts +14 -14
- package/lib/client/mixins/SpacerMixin.js +12 -12
- package/lib/client/utils/spacerUtils.d.ts +4 -4
- package/lib/client/utils/spacerUtils.js +4 -4
- package/lib/components/checkout/StripeCheckout.js +19 -23
- package/lib/components/context/OrganizationSelect.js +12 -15
- package/lib/components/context/SpaceSelect.js +24 -25
- package/lib/components/runtimes/RuntimeLauncherDialog.js +2 -2
- package/lib/components/runtimes/RuntimePickerCell.js +1 -1
- package/lib/components/runtimes/RuntimePickerNotebook.js +1 -1
- package/lib/components/runtimes/RuntimeTransfer.d.ts +1 -1
- package/lib/hooks/useAuthorization.js +4 -2
- package/lib/hooks/useCache.d.ts +932 -285
- package/lib/hooks/useCache.js +5736 -2767
- package/lib/hooks/useCache0.d.ts +312 -0
- package/lib/hooks/useCache0.js +3189 -0
- package/lib/hooks/useIAM.js +18 -17
- package/lib/index.d.ts +1 -2
- package/lib/index.js +1 -2
- package/lib/{client/models/Credits.d.ts → models/CreditsDTO.d.ts} +38 -5
- package/lib/{client/models/Credits.js → models/CreditsDTO.js} +7 -2
- package/lib/models/Environment.d.ts +1 -1
- package/lib/{client/models/Environment.d.ts → models/EnvironmentDTO.d.ts} +55 -3
- package/lib/{client/models/Environment.js → models/EnvironmentDTO.js} +2 -2
- package/lib/{client/models → models}/HealthCheck.js +1 -1
- package/lib/{api/types/iam.d.ts → models/IAM.d.ts} +1 -87
- package/lib/{client/models/Item.d.ts → models/ItemDTO.d.ts} +6 -1
- package/lib/{client/models/Item.js → models/ItemDTO.js} +2 -7
- package/lib/{client/models/Lexical.d.ts → models/LexicalDTO.d.ts} +79 -7
- package/lib/{client/models/Lexical.js → models/LexicalDTO.js} +10 -5
- package/lib/{client/models/Notebook.d.ts → models/NotebookDTO.d.ts} +16 -7
- package/lib/{client/models/Notebook.js → models/NotebookDTO.js} +5 -5
- package/lib/models/Profile.d.ts +65 -0
- package/lib/models/Runtime.d.ts +49 -49
- package/lib/{client/models/Runtime.d.ts → models/RuntimeDTO.d.ts} +74 -5
- package/lib/{client/models/Runtime.js → models/RuntimeDTO.js} +5 -5
- package/lib/{client/models/Snapshot.d.ts → models/RuntimeSnapshotDTO.d.ts} +89 -8
- package/lib/{client/models/Snapshot.js → models/RuntimeSnapshotDTO.js} +4 -4
- package/lib/models/SpaceDTO.d.ts +280 -0
- package/lib/{client/models/Space.js → models/SpaceDTO.js} +17 -12
- package/lib/{client/models/User.d.ts → models/UserDTO.d.ts} +25 -3
- package/lib/{client/models/User.js → models/UserDTO.js} +3 -2
- package/lib/models/index.d.ts +45 -4
- package/lib/models/index.js +45 -4
- package/package.json +2 -1
- package/lib/api/types/index.d.ts +0 -34
- package/lib/api/types/index.js +0 -38
- package/lib/api/types/runtimes.d.ts +0 -205
- package/lib/api/types/runtimes.js +0 -5
- package/lib/api/types/spacer.d.ts +0 -243
- package/lib/api/types/spacer.js +0 -5
- package/lib/client/models/Space.d.ts +0 -135
- package/lib/client/models/index.d.ts +0 -26
- package/lib/client/models/index.js +0 -25
- /package/lib/{api/types/common.d.ts → models/Common.d.ts} +0 -0
- /package/lib/{api/types/common.js → models/Common.js} +0 -0
- /package/lib/{client/models → models}/HealthCheck.d.ts +0 -0
- /package/lib/{api/types/iam.js → models/IAM.js} +0 -0
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
import * as environments from '../../api/runtimes/environments';
|
|
10
10
|
import * as runtimes from '../../api/runtimes/runtimes';
|
|
11
11
|
import * as snapshots from '../../api/runtimes/snapshots';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { HealthCheck } from '
|
|
12
|
+
import { EnvironmentDTO } from '../../models/EnvironmentDTO';
|
|
13
|
+
import { RuntimeDTO } from '../../models/RuntimeDTO';
|
|
14
|
+
import { RuntimeSnapshotDTO } from '../../models/RuntimeSnapshotDTO';
|
|
15
|
+
import { HealthCheck } from '../../models/HealthCheck';
|
|
16
16
|
/** Runtimes mixin providing computational environment and runtime management. */
|
|
17
17
|
export function RuntimesMixin(Base) {
|
|
18
18
|
return class extends Base {
|
|
@@ -41,7 +41,7 @@ export function RuntimesMixin(Base) {
|
|
|
41
41
|
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
42
42
|
const response = await environments.listEnvironments(token, runtimesRunUrl);
|
|
43
43
|
// Save for later use after first call
|
|
44
|
-
this.environments = response.environments.map(env => new
|
|
44
|
+
this.environments = response.environments.map(env => new EnvironmentDTO(env, this));
|
|
45
45
|
return this.environments;
|
|
46
46
|
}
|
|
47
47
|
// ========================================================================
|
|
@@ -76,7 +76,7 @@ export function RuntimesMixin(Base) {
|
|
|
76
76
|
from: fromSnapshotId,
|
|
77
77
|
};
|
|
78
78
|
const response = await runtimes.createRuntime(token, data, runtimesRunUrl);
|
|
79
|
-
return new
|
|
79
|
+
return new RuntimeDTO(response.runtime, this);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
@@ -91,7 +91,7 @@ export function RuntimesMixin(Base) {
|
|
|
91
91
|
const token = this.getToken();
|
|
92
92
|
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
93
93
|
const response = await runtimes.listRuntimes(token, runtimesRunUrl);
|
|
94
|
-
return response.runtimes.map(r => new
|
|
94
|
+
return response.runtimes.map(r => new RuntimeDTO(r, this));
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
97
|
* Get details for a specific runtime by pod name.
|
|
@@ -102,7 +102,7 @@ export function RuntimesMixin(Base) {
|
|
|
102
102
|
const token = this.getToken();
|
|
103
103
|
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
104
104
|
const runtimeData = await runtimes.getRuntime(token, podName, runtimesRunUrl);
|
|
105
|
-
return new
|
|
105
|
+
return new RuntimeDTO(runtimeData, this);
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Delete a runtime permanently.
|
|
@@ -148,7 +148,7 @@ export function RuntimesMixin(Base) {
|
|
|
148
148
|
stop,
|
|
149
149
|
};
|
|
150
150
|
const response = await snapshots.createSnapshot(token, data, runtimesRunUrl);
|
|
151
|
-
return new
|
|
151
|
+
return new RuntimeSnapshotDTO(response.snapshot, this);
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
154
|
* List all runtime snapshots.
|
|
@@ -158,7 +158,7 @@ export function RuntimesMixin(Base) {
|
|
|
158
158
|
const token = this.getToken();
|
|
159
159
|
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
160
160
|
const response = await snapshots.listSnapshots(token, runtimesRunUrl);
|
|
161
|
-
return response.snapshots.map(s => new
|
|
161
|
+
return response.snapshots.map(s => new RuntimeSnapshotDTO(s, this));
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
164
164
|
* Get details for a specific snapshot by ID.
|
|
@@ -169,7 +169,7 @@ export function RuntimesMixin(Base) {
|
|
|
169
169
|
const token = this.getToken();
|
|
170
170
|
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
171
171
|
const response = await snapshots.getSnapshot(token, id, runtimesRunUrl);
|
|
172
|
-
return new
|
|
172
|
+
return new RuntimeSnapshotDTO(response.snapshot, this);
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
175
175
|
* Delete a snapshot permanently.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Constructor } from '../utils/mixins';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { HealthCheck } from '
|
|
2
|
+
import { NotebookDTO } from '../../models/NotebookDTO';
|
|
3
|
+
import { LexicalDTO } from '../../models/LexicalDTO';
|
|
4
|
+
import { SpaceDTO } from '../../models/SpaceDTO';
|
|
5
|
+
import { HealthCheck } from '../../models/HealthCheck';
|
|
6
6
|
/** Options for content loading with CDN support. */
|
|
7
7
|
export interface ContentLoadingOptions {
|
|
8
8
|
/** Whether to try CDN first before API (default: true) */
|
|
@@ -17,7 +17,7 @@ export declare function SpacerMixin<TBase extends Constructor>(Base: TBase): {
|
|
|
17
17
|
* Get all workspaces for the authenticated user.
|
|
18
18
|
* @returns Array of Space instances
|
|
19
19
|
*/
|
|
20
|
-
getMySpaces(): Promise<
|
|
20
|
+
getMySpaces(): Promise<SpaceDTO[]>;
|
|
21
21
|
/**
|
|
22
22
|
* Create a new workspace.
|
|
23
23
|
* @param name - Space name
|
|
@@ -29,7 +29,7 @@ export declare function SpacerMixin<TBase extends Constructor>(Base: TBase): {
|
|
|
29
29
|
* @param isPublic - Whether the space is public
|
|
30
30
|
* @returns Created Space instance
|
|
31
31
|
*/
|
|
32
|
-
createSpace(name: string, description: string, variant: string, spaceHandle: string, organizationId: string, seedSpaceId: string, isPublic: boolean): Promise<
|
|
32
|
+
createSpace(name: string, description: string, variant: string, spaceHandle: string, organizationId: string, seedSpaceId: string, isPublic: boolean): Promise<SpaceDTO>;
|
|
33
33
|
/**
|
|
34
34
|
* Create a new notebook.
|
|
35
35
|
* @param spaceId - ID of the space to create the notebook in
|
|
@@ -38,13 +38,13 @@ export declare function SpacerMixin<TBase extends Constructor>(Base: TBase): {
|
|
|
38
38
|
* @param file - Optional file for notebook content
|
|
39
39
|
* @returns Created Notebook instance
|
|
40
40
|
*/
|
|
41
|
-
createNotebook(spaceId: string, name: string, description: string, file?: File | Blob): Promise<
|
|
41
|
+
createNotebook(spaceId: string, name: string, description: string, file?: File | Blob): Promise<NotebookDTO>;
|
|
42
42
|
/**
|
|
43
43
|
* Get a notebook by ID.
|
|
44
44
|
* @param id - Notebook ID
|
|
45
45
|
* @returns Notebook instance
|
|
46
46
|
*/
|
|
47
|
-
getNotebook(id: string): Promise<
|
|
47
|
+
getNotebook(id: string): Promise<NotebookDTO>;
|
|
48
48
|
/**
|
|
49
49
|
* Update a notebook.
|
|
50
50
|
* @param id - Notebook ID
|
|
@@ -52,7 +52,7 @@ export declare function SpacerMixin<TBase extends Constructor>(Base: TBase): {
|
|
|
52
52
|
* @param description - Optional new description for the notebook
|
|
53
53
|
* @returns Updated Notebook instance
|
|
54
54
|
*/
|
|
55
|
-
updateNotebook(id: string, name?: string, description?: string): Promise<
|
|
55
|
+
updateNotebook(id: string, name?: string, description?: string): Promise<NotebookDTO>;
|
|
56
56
|
/**
|
|
57
57
|
* Create a new lexical document.
|
|
58
58
|
* @param spaceId - ID of the space to create the lexical document in
|
|
@@ -61,13 +61,13 @@ export declare function SpacerMixin<TBase extends Constructor>(Base: TBase): {
|
|
|
61
61
|
* @param file - Optional file for document content
|
|
62
62
|
* @returns Created Lexical instance
|
|
63
63
|
*/
|
|
64
|
-
createLexical(spaceId: string, name: string, description: string, file?: File | Blob): Promise<
|
|
64
|
+
createLexical(spaceId: string, name: string, description: string, file?: File | Blob): Promise<LexicalDTO>;
|
|
65
65
|
/**
|
|
66
66
|
* Get a lexical document by ID.
|
|
67
67
|
* @param id - Document ID
|
|
68
68
|
* @returns Lexical instance
|
|
69
69
|
*/
|
|
70
|
-
getLexical(id: string): Promise<
|
|
70
|
+
getLexical(id: string): Promise<LexicalDTO>;
|
|
71
71
|
/**
|
|
72
72
|
* Update a lexical document.
|
|
73
73
|
* @param id - Document ID
|
|
@@ -75,20 +75,20 @@ export declare function SpacerMixin<TBase extends Constructor>(Base: TBase): {
|
|
|
75
75
|
* @param description - Optional new description for the lexical document
|
|
76
76
|
* @returns Updated Lexical instance
|
|
77
77
|
*/
|
|
78
|
-
updateLexical(id: string, name?: string, description?: string): Promise<
|
|
78
|
+
updateLexical(id: string, name?: string, description?: string): Promise<LexicalDTO>;
|
|
79
79
|
/**
|
|
80
80
|
* Get the items of a space as model instances.
|
|
81
81
|
* @param spaceId - Space ID
|
|
82
82
|
* @returns Array of Notebook and Lexical model instances
|
|
83
83
|
*/
|
|
84
|
-
getSpaceItems(spaceId: string): Promise<(
|
|
84
|
+
getSpaceItems(spaceId: string): Promise<(NotebookDTO | LexicalDTO)[]>;
|
|
85
85
|
/**
|
|
86
86
|
* Get a single item from a space.
|
|
87
87
|
* @param itemId - Item ID to retrieve
|
|
88
88
|
* @returns Notebook or Lexical model instance
|
|
89
89
|
* @throws Error if item not found
|
|
90
90
|
*/
|
|
91
|
-
getSpaceItem(itemId: string): Promise<
|
|
91
|
+
getSpaceItem(itemId: string): Promise<NotebookDTO | LexicalDTO>;
|
|
92
92
|
/**
|
|
93
93
|
* Delete an item from a space.
|
|
94
94
|
* @param itemId - Item ID to delete
|
|
@@ -12,10 +12,10 @@ import * as users from '../../api/spacer/users';
|
|
|
12
12
|
import * as lexicals from '../../api/spacer/lexicals';
|
|
13
13
|
import * as documents from '../../api/spacer/documents';
|
|
14
14
|
import * as items from '../../api/spacer/items';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { HealthCheck } from '
|
|
15
|
+
import { NotebookDTO } from '../../models/NotebookDTO';
|
|
16
|
+
import { LexicalDTO } from '../../models/LexicalDTO';
|
|
17
|
+
import { SpaceDTO } from '../../models/SpaceDTO';
|
|
18
|
+
import { HealthCheck } from '../../models/HealthCheck';
|
|
19
19
|
import { convertSpaceItemsToModels } from '../utils/spacerUtils';
|
|
20
20
|
/** Spacer mixin providing workspace and content management. */
|
|
21
21
|
export function SpacerMixin(Base) {
|
|
@@ -31,7 +31,7 @@ export function SpacerMixin(Base) {
|
|
|
31
31
|
const token = this.getToken();
|
|
32
32
|
const spacerRunUrl = this.getSpacerRunUrl();
|
|
33
33
|
const response = await users.getMySpaces(token, spacerRunUrl);
|
|
34
|
-
return response.spaces.map(s => new
|
|
34
|
+
return response.spaces.map(s => new SpaceDTO(s, this));
|
|
35
35
|
}
|
|
36
36
|
// ========================================================================
|
|
37
37
|
// Spaces
|
|
@@ -63,7 +63,7 @@ export function SpacerMixin(Base) {
|
|
|
63
63
|
if (!response.space) {
|
|
64
64
|
throw new Error('Failed to create space: no space returned');
|
|
65
65
|
}
|
|
66
|
-
return new
|
|
66
|
+
return new SpaceDTO(response.space, this);
|
|
67
67
|
}
|
|
68
68
|
// ========================================================================
|
|
69
69
|
// Notebooks
|
|
@@ -102,7 +102,7 @@ export function SpacerMixin(Base) {
|
|
|
102
102
|
if (!response.notebook) {
|
|
103
103
|
throw new Error(`Notebook with ID '${id}' not found`);
|
|
104
104
|
}
|
|
105
|
-
return new
|
|
105
|
+
return new NotebookDTO(response.notebook, this);
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Update a notebook.
|
|
@@ -123,7 +123,7 @@ export function SpacerMixin(Base) {
|
|
|
123
123
|
if (!response.notebook) {
|
|
124
124
|
throw new Error('Failed to update notebook: no notebook returned');
|
|
125
125
|
}
|
|
126
|
-
return new
|
|
126
|
+
return new NotebookDTO(response.notebook, this);
|
|
127
127
|
}
|
|
128
128
|
// ========================================================================
|
|
129
129
|
// Lexicals
|
|
@@ -162,7 +162,7 @@ export function SpacerMixin(Base) {
|
|
|
162
162
|
if (!response.document) {
|
|
163
163
|
throw new Error(`Lexical document with ID '${id}' not found`);
|
|
164
164
|
}
|
|
165
|
-
return new
|
|
165
|
+
return new LexicalDTO(response.document, this);
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
168
168
|
* Update a lexical document.
|
|
@@ -180,7 +180,7 @@ export function SpacerMixin(Base) {
|
|
|
180
180
|
if (description !== undefined)
|
|
181
181
|
data.description = description;
|
|
182
182
|
const response = await lexicals.updateLexical(token, id, data, spacerRunUrl);
|
|
183
|
-
return new
|
|
183
|
+
return new LexicalDTO(response.document, this);
|
|
184
184
|
}
|
|
185
185
|
// ========================================================================
|
|
186
186
|
// Items
|
|
@@ -213,11 +213,11 @@ export function SpacerMixin(Base) {
|
|
|
213
213
|
// Determine item type and create appropriate model
|
|
214
214
|
const item = response.item;
|
|
215
215
|
if (item.type_s === 'notebook' || item.notebook_name_s !== undefined) {
|
|
216
|
-
return new
|
|
216
|
+
return new NotebookDTO(item, this);
|
|
217
217
|
}
|
|
218
218
|
else if (item.type_s === 'lexical' ||
|
|
219
219
|
item.document_name_s !== undefined) {
|
|
220
|
-
return new
|
|
220
|
+
return new LexicalDTO(item, this);
|
|
221
221
|
}
|
|
222
222
|
else {
|
|
223
223
|
throw new Error(`Unknown item type for item '${itemId}'`);
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Utility functions for Spacer-related operations to avoid code duplication.
|
|
3
3
|
* @module client/utils/spacerUtils
|
|
4
4
|
*/
|
|
5
|
-
import type { GetSpaceItemsResponse } from '../../
|
|
5
|
+
import type { GetSpaceItemsResponse } from '../../models/SpaceDTO';
|
|
6
6
|
import type { DatalayerClient } from '../index';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { NotebookDTO } from '../../models/NotebookDTO';
|
|
8
|
+
import { LexicalDTO } from '../../models/LexicalDTO';
|
|
9
9
|
/**
|
|
10
10
|
* Convert raw space items from API response to model instances.
|
|
11
11
|
* This utility function is shared between Space.getItems() and SpacerMixin.getSpaceItems()
|
|
@@ -15,4 +15,4 @@ import { Lexical } from '../models/Lexical';
|
|
|
15
15
|
* @param sdk - SDK instance to pass to model constructors
|
|
16
16
|
* @returns Array of Notebook and Lexical model instances
|
|
17
17
|
*/
|
|
18
|
-
export declare function convertSpaceItemsToModels(items: GetSpaceItemsResponse['items'], sdk: DatalayerClient): (
|
|
18
|
+
export declare function convertSpaceItemsToModels(items: GetSpaceItemsResponse['items'], sdk: DatalayerClient): (NotebookDTO | LexicalDTO)[];
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { NotebookDTO } from '../../models/NotebookDTO';
|
|
6
|
+
import { LexicalDTO } from '../../models/LexicalDTO';
|
|
7
7
|
import { ItemTypes } from '../constants';
|
|
8
8
|
/**
|
|
9
9
|
* Convert raw space items from API response to model instances.
|
|
@@ -21,10 +21,10 @@ export function convertSpaceItemsToModels(items, sdk) {
|
|
|
21
21
|
const itemType = item.type_s;
|
|
22
22
|
// Only include notebooks and lexicals
|
|
23
23
|
if (itemType === ItemTypes.NOTEBOOK) {
|
|
24
|
-
modelItems.push(new
|
|
24
|
+
modelItems.push(new NotebookDTO(item, sdk));
|
|
25
25
|
}
|
|
26
26
|
else if (itemType === ItemTypes.LEXICAL) {
|
|
27
|
-
modelItems.push(new
|
|
27
|
+
modelItems.push(new LexicalDTO(item, sdk));
|
|
28
28
|
}
|
|
29
29
|
// Skip everything else (exercises, cells, etc.)
|
|
30
30
|
}
|
|
@@ -7,34 +7,26 @@ import { createElement, useCallback, useEffect, useState } from 'react';
|
|
|
7
7
|
import { Button, Flash, FormControl, Spinner, Text } from '@primer/react';
|
|
8
8
|
import { Box } from '@datalayer/primer-addons';
|
|
9
9
|
import { useCache } from '../../hooks';
|
|
10
|
-
import { useIAMStore } from '../../state';
|
|
11
10
|
/**
|
|
12
11
|
* Stripe checkout.
|
|
13
12
|
*/
|
|
14
13
|
export function StripeCheckout({ checkoutPortal, }) {
|
|
15
|
-
const {
|
|
16
|
-
const { createCheckoutSession, refreshStripePrices } = useCache();
|
|
14
|
+
const { useCreateCheckoutSession, useStripePrices } = useCache();
|
|
17
15
|
const [stripe, setStripe] = useState(null);
|
|
18
16
|
const [components, setComponents] = useState(null);
|
|
19
17
|
const [items, setItems] = useState(null);
|
|
20
18
|
const [product, setProduct] = useState(null);
|
|
21
19
|
const [checkout, setCheckout] = useState(false);
|
|
22
|
-
//
|
|
20
|
+
// Get Stripe prices using TanStack Query hook
|
|
21
|
+
const { data: pricesData } = useStripePrices();
|
|
22
|
+
// Update items when prices data changes
|
|
23
23
|
useEffect(() => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
setItems([]);
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
.catch(error => {
|
|
34
|
-
console.error('Failed to fetch product items.', error);
|
|
35
|
-
setItems([]);
|
|
36
|
-
});
|
|
37
|
-
}, []);
|
|
24
|
+
if (pricesData) {
|
|
25
|
+
setItems(pricesData);
|
|
26
|
+
}
|
|
27
|
+
}, [pricesData]);
|
|
28
|
+
// Get checkout session mutation
|
|
29
|
+
const checkoutSessionMutation = useCreateCheckoutSession();
|
|
38
30
|
// Load stripe components.
|
|
39
31
|
useEffect(() => {
|
|
40
32
|
import('@stripe/react-stripe-js').then(module => {
|
|
@@ -45,15 +37,19 @@ export function StripeCheckout({ checkoutPortal, }) {
|
|
|
45
37
|
useEffect(() => {
|
|
46
38
|
if (checkoutPortal?.metadata?.stripe_key) {
|
|
47
39
|
import('@stripe/stripe-js').then(module => {
|
|
48
|
-
setStripe(module.loadStripe(checkoutPortal.metadata
|
|
40
|
+
setStripe(module.loadStripe(checkoutPortal.metadata?.stripe_key ?? ''));
|
|
49
41
|
});
|
|
50
42
|
}
|
|
51
43
|
}, [checkoutPortal?.metadata?.stripe_key]);
|
|
52
|
-
const fetchClientSecret = useCallback(() => {
|
|
44
|
+
const fetchClientSecret = useCallback(async () => {
|
|
53
45
|
const location = document.location;
|
|
54
|
-
// Create a Checkout Session
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
// Create a Checkout Session using TanStack Query mutation
|
|
47
|
+
const result = await checkoutSessionMutation.mutateAsync({
|
|
48
|
+
product,
|
|
49
|
+
location,
|
|
50
|
+
});
|
|
51
|
+
return result;
|
|
52
|
+
}, [checkoutSessionMutation, product]);
|
|
57
53
|
const options = { fetchClientSecret };
|
|
58
54
|
let view = (_jsx(Box, { sx: { minHeight: '40px' }, children: _jsx(Spinner, {}) }));
|
|
59
55
|
if (checkout) {
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { useCallback, useEffect } from 'react';
|
|
7
7
|
import { Select } from '@primer/react';
|
|
8
8
|
import { useCache, useUser } from './../../hooks';
|
|
9
9
|
import { useLayoutStore } from '../../state';
|
|
@@ -11,25 +11,22 @@ const NO_ORGANIZATION_SELECTED_VALUE = 'NO_ORGANIZATION_SELECTED_VALUE';
|
|
|
11
11
|
export const OrganizationSelect = () => {
|
|
12
12
|
const user = useUser();
|
|
13
13
|
const { organization, updateLayoutOrganization, updateLayoutSpace } = useLayoutStore();
|
|
14
|
-
const {
|
|
15
|
-
const
|
|
16
|
-
const [
|
|
14
|
+
const { useRefreshUserOrganizations, useUserOrganizations } = useCache();
|
|
15
|
+
const { mutate: refreshUserOrganizationsMutate } = useRefreshUserOrganizations();
|
|
16
|
+
const { data: organizations = [] } = useUserOrganizations();
|
|
17
17
|
useEffect(() => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const onSelectionChange = useCallback((e) => {
|
|
25
|
-
const selectedOrganization = e.target.value;
|
|
18
|
+
if (user) {
|
|
19
|
+
refreshUserOrganizationsMutate();
|
|
20
|
+
}
|
|
21
|
+
}, [user, refreshUserOrganizationsMutate]);
|
|
22
|
+
const onSelectionChange = useCallback((event) => {
|
|
23
|
+
const selectedOrganization = event.target.value;
|
|
26
24
|
const org = selectedOrganization === NO_ORGANIZATION_SELECTED_VALUE
|
|
27
25
|
? undefined
|
|
28
26
|
: organizations[parseInt(selectedOrganization, 10)];
|
|
29
|
-
setSelection(org);
|
|
30
27
|
updateLayoutOrganization(org);
|
|
31
28
|
updateLayoutSpace(undefined);
|
|
32
|
-
}, [
|
|
33
|
-
return (_jsx(_Fragment, { children: _jsxs(Select, { block: true, width: "medium", onChange: onSelectionChange, children: [_jsx(Select.Option, { value: NO_ORGANIZATION_SELECTED_VALUE, selected: organization === undefined, children: "Please select an organization..." }), organizations.map((org, index) => (_jsx(Select.Option, { value: `${index}`, selected: org.id === organization?.id, children: org.name })))] }) }));
|
|
29
|
+
}, [organizations, updateLayoutOrganization, updateLayoutSpace]);
|
|
30
|
+
return (_jsx(_Fragment, { children: _jsxs(Select, { block: true, width: "medium", onChange: onSelectionChange, children: [_jsx(Select.Option, { value: NO_ORGANIZATION_SELECTED_VALUE, selected: organization === undefined, children: "Please select an organization..." }), organizations.map((org, index) => (_jsx(Select.Option, { value: `${index}`, selected: org.id === organization?.id, children: org.name }, org.id)))] }) }));
|
|
34
31
|
};
|
|
35
32
|
export default OrganizationSelect;
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { useCallback, useEffect } from 'react';
|
|
7
7
|
import { FormControl, Select } from '@primer/react';
|
|
8
8
|
import { Box } from '@datalayer/primer-addons';
|
|
9
9
|
import { useCache, useUser } from './../../hooks';
|
|
@@ -11,33 +11,32 @@ import { useLayoutStore } from '../../state';
|
|
|
11
11
|
export const SpaceSelect = () => {
|
|
12
12
|
const user = useUser();
|
|
13
13
|
const { organization, space, updateLayoutSpace } = useLayoutStore();
|
|
14
|
-
const {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
14
|
+
const { useRefreshUserSpaces, useUserSpaces, useRefreshOrganizationSpaces, useOrganizationSpaces, } = useCache();
|
|
15
|
+
const { mutate: refreshUserSpacesMutate } = useRefreshUserSpaces();
|
|
16
|
+
const { mutate: refreshOrganizationSpacesMutate } = useRefreshOrganizationSpaces();
|
|
17
|
+
const { data: organizationSpaces = [] } = useOrganizationSpaces(organization?.id ?? '');
|
|
18
|
+
const { data: userSpaces = [] } = useUserSpaces();
|
|
19
|
+
const spaces = organization ? organizationSpaces : userSpaces;
|
|
17
20
|
useEffect(() => {
|
|
18
|
-
if (organization) {
|
|
19
|
-
|
|
20
|
-
if (resp.success) {
|
|
21
|
-
setSpaces(getOrganizationSpaces(organization.id));
|
|
22
|
-
}
|
|
23
|
-
});
|
|
21
|
+
if (organization?.id) {
|
|
22
|
+
refreshOrganizationSpacesMutate(organization.id);
|
|
24
23
|
}
|
|
25
|
-
else {
|
|
26
|
-
|
|
27
|
-
if (resp.success) {
|
|
28
|
-
setSpaces(getUserSpaces());
|
|
29
|
-
}
|
|
30
|
-
});
|
|
24
|
+
else if (user) {
|
|
25
|
+
refreshUserSpacesMutate();
|
|
31
26
|
}
|
|
32
|
-
}, [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
}, [
|
|
28
|
+
organization?.id,
|
|
29
|
+
refreshOrganizationSpacesMutate,
|
|
30
|
+
refreshUserSpacesMutate,
|
|
31
|
+
user,
|
|
32
|
+
]);
|
|
33
|
+
const onSelectionChange = useCallback((event) => {
|
|
34
|
+
const selectedSpaceIndex = Number.parseInt(event.target.value, 10);
|
|
35
|
+
const selectedSpace = Number.isNaN(selectedSpaceIndex) || selectedSpaceIndex < 0
|
|
36
36
|
? undefined
|
|
37
|
-
: spaces[
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return (_jsx(_Fragment, { children: _jsx(Box, { as: "form", children: _jsxs(FormControl, { children: [_jsx(FormControl.Label, { children: "Select a space" }), _jsx(FormControl.Caption, { children: "This will go with you while you navigate" }), _jsx(Select, { block: true, width: "medium", onChange: onSelectionChange, placeholder: "Please select an space...", children: spaces.map((sp, index) => (_jsx(Select.Option, { value: `${index}`, selected: sp.id === space?.id, children: sp.name }))) })] }) }) }));
|
|
37
|
+
: spaces[selectedSpaceIndex];
|
|
38
|
+
updateLayoutSpace(selectedSpace);
|
|
39
|
+
}, [spaces, updateLayoutSpace]);
|
|
40
|
+
return (_jsx(_Fragment, { children: _jsx(Box, { as: "form", children: _jsxs(FormControl, { children: [_jsx(FormControl.Label, { children: "Select a space" }), _jsx(FormControl.Caption, { children: "This will go with you while you navigate" }), _jsx(Select, { block: true, width: "medium", onChange: onSelectionChange, placeholder: "Please select an space...", children: spaces.map((sp, index) => (_jsx(Select.Option, { value: `${index}`, selected: sp.id === space?.id, children: sp.name }, sp.id))) })] }) }) }));
|
|
42
41
|
};
|
|
43
42
|
export default SpaceSelect;
|
|
@@ -50,7 +50,7 @@ export function RuntimeLauncherDialog(props) {
|
|
|
50
50
|
const jupyterLabAdapter = jupyterReactStore.jupyterLabAdapter;
|
|
51
51
|
const [selection, setSelection] = useState((kernelSnapshot?.environment || environments[0]?.name) ?? '');
|
|
52
52
|
const [timeLimit, setTimeLimit] = useState(Math.min(credits?.available ?? 0, 10));
|
|
53
|
-
const [runtimeName, setRuntimeName] = useState(environments[0]?.
|
|
53
|
+
const [runtimeName, setRuntimeName] = useState(environments[0]?.runtime?.givenNameTemplate || environments[0]?.title || '');
|
|
54
54
|
// Whether the runtim name has been changed by the user or not
|
|
55
55
|
const [hasCustomRuntimeName, setHasCustomRuntimeName] = useState(false);
|
|
56
56
|
const [userStorage, setUserStorage] = useState(false);
|
|
@@ -75,7 +75,7 @@ export function RuntimeLauncherDialog(props) {
|
|
|
75
75
|
setSelection(selection);
|
|
76
76
|
if (!hasCustomRuntimeName) {
|
|
77
77
|
const spec = environments.find(env => env.name === selection);
|
|
78
|
-
setRuntimeName(spec?.
|
|
78
|
+
setRuntimeName(spec?.runtime?.givenNameTemplate || spec?.title || '');
|
|
79
79
|
}
|
|
80
80
|
}, [setSelection, hasCustomRuntimeName]);
|
|
81
81
|
const handleSubmitRuntime = useCallback(async () => {
|
|
@@ -61,7 +61,7 @@ export function RuntimePickerCell(props) {
|
|
|
61
61
|
}, [preference]);
|
|
62
62
|
const setSelectedRuntimeDesc = useCallback((kernel) => {
|
|
63
63
|
const datalayerMeta = model.getMetadata('datalayer') ?? {
|
|
64
|
-
|
|
64
|
+
runtime: undefined,
|
|
65
65
|
};
|
|
66
66
|
if (!kernel) {
|
|
67
67
|
delete datalayerMeta.kernel;
|
|
@@ -120,7 +120,7 @@ export function RuntimePickerNotebook(props) {
|
|
|
120
120
|
: undefined;
|
|
121
121
|
setValue(creditsLimit !== 0
|
|
122
122
|
? {
|
|
123
|
-
|
|
123
|
+
runtime: selectedRuntimeDesc
|
|
124
124
|
? {
|
|
125
125
|
environmentName: ['browser', 'remote'].includes(selectedRuntimeDesc.location)
|
|
126
126
|
? `${selectedRuntimeDesc.location}-${selectedRuntimeDesc.name}`
|
|
@@ -16,8 +16,10 @@ export const useAuthorization = () => {
|
|
|
16
16
|
};
|
|
17
17
|
// Account -------------------------------------------------------------------
|
|
18
18
|
const checkUserAccountPermissions = (user, accountHandle) => {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
// Note: user object from API has handle_s property, not handle
|
|
20
|
+
const userHandle = user.handle_s || user.handle;
|
|
21
|
+
if (userHandle !== accountHandle) {
|
|
22
|
+
goToApplicationStateError(`Permissions check failed for account handle: ${accountHandle} and user handle: ${userHandle}`);
|
|
21
23
|
}
|
|
22
24
|
};
|
|
23
25
|
// Platform -------------------------------------------------------------------
|