@datalayer/core 0.0.14 → 0.0.16

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.
@@ -14,7 +14,9 @@ export const useIAM = (props = { user: undefined, token: undefined }) => {
14
14
  const layoutStore = useLayoutStore();
15
15
  const organizationStore = useOrganizationStore();
16
16
  const spaceStore = useSpaceStore();
17
- const { clearAllCaches, whoami } = useCache();
17
+ const { useWhoami, useLogout } = useCache();
18
+ const { data: whoamiData } = useWhoami();
19
+ const logoutMutation = useLogout();
18
20
  const loginAndNavigate = async (token, logout, refresh, navigate, homeRoute) => {
19
21
  try {
20
22
  const resp = await requestDatalayerAPI({
@@ -60,27 +62,26 @@ export const useIAM = (props = { user: undefined, token: undefined }) => {
60
62
  layoutStore.reset();
61
63
  organizationStore.updateOrganizations([]);
62
64
  spaceStore.updateSpaces([]);
63
- clearAllCaches();
65
+ // Call TanStack Query logout mutation which will clear all caches
66
+ logoutMutation.mutate();
64
67
  setIAMState({ user: ANONYMOUS_USER, token: ANONYMOUS_USER_TOKEN });
65
68
  };
66
69
  useEffect(() => {
67
- if (token) {
68
- whoami().then(resp => {
69
- if (resp.success) {
70
- const user = asUser(resp.profile);
71
- setIAMState({ user, token });
72
- iamStore.setLogin(user, token);
73
- // TODO centralize user settings management.
74
- const aiagentsRunUrl = user.settings?.aiAgentsUrl;
75
- if (aiagentsRunUrl) {
76
- coreStore.getState().setConfiguration({
77
- aiagentsRunUrl,
78
- });
79
- }
70
+ if (token && whoamiData) {
71
+ if (whoamiData.success) {
72
+ const user = asUser(whoamiData.profile);
73
+ setIAMState({ user, token });
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
+ });
80
81
  }
81
- });
82
+ }
82
83
  }
83
- }, []);
84
+ }, [token, whoamiData, iamStore]);
84
85
  return {
85
86
  user: iamState.user,
86
87
  token: iamState.token,
@@ -21,6 +21,55 @@ export type IRuntimeLocation = 'browser' | 'local' | string;
21
21
  */
22
22
  export interface IRuntimeModel extends IRuntimePod, Kernel.IModel {
23
23
  }
24
+ /**
25
+ * Runtime pod.
26
+ */
27
+ export interface IRuntimePod {
28
+ /**
29
+ * Environment display name
30
+ */
31
+ environment_title: string;
32
+ /**
33
+ * Environment name
34
+ */
35
+ environment_name: string;
36
+ /**
37
+ * Runtime name
38
+ */
39
+ pod_name: string;
40
+ /**
41
+ * Runtime ingress URL
42
+ */
43
+ ingress: string;
44
+ /**
45
+ * Runtime user given name
46
+ */
47
+ given_name: string;
48
+ /**
49
+ * Runtime type
50
+ */
51
+ type: IRuntimeType;
52
+ /**
53
+ * Server authentication token
54
+ */
55
+ token: string;
56
+ /**
57
+ * Credits burning rate per second
58
+ */
59
+ burning_rate: number;
60
+ /**
61
+ * Kernel reservation ID
62
+ */
63
+ reservation_id?: string;
64
+ /**
65
+ * Runtime usage starting timestamp
66
+ */
67
+ started_at: string;
68
+ /**
69
+ * Runtime credits reservation expiration timestamp
70
+ */
71
+ expired_at?: string;
72
+ }
24
73
  /**
25
74
  * Runtime description.
26
75
  */
@@ -72,52 +121,3 @@ export type IRuntimeType = 'notebook' | 'cell';
72
121
  * Runtime optional capabilities.
73
122
  */
74
123
  export type IRuntimeCapabilities = 'user_storage';
75
- /**
76
- * Runtime pod.
77
- */
78
- export interface IRuntimePod {
79
- /**
80
- * Environment display name
81
- */
82
- environment_title: string;
83
- /**
84
- * Environment name
85
- */
86
- environment_name: string;
87
- /**
88
- * Runtime name
89
- */
90
- pod_name: string;
91
- /**
92
- * Runtime ingress URL
93
- */
94
- ingress: string;
95
- /**
96
- * Runtime user given name
97
- */
98
- given_name: string;
99
- /**
100
- * Runtime type
101
- */
102
- type: IRuntimeType;
103
- /**
104
- * Server authentication token
105
- */
106
- token: string;
107
- /**
108
- * Credits burning rate per second
109
- */
110
- burning_rate: number;
111
- /**
112
- * Kernel reservation ID
113
- */
114
- reservation_id?: string;
115
- /**
116
- * Runtime usage starting timestamp
117
- */
118
- started_at: string;
119
- /**
120
- * Runtime credits reservation expiration timestamp
121
- */
122
- expired_at?: string;
123
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/core",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "type": "module",
5
5
  "workspaces": [
6
6
  ".",
@@ -1,27 +0,0 @@
1
- /**
2
- * Main SDK entry point for the Datalayer platform.
3
- *
4
- * This module provides the unified DatalayerSDK class with a flat, intuitive API
5
- * for all Datalayer platform services. The SDK uses TypeScript mixins to provide
6
- * excellent discoverability and ease of use.
7
- *
8
- * @example
9
- * ```typescript
10
- * import { DatalayerSDK } from '@datalayer/core/sdk';
11
- *
12
- * const sdk = new DatalayerSDK({
13
- * token: 'your-api-token',
14
- * baseUrl: 'https://prod1.datalayer.run'
15
- * });
16
- *
17
- * // Flat, intuitive API - all methods directly accessible
18
- * const user = await sdk.whoami();
19
- * const environments = await sdk.listEnvironments();
20
- * const runtime = await sdk.createRuntime(config);
21
- * const notebook = await sdk.createNotebook(data);
22
- * ```
23
- *
24
- * @module sdk
25
- */
26
- export { DatalayerClient, type DatalayerClientConfig } from '../client';
27
- export * from '../stateful';
package/lib/sdk/index.js DELETED
@@ -1,33 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- /**
6
- * Main SDK entry point for the Datalayer platform.
7
- *
8
- * This module provides the unified DatalayerSDK class with a flat, intuitive API
9
- * for all Datalayer platform services. The SDK uses TypeScript mixins to provide
10
- * excellent discoverability and ease of use.
11
- *
12
- * @example
13
- * ```typescript
14
- * import { DatalayerSDK } from '@datalayer/core/sdk';
15
- *
16
- * const sdk = new DatalayerSDK({
17
- * token: 'your-api-token',
18
- * baseUrl: 'https://prod1.datalayer.run'
19
- * });
20
- *
21
- * // Flat, intuitive API - all methods directly accessible
22
- * const user = await sdk.whoami();
23
- * const environments = await sdk.listEnvironments();
24
- * const runtime = await sdk.createRuntime(config);
25
- * const notebook = await sdk.createNotebook(data);
26
- * ```
27
- *
28
- * @module sdk
29
- */
30
- // Export the main Client class with flat API
31
- export { DatalayerClient } from '../client';
32
- // Export stateful modules for advanced use cases
33
- export * from '../stateful';