@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.
Files changed (85) hide show
  1. package/lib/api/DatalayerApi.js +17 -5
  2. package/lib/api/iam/authentication.d.ts +1 -1
  3. package/lib/api/iam/healthz.d.ts +1 -1
  4. package/lib/api/iam/index.d.ts +1 -1
  5. package/lib/api/iam/index.js +1 -1
  6. package/lib/api/iam/profile.d.ts +1 -1
  7. package/lib/api/iam/usage.d.ts +1 -39
  8. package/lib/api/index.d.ts +0 -1
  9. package/lib/api/index.js +0 -2
  10. package/lib/api/runtimes/environments.d.ts +2 -2
  11. package/lib/api/runtimes/healthz.d.ts +1 -1
  12. package/lib/api/runtimes/runtimes.d.ts +4 -4
  13. package/lib/api/runtimes/snapshots.d.ts +4 -4
  14. package/lib/api/spacer/documents.d.ts +1 -1
  15. package/lib/api/spacer/healthz.d.ts +1 -1
  16. package/lib/api/spacer/items.d.ts +1 -1
  17. package/lib/api/spacer/lexicals.d.ts +1 -1
  18. package/lib/api/spacer/notebooks.d.ts +1 -1
  19. package/lib/api/spacer/spaces.d.ts +1 -1
  20. package/lib/api/spacer/users.d.ts +1 -1
  21. package/lib/client/base.d.ts +2 -2
  22. package/lib/client/index.d.ts +44 -44
  23. package/lib/client/index.js +10 -10
  24. package/lib/client/mixins/IAMMixin.d.ts +7 -7
  25. package/lib/client/mixins/IAMMixin.js +5 -5
  26. package/lib/client/mixins/RuntimesMixin.d.ts +13 -13
  27. package/lib/client/mixins/RuntimesMixin.js +11 -11
  28. package/lib/client/mixins/SpacerMixin.d.ts +14 -14
  29. package/lib/client/mixins/SpacerMixin.js +12 -12
  30. package/lib/client/utils/spacerUtils.d.ts +4 -4
  31. package/lib/client/utils/spacerUtils.js +4 -4
  32. package/lib/components/checkout/StripeCheckout.js +19 -23
  33. package/lib/components/context/OrganizationSelect.js +12 -15
  34. package/lib/components/context/SpaceSelect.js +24 -25
  35. package/lib/components/runtimes/RuntimeLauncherDialog.js +2 -2
  36. package/lib/components/runtimes/RuntimePickerCell.js +1 -1
  37. package/lib/components/runtimes/RuntimePickerNotebook.js +1 -1
  38. package/lib/components/runtimes/RuntimeTransfer.d.ts +1 -1
  39. package/lib/hooks/useAuthorization.js +4 -2
  40. package/lib/hooks/useCache.d.ts +932 -285
  41. package/lib/hooks/useCache.js +5736 -2767
  42. package/lib/hooks/useCache0.d.ts +312 -0
  43. package/lib/hooks/useCache0.js +3189 -0
  44. package/lib/hooks/useIAM.js +18 -17
  45. package/lib/index.d.ts +1 -2
  46. package/lib/index.js +1 -2
  47. package/lib/{client/models/Credits.d.ts → models/CreditsDTO.d.ts} +38 -5
  48. package/lib/{client/models/Credits.js → models/CreditsDTO.js} +7 -2
  49. package/lib/models/Environment.d.ts +1 -1
  50. package/lib/{client/models/Environment.d.ts → models/EnvironmentDTO.d.ts} +55 -3
  51. package/lib/{client/models/Environment.js → models/EnvironmentDTO.js} +2 -2
  52. package/lib/{client/models → models}/HealthCheck.js +1 -1
  53. package/lib/{api/types/iam.d.ts → models/IAM.d.ts} +1 -87
  54. package/lib/{client/models/Item.d.ts → models/ItemDTO.d.ts} +6 -1
  55. package/lib/{client/models/Item.js → models/ItemDTO.js} +2 -7
  56. package/lib/{client/models/Lexical.d.ts → models/LexicalDTO.d.ts} +79 -7
  57. package/lib/{client/models/Lexical.js → models/LexicalDTO.js} +10 -5
  58. package/lib/{client/models/Notebook.d.ts → models/NotebookDTO.d.ts} +16 -7
  59. package/lib/{client/models/Notebook.js → models/NotebookDTO.js} +5 -5
  60. package/lib/models/Profile.d.ts +65 -0
  61. package/lib/models/Runtime.d.ts +49 -49
  62. package/lib/{client/models/Runtime.d.ts → models/RuntimeDTO.d.ts} +74 -5
  63. package/lib/{client/models/Runtime.js → models/RuntimeDTO.js} +5 -5
  64. package/lib/{client/models/Snapshot.d.ts → models/RuntimeSnapshotDTO.d.ts} +89 -8
  65. package/lib/{client/models/Snapshot.js → models/RuntimeSnapshotDTO.js} +4 -4
  66. package/lib/models/SpaceDTO.d.ts +280 -0
  67. package/lib/{client/models/Space.js → models/SpaceDTO.js} +17 -12
  68. package/lib/{client/models/User.d.ts → models/UserDTO.d.ts} +25 -3
  69. package/lib/{client/models/User.js → models/UserDTO.js} +3 -2
  70. package/lib/models/index.d.ts +45 -4
  71. package/lib/models/index.js +45 -4
  72. package/package.json +2 -1
  73. package/lib/api/types/index.d.ts +0 -34
  74. package/lib/api/types/index.js +0 -38
  75. package/lib/api/types/runtimes.d.ts +0 -205
  76. package/lib/api/types/runtimes.js +0 -5
  77. package/lib/api/types/spacer.d.ts +0 -243
  78. package/lib/api/types/spacer.js +0 -5
  79. package/lib/client/models/Space.d.ts +0 -135
  80. package/lib/client/models/index.d.ts +0 -26
  81. package/lib/client/models/index.js +0 -25
  82. /package/lib/{api/types/common.d.ts → models/Common.d.ts} +0 -0
  83. /package/lib/{api/types/common.js → models/Common.js} +0 -0
  84. /package/lib/{client/models → models}/HealthCheck.d.ts +0 -0
  85. /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 { Environment } from '../models/Environment';
13
- import { Runtime } from '../models/Runtime';
14
- import { Snapshot } from '../models/Snapshot';
15
- import { HealthCheck } from '../models/HealthCheck';
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 Environment(env, this));
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 Runtime(response.runtime, this);
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 Runtime(r, this));
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 Runtime(runtimeData, this);
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 Snapshot(response.snapshot, this);
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 Snapshot(s, this));
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 Snapshot(response.snapshot, this);
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 { Notebook } from '../models/Notebook';
3
- import { Lexical } from '../models/Lexical';
4
- import { Space } from '../models/Space';
5
- import { HealthCheck } from '../models/HealthCheck';
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<Space[]>;
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<Space>;
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<Notebook>;
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<Notebook>;
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<Notebook>;
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<Lexical>;
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<Lexical>;
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<Lexical>;
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<(Notebook | Lexical)[]>;
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<Notebook | Lexical>;
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 { Notebook } from '../models/Notebook';
16
- import { Lexical } from '../models/Lexical';
17
- import { Space } from '../models/Space';
18
- import { HealthCheck } from '../models/HealthCheck';
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 Space(s, this));
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 Space(response.space, this);
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 Notebook(response.notebook, this);
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 Notebook(response.notebook, this);
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 Lexical(response.document, this);
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 Lexical(response.document, this);
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 Notebook(item, this);
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 Lexical(item, this);
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 '../../api/types/spacer';
5
+ import type { GetSpaceItemsResponse } from '../../models/SpaceDTO';
6
6
  import type { DatalayerClient } from '../index';
7
- import { Notebook } from '../models/Notebook';
8
- import { Lexical } from '../models/Lexical';
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): (Notebook | Lexical)[];
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 { Notebook } from '../models/Notebook';
6
- import { Lexical } from '../models/Lexical';
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 Notebook(item, sdk));
24
+ modelItems.push(new NotebookDTO(item, sdk));
25
25
  }
26
26
  else if (itemType === ItemTypes.LEXICAL) {
27
- modelItems.push(new Lexical(item, sdk));
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 { iamRunUrl } = useIAMStore();
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
- // Refresh Stripe items.
20
+ // Get Stripe prices using TanStack Query hook
21
+ const { data: pricesData } = useStripePrices();
22
+ // Update items when prices data changes
23
23
  useEffect(() => {
24
- refreshStripePrices()
25
- .then(response => {
26
- if (response.success) {
27
- setItems(response.prices);
28
- }
29
- else {
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.stripe_key));
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
- return createCheckoutSession(product, location);
56
- }, [iamRunUrl, location, product?.id]);
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 { useState, useEffect, useCallback } from 'react';
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 { refreshUserOrganizations, getUserOrganizations } = useCache();
15
- const [organizations, setOrganizations] = useState(getUserOrganizations());
16
- const [_, setSelection] = useState(organization);
14
+ const { useRefreshUserOrganizations, useUserOrganizations } = useCache();
15
+ const { mutate: refreshUserOrganizationsMutate } = useRefreshUserOrganizations();
16
+ const { data: organizations = [] } = useUserOrganizations();
17
17
  useEffect(() => {
18
- refreshUserOrganizations(user).then(resp => {
19
- if (resp.success) {
20
- setOrganizations(getUserOrganizations());
21
- }
22
- });
23
- }, [user]);
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
- }, [setSelection, organizations]);
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 { useState, useEffect, useCallback } from 'react';
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 { refreshUserSpaces, getUserSpaces, refreshOrganizationSpaces, getOrganizationSpaces, } = useCache();
15
- const [spaces, setSpaces] = useState([]);
16
- const [_, setSelection] = useState(space);
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
- refreshOrganizationSpaces(organization.id).then(resp => {
20
- if (resp.success) {
21
- setSpaces(getOrganizationSpaces(organization.id));
22
- }
23
- });
21
+ if (organization?.id) {
22
+ refreshOrganizationSpacesMutate(organization.id);
24
23
  }
25
- else {
26
- refreshUserSpaces().then(resp => {
27
- if (resp.success) {
28
- setSpaces(getUserSpaces());
29
- }
30
- });
24
+ else if (user) {
25
+ refreshUserSpacesMutate();
31
26
  }
32
- }, [user, organization]);
33
- const onSelectionChange = useCallback((e) => {
34
- const selectedSpace = e.target.value;
35
- const org = selectedSpace === undefined
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[parseInt(selectedSpace, 10)];
38
- setSelection(org);
39
- updateLayoutSpace(org);
40
- }, [setSelection, spaces]);
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]?.kernel?.givenNameTemplate || environments[0]?.title || '');
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?.kernel?.givenNameTemplate || spec?.title || '');
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
- kernel: undefined,
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
- kernel: selectedRuntimeDesc
123
+ runtime: selectedRuntimeDesc
124
124
  ? {
125
125
  environmentName: ['browser', 'remote'].includes(selectedRuntimeDesc.location)
126
126
  ? `${selectedRuntimeDesc.location}-${selectedRuntimeDesc.name}`
@@ -3,7 +3,7 @@ export interface RuntimeTransfer {
3
3
  /**
4
4
  * Selected Kernel.
5
5
  */
6
- kernel: Partial<Omit<IRuntimeOptions, 'kernelType'> & {
6
+ runtime: Partial<Omit<IRuntimeOptions, 'kernelType'> & {
7
7
  id: string;
8
8
  }> | null;
9
9
  /**
@@ -16,8 +16,10 @@ export const useAuthorization = () => {
16
16
  };
17
17
  // Account -------------------------------------------------------------------
18
18
  const checkUserAccountPermissions = (user, accountHandle) => {
19
- if (user.handle !== accountHandle) {
20
- goToApplicationStateError(`Permissions check failed for account handle: ${accountHandle} and user: ${user}`);
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 -------------------------------------------------------------------