@datalayer/core 0.0.12 → 0.0.13

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 (237) hide show
  1. package/README.md +2 -2
  2. package/lib/api/DatalayerApi.d.ts +38 -26
  3. package/lib/api/DatalayerApi.js +35 -8
  4. package/lib/api/iam/authentication.d.ts +8 -7
  5. package/lib/api/iam/authentication.js +14 -15
  6. package/lib/api/iam/healthz.d.ts +3 -2
  7. package/lib/api/iam/healthz.js +5 -3
  8. package/lib/api/iam/index.d.ts +9 -4
  9. package/lib/api/iam/index.js +9 -4
  10. package/lib/api/iam/oauth2.d.ts +115 -0
  11. package/lib/api/iam/oauth2.js +309 -0
  12. package/lib/api/iam/profile.d.ts +8 -1
  13. package/lib/api/iam/profile.js +17 -2
  14. package/lib/api/iam/usage.d.ts +56 -0
  15. package/lib/api/iam/usage.js +39 -0
  16. package/lib/api/index.d.ts +6 -5
  17. package/lib/api/index.js +6 -5
  18. package/lib/api/runtimes/environments.js +3 -2
  19. package/lib/api/runtimes/healthz.d.ts +3 -13
  20. package/lib/api/runtimes/healthz.js +4 -3
  21. package/lib/api/runtimes/index.d.ts +3 -2
  22. package/lib/api/runtimes/index.js +3 -2
  23. package/lib/api/runtimes/runtimes.js +17 -6
  24. package/lib/api/runtimes/snapshots.js +3 -2
  25. package/lib/api/spacer/documents.d.ts +12 -0
  26. package/lib/api/spacer/documents.js +43 -0
  27. package/lib/api/spacer/healthz.d.ts +3 -13
  28. package/lib/api/spacer/healthz.js +4 -3
  29. package/lib/api/spacer/index.d.ts +4 -2
  30. package/lib/api/spacer/index.js +4 -2
  31. package/lib/api/spacer/items.d.ts +9 -1
  32. package/lib/api/spacer/items.js +17 -2
  33. package/lib/api/spacer/lexicals.js +3 -2
  34. package/lib/api/spacer/notebooks.js +3 -2
  35. package/lib/api/spacer/spaces.js +3 -2
  36. package/lib/api/spacer/users.js +3 -2
  37. package/lib/api/types/common.d.ts +64 -0
  38. package/lib/api/types/iam.d.ts +88 -65
  39. package/lib/api/types/index.d.ts +4 -2
  40. package/lib/api/types/index.js +4 -2
  41. package/lib/api/types/runtimes.d.ts +9 -39
  42. package/lib/api/types/spacer.d.ts +37 -65
  43. package/lib/api/utils/validation.d.ts +24 -1
  44. package/lib/api/utils/validation.js +62 -1
  45. package/lib/client/base.d.ts +75 -0
  46. package/lib/client/base.js +199 -0
  47. package/lib/client/constants.d.ts +22 -0
  48. package/lib/client/constants.js +22 -0
  49. package/lib/client/index.d.ts +108 -0
  50. package/lib/client/index.js +79 -0
  51. package/lib/client/mixins/IAMMixin.d.ts +54 -0
  52. package/lib/client/mixins/IAMMixin.js +181 -0
  53. package/lib/client/mixins/RuntimesMixin.d.ts +93 -0
  54. package/lib/client/mixins/RuntimesMixin.js +229 -0
  55. package/lib/client/mixins/SpacerMixin.d.ts +111 -0
  56. package/lib/client/mixins/SpacerMixin.js +340 -0
  57. package/lib/client/models/Credits.d.ts +91 -0
  58. package/lib/client/models/Credits.js +130 -0
  59. package/lib/client/models/Environment.d.ts +73 -0
  60. package/lib/client/models/Environment.js +88 -0
  61. package/lib/client/models/HealthCheck.d.ts +72 -0
  62. package/lib/client/models/HealthCheck.js +107 -0
  63. package/lib/client/models/Item.d.ts +69 -0
  64. package/lib/client/models/Item.js +191 -0
  65. package/lib/client/models/Lexical.d.ts +83 -0
  66. package/lib/client/models/Lexical.js +152 -0
  67. package/lib/client/models/Notebook.d.ts +87 -0
  68. package/lib/client/models/Notebook.js +153 -0
  69. package/lib/client/models/Runtime.d.ts +122 -0
  70. package/lib/client/models/Runtime.js +204 -0
  71. package/lib/client/models/Snapshot.d.ts +92 -0
  72. package/lib/client/models/Snapshot.js +139 -0
  73. package/lib/client/models/Space.d.ts +135 -0
  74. package/lib/client/models/Space.js +234 -0
  75. package/lib/client/models/User.d.ts +64 -0
  76. package/lib/client/models/User.js +83 -0
  77. package/lib/client/models/index.d.ts +26 -0
  78. package/lib/client/models/index.js +25 -0
  79. package/lib/client/utils/mixins.d.ts +12 -0
  80. package/lib/{sdk/client → client}/utils/mixins.js +0 -28
  81. package/lib/client/utils/spacerUtils.d.ts +18 -0
  82. package/lib/client/utils/spacerUtils.js +32 -0
  83. package/lib/collaboration/DatalayerCollaboration.d.ts +6 -1
  84. package/lib/collaboration/DatalayerCollaboration.js +2 -2
  85. package/lib/collaboration/DatalayerCollaborationProvider.d.ts +5 -0
  86. package/lib/collaboration/DatalayerCollaborationProvider.js +10 -9
  87. package/lib/components/progress/CreditsIndicator.d.ts +1 -1
  88. package/lib/components/runtimes/RuntimeCellVariablesDialog.js +1 -1
  89. package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +1 -1
  90. package/lib/components/runtimes/RuntimePickerBase.d.ts +1 -1
  91. package/lib/components/runtimes/RuntimePickerBase.js +1 -1
  92. package/lib/components/runtimes/RuntimePickerCell.js +2 -2
  93. package/lib/components/runtimes/RuntimePickerNotebook.d.ts +1 -1
  94. package/lib/components/runtimes/RuntimePickerNotebook.js +1 -1
  95. package/lib/components/runtimes/RuntimeTransfer.d.ts +1 -1
  96. package/lib/components/runtimes/RuntimeUtils.d.ts +1 -1
  97. package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -1
  98. package/lib/components/snapshots/RuntimeSnapshotMenu.js +27 -20
  99. package/lib/config/Configuration.d.ts +8 -0
  100. package/lib/hooks/useDatalayer.js +1 -1
  101. package/lib/hooks/useRuntimes.js +1 -1
  102. package/lib/hooks/useToast.js +1 -1
  103. package/lib/index.d.ts +2 -2
  104. package/lib/index.js +4 -2
  105. package/lib/sdk/index.d.ts +5 -4
  106. package/lib/sdk/index.js +6 -5
  107. package/lib/services/DatalayerServiceManager.js +1 -1
  108. package/lib/state/substates/CoreState.js +2 -0
  109. package/lib/state/substates/RuntimesState.d.ts +1 -1
  110. package/lib/state/substates/RuntimesState.js +1 -1
  111. package/lib/{sdk/stateful → stateful}/index.d.ts +1 -1
  112. package/lib/{sdk/stateful → stateful}/index.js +1 -1
  113. package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.d.ts +1 -41
  114. package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.js +1 -20
  115. package/lib/{sdk/stateful → stateful}/runtimes/actions.d.ts +3 -3
  116. package/lib/{sdk/stateful → stateful}/runtimes/actions.js +8 -8
  117. package/lib/{sdk/stateful → stateful}/runtimes/apis.d.ts +8 -8
  118. package/lib/stateful/runtimes/apis.js +5 -0
  119. package/package.json +12 -10
  120. package/lib/__tests__/hooks.test.d.ts +0 -1
  121. package/lib/__tests__/hooks.test.js +0 -19
  122. package/lib/__tests__/index.test.d.ts +0 -1
  123. package/lib/__tests__/index.test.js +0 -27
  124. package/lib/__tests__/integration.test.d.ts +0 -1
  125. package/lib/__tests__/integration.test.js +0 -57
  126. package/lib/__tests__/shared/cleanup-shared.d.ts +0 -4
  127. package/lib/__tests__/shared/cleanup-shared.js +0 -228
  128. package/lib/__tests__/shared/test-config.d.ts +0 -51
  129. package/lib/__tests__/shared/test-config.js +0 -110
  130. package/lib/__tests__/shared/test-constants.d.ts +0 -66
  131. package/lib/__tests__/shared/test-constants.js +0 -79
  132. package/lib/__tests__/utils.test.d.ts +0 -1
  133. package/lib/__tests__/utils.test.js +0 -59
  134. package/lib/api/__tests__/iam.authentication.integration.test.d.ts +0 -1
  135. package/lib/api/__tests__/iam.authentication.integration.test.js +0 -247
  136. package/lib/api/__tests__/iam.healthz.integration.test.d.ts +0 -1
  137. package/lib/api/__tests__/iam.healthz.integration.test.js +0 -63
  138. package/lib/api/__tests__/iam.profile.integration.test.d.ts +0 -1
  139. package/lib/api/__tests__/iam.profile.integration.test.js +0 -252
  140. package/lib/api/__tests__/runtimes.environments.integration.test.d.ts +0 -1
  141. package/lib/api/__tests__/runtimes.environments.integration.test.js +0 -122
  142. package/lib/api/__tests__/runtimes.healthz.integration.test.d.ts +0 -1
  143. package/lib/api/__tests__/runtimes.healthz.integration.test.js +0 -50
  144. package/lib/api/__tests__/runtimes.integration.test.d.ts +0 -1
  145. package/lib/api/__tests__/runtimes.integration.test.js +0 -369
  146. package/lib/api/__tests__/spacer.healthz.integration.test.d.ts +0 -1
  147. package/lib/api/__tests__/spacer.healthz.integration.test.js +0 -50
  148. package/lib/api/__tests__/spacer.integration.test.d.ts +0 -1
  149. package/lib/api/__tests__/spacer.integration.test.js +0 -519
  150. package/lib/api/iam/__tests__/authentication.unit.test.d.ts +0 -1
  151. package/lib/api/iam/__tests__/authentication.unit.test.js +0 -63
  152. package/lib/api/iam/__tests__/healthz.unit.test.d.ts +0 -1
  153. package/lib/api/iam/__tests__/healthz.unit.test.js +0 -60
  154. package/lib/api/iam/__tests__/profile.unit.test.d.ts +0 -1
  155. package/lib/api/iam/__tests__/profile.unit.test.js +0 -57
  156. package/lib/api/runtimes/__tests__/environments.unit.test.d.ts +0 -1
  157. package/lib/api/runtimes/__tests__/environments.unit.test.js +0 -77
  158. package/lib/api/runtimes/__tests__/healthz.unit.test.d.ts +0 -1
  159. package/lib/api/runtimes/__tests__/healthz.unit.test.js +0 -57
  160. package/lib/api/runtimes/__tests__/runtimes.unit.test.d.ts +0 -1
  161. package/lib/api/runtimes/__tests__/runtimes.unit.test.js +0 -139
  162. package/lib/api/runtimes/__tests__/snapshots.unit.test.d.ts +0 -1
  163. package/lib/api/runtimes/__tests__/snapshots.unit.test.js +0 -96
  164. package/lib/api/spacer/__tests__/healthz.unit.test.d.ts +0 -1
  165. package/lib/api/spacer/__tests__/healthz.unit.test.js +0 -57
  166. package/lib/api/spacer/__tests__/items.unit.test.d.ts +0 -1
  167. package/lib/api/spacer/__tests__/items.unit.test.js +0 -165
  168. package/lib/api/spacer/__tests__/lexicals.unit.test.d.ts +0 -1
  169. package/lib/api/spacer/__tests__/lexicals.unit.test.js +0 -323
  170. package/lib/api/spacer/__tests__/notebooks.unit.test.d.ts +0 -1
  171. package/lib/api/spacer/__tests__/notebooks.unit.test.js +0 -224
  172. package/lib/api/spacer/__tests__/users.unit.test.d.ts +0 -1
  173. package/lib/api/spacer/__tests__/users.unit.test.js +0 -132
  174. package/lib/api/utils/__tests__/validation.test.d.ts +0 -1
  175. package/lib/api/utils/__tests__/validation.test.js +0 -109
  176. package/lib/sdk/client/__tests__/sdk.health.integration.test.d.ts +0 -1
  177. package/lib/sdk/client/__tests__/sdk.health.integration.test.js +0 -110
  178. package/lib/sdk/client/__tests__/sdk.iam.integration.test.d.ts +0 -1
  179. package/lib/sdk/client/__tests__/sdk.iam.integration.test.js +0 -179
  180. package/lib/sdk/client/__tests__/sdk.models.integration.test.d.ts +0 -1
  181. package/lib/sdk/client/__tests__/sdk.models.integration.test.js +0 -376
  182. package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.d.ts +0 -1
  183. package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.js +0 -276
  184. package/lib/sdk/client/__tests__/sdk.spacer.integration.test.d.ts +0 -1
  185. package/lib/sdk/client/__tests__/sdk.spacer.integration.test.js +0 -361
  186. package/lib/sdk/client/base.d.ts +0 -88
  187. package/lib/sdk/client/base.js +0 -112
  188. package/lib/sdk/client/index.d.ts +0 -192
  189. package/lib/sdk/client/index.js +0 -128
  190. package/lib/sdk/client/mixins/HealthMixin.d.ts +0 -100
  191. package/lib/sdk/client/mixins/HealthMixin.js +0 -133
  192. package/lib/sdk/client/mixins/IAMMixin.d.ts +0 -59
  193. package/lib/sdk/client/mixins/IAMMixin.js +0 -83
  194. package/lib/sdk/client/mixins/RuntimesMixin.d.ts +0 -134
  195. package/lib/sdk/client/mixins/RuntimesMixin.js +0 -221
  196. package/lib/sdk/client/mixins/SpacerMixin.d.ts +0 -184
  197. package/lib/sdk/client/mixins/SpacerMixin.js +0 -278
  198. package/lib/sdk/client/models/Lexical.d.ts +0 -156
  199. package/lib/sdk/client/models/Lexical.js +0 -275
  200. package/lib/sdk/client/models/Notebook.d.ts +0 -174
  201. package/lib/sdk/client/models/Notebook.js +0 -311
  202. package/lib/sdk/client/models/Runtime.d.ts +0 -221
  203. package/lib/sdk/client/models/Runtime.js +0 -341
  204. package/lib/sdk/client/models/Snapshot.d.ts +0 -156
  205. package/lib/sdk/client/models/Snapshot.js +0 -244
  206. package/lib/sdk/client/models/Space.d.ts +0 -182
  207. package/lib/sdk/client/models/Space.js +0 -276
  208. package/lib/sdk/client/models/__tests__/Lexical.test.d.ts +0 -1
  209. package/lib/sdk/client/models/__tests__/Lexical.test.js +0 -288
  210. package/lib/sdk/client/models/__tests__/Notebook.test.d.ts +0 -1
  211. package/lib/sdk/client/models/__tests__/Notebook.test.js +0 -206
  212. package/lib/sdk/client/models/__tests__/Runtime.test.d.ts +0 -1
  213. package/lib/sdk/client/models/__tests__/Runtime.test.js +0 -133
  214. package/lib/sdk/client/models/__tests__/Snapshot.test.d.ts +0 -1
  215. package/lib/sdk/client/models/__tests__/Snapshot.test.js +0 -244
  216. package/lib/sdk/client/models/__tests__/Space.test.d.ts +0 -1
  217. package/lib/sdk/client/models/__tests__/Space.test.js +0 -334
  218. package/lib/sdk/client/models/index.d.ts +0 -30
  219. package/lib/sdk/client/models/index.js +0 -30
  220. package/lib/sdk/client/utils/mixins.d.ts +0 -42
  221. /package/lib/{sdk/stateful/runtimes/apis.js → api/types/common.js} +0 -0
  222. /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.d.ts +0 -0
  223. /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.js +0 -0
  224. /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.d.ts +0 -0
  225. /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.js +0 -0
  226. /package/lib/{sdk/stateful → stateful}/jupyter/index.d.ts +0 -0
  227. /package/lib/{sdk/stateful → stateful}/jupyter/index.js +0 -0
  228. /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.d.ts +0 -0
  229. /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.js +0 -0
  230. /package/lib/{sdk/stateful → stateful}/runtimes/index.d.ts +0 -0
  231. /package/lib/{sdk/stateful → stateful}/runtimes/index.js +0 -0
  232. /package/lib/{sdk/stateful → stateful}/runtimes/settings.d.ts +0 -0
  233. /package/lib/{sdk/stateful → stateful}/runtimes/settings.js +0 -0
  234. /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.d.ts +0 -0
  235. /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.js +0 -0
  236. /package/lib/{sdk/stateful → stateful}/runtimes/utils.d.ts +0 -0
  237. /package/lib/{sdk/stateful → stateful}/runtimes/utils.js +0 -0
@@ -1,133 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- /**
6
- * @module sdk/client/mixins/HealthMixin
7
- * @description Health check functionality for the Datalayer SDK.
8
- *
9
- * Provides methods to check the health status of all Datalayer services.
10
- */
11
- import { iam, runtimes, spacer } from '../../../api';
12
- /**
13
- * Mixin that provides health check functionality for the SDK.
14
- */
15
- export function HealthMixin(Base) {
16
- return class extends Base {
17
- /**
18
- * Check if the IAM service is healthy.
19
- *
20
- * @returns True if service is healthy, false otherwise
21
- */
22
- async isIAMHealthy() {
23
- try {
24
- await iam.healthz.ping(this.iamRunUrl);
25
- return true;
26
- }
27
- catch {
28
- return false;
29
- }
30
- }
31
- /**
32
- * Check if the Runtimes service is healthy.
33
- *
34
- * @returns True if service is healthy, false otherwise
35
- */
36
- async isRuntimesHealthy() {
37
- try {
38
- await runtimes.healthz.ping(this.runtimesRunUrl);
39
- return true;
40
- }
41
- catch {
42
- return false;
43
- }
44
- }
45
- /**
46
- * Check if the Spacer service is healthy.
47
- *
48
- * @returns True if service is healthy, false otherwise
49
- */
50
- async isSpacerHealthy() {
51
- try {
52
- await spacer.healthz.ping(this.spacerRunUrl);
53
- return true;
54
- }
55
- catch {
56
- return false;
57
- }
58
- }
59
- /**
60
- * Check if all Datalayer services are healthy.
61
- *
62
- * @returns True if all services are healthy, false otherwise
63
- */
64
- async areAllServicesHealthy() {
65
- const [iamHealthy, runtimesHealthy, spacerHealthy] = await Promise.all([
66
- this.isIAMHealthy(),
67
- this.isRuntimesHealthy(),
68
- this.isSpacerHealthy(),
69
- ]);
70
- return iamHealthy && runtimesHealthy && spacerHealthy;
71
- }
72
- /**
73
- * Get detailed health status for all services.
74
- *
75
- * @returns Object containing health status and details for each service
76
- */
77
- async getHealthStatus() {
78
- const [iamStatus, runtimesStatus, spacerStatus] = await Promise.allSettled([
79
- iam.healthz.ping(this.iamRunUrl),
80
- runtimes.healthz.ping(this.runtimesRunUrl),
81
- spacer.healthz.ping(this.spacerRunUrl),
82
- ]);
83
- const result = {
84
- iam: {
85
- healthy: false,
86
- details: undefined,
87
- error: undefined,
88
- },
89
- runtimes: {
90
- healthy: false,
91
- details: undefined,
92
- error: undefined,
93
- },
94
- spacer: {
95
- healthy: false,
96
- details: undefined,
97
- error: undefined,
98
- },
99
- };
100
- // Process IAM status
101
- if (iamStatus.status === 'fulfilled') {
102
- result.iam.healthy = true;
103
- result.iam.details = iamStatus.value;
104
- }
105
- else {
106
- result.iam.error = iamStatus.reason?.message || 'Unknown error';
107
- }
108
- // Process Runtimes status
109
- if (runtimesStatus.status === 'fulfilled') {
110
- result.runtimes.healthy = true;
111
- result.runtimes.details = runtimesStatus.value;
112
- }
113
- else {
114
- result.runtimes.error =
115
- runtimesStatus.reason?.message || 'Unknown error';
116
- }
117
- // Process Spacer status
118
- if (spacerStatus.status === 'fulfilled') {
119
- result.spacer.healthy = true;
120
- result.spacer.details = spacerStatus.value;
121
- }
122
- else {
123
- result.spacer.error = spacerStatus.reason?.message || 'Unknown error';
124
- }
125
- return {
126
- ...result,
127
- allHealthy: result.iam.healthy &&
128
- result.runtimes.healthy &&
129
- result.spacer.healthy,
130
- };
131
- }
132
- };
133
- }
@@ -1,59 +0,0 @@
1
- import type { User, LoginRequest, LoginResponse } from '../../../api/types/iam';
2
- import type { Constructor } from '../utils/mixins';
3
- /**
4
- * IAM mixin that provides authentication and user management functionality.
5
- *
6
- */
7
- export declare function IAMMixin<TBase extends Constructor>(Base: TBase): {
8
- new (...args: any[]): {
9
- /**
10
- * Get the current user's profile information.
11
- *
12
- * @returns Promise resolving to the current user's profile
13
- *
14
- * @example
15
- * ```typescript
16
- * const user = await sdk.whoami();
17
- * console.log('Current user:', user.username);
18
- * ```
19
- */
20
- whoami(): Promise<User>;
21
- /**
22
- * Authenticate a user with credentials or token.
23
- *
24
- * @param data - Login credentials (either handle+password or token)
25
- * @returns Promise resolving to login response with tokens
26
- *
27
- * @example
28
- * ```typescript
29
- * // Login with handle and password
30
- * const loginResponse = await sdk.login({
31
- * handle: 'user@example.com',
32
- * password: 'secure-password'
33
- * });
34
- *
35
- * // Or login with token
36
- * const tokenResponse = await sdk.login({
37
- * token: 'existing-auth-token'
38
- * });
39
- *
40
- * // Update SDK with new token
41
- * sdk.updateToken(loginResponse.token);
42
- * ```
43
- */
44
- login(data: LoginRequest): Promise<LoginResponse>;
45
- /**
46
- * Log out the current user.
47
- *
48
- * This method performs a logout operation on the server and clears
49
- * the authentication token from the SDK.
50
- *
51
- * @example
52
- * ```typescript
53
- * await sdk.logout();
54
- * console.log('User logged out successfully');
55
- * ```
56
- */
57
- logout(): Promise<void>;
58
- };
59
- } & TBase;
@@ -1,83 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- /**
6
- * @module sdk/client/mixins/IAMMixin
7
- * @description IAM (Identity and Access Management) mixin for the Datalayer SDK.
8
- *
9
- * This mixin provides intuitive authentication and user management methods
10
- * that are mixed into the main DatalayerSDK class.
11
- */
12
- import { authentication, profile } from '../../../api/iam';
13
- /**
14
- * IAM mixin that provides authentication and user management functionality.
15
- *
16
- */
17
- export function IAMMixin(Base) {
18
- return class extends Base {
19
- /**
20
- * Get the current user's profile information.
21
- *
22
- * @returns Promise resolving to the current user's profile
23
- *
24
- * @example
25
- * ```typescript
26
- * const user = await sdk.whoami();
27
- * console.log('Current user:', user.username);
28
- * ```
29
- */
30
- async whoami() {
31
- const token = this.getToken();
32
- const iamRunUrl = this.getIamRunUrl();
33
- const response = await profile.me(token, iamRunUrl);
34
- return response.me;
35
- }
36
- /**
37
- * Authenticate a user with credentials or token.
38
- *
39
- * @param data - Login credentials (either handle+password or token)
40
- * @returns Promise resolving to login response with tokens
41
- *
42
- * @example
43
- * ```typescript
44
- * // Login with handle and password
45
- * const loginResponse = await sdk.login({
46
- * handle: 'user@example.com',
47
- * password: 'secure-password'
48
- * });
49
- *
50
- * // Or login with token
51
- * const tokenResponse = await sdk.login({
52
- * token: 'existing-auth-token'
53
- * });
54
- *
55
- * // Update SDK with new token
56
- * sdk.updateToken(loginResponse.token);
57
- * ```
58
- */
59
- async login(data) {
60
- const iamRunUrl = this.getIamRunUrl();
61
- return await authentication.login(data, iamRunUrl);
62
- }
63
- /**
64
- * Log out the current user.
65
- *
66
- * This method performs a logout operation on the server and clears
67
- * the authentication token from the SDK.
68
- *
69
- * @example
70
- * ```typescript
71
- * await sdk.logout();
72
- * console.log('User logged out successfully');
73
- * ```
74
- */
75
- async logout() {
76
- const token = this.getToken();
77
- const iamRunUrl = this.getIamRunUrl();
78
- await authentication.logout(token, iamRunUrl);
79
- // Clear the token from the SDK
80
- this.updateToken('');
81
- }
82
- };
83
- }
@@ -1,134 +0,0 @@
1
- import type { Environment, CreateRuntimeRequest, CreateRuntimeSnapshotRequest } from '../../../api/types/runtimes';
2
- import type { Constructor } from '../utils/mixins';
3
- import { Runtime } from '../models/Runtime';
4
- import { Snapshot } from '../models/Snapshot';
5
- /**
6
- * Runtimes mixin that provides computational environment and runtime management.
7
- *
8
- * This mixin is applied to the DatalayerSDK class to provide clean, intuitive
9
- * methods for managing environments and runtimes.
10
- */
11
- export declare function RuntimesMixin<TBase extends Constructor>(Base: TBase): {
12
- new (...args: any[]): {
13
- _extractRuntimePodName(runtimePodNameOrInstance: string | Runtime): string;
14
- _extractSnapshotId(snapshotIdOrInstance: string | Snapshot): string;
15
- /**
16
- * List all available computational environments.
17
- *
18
- * @returns Promise resolving to array of environments
19
- *
20
- * @example
21
- * ```typescript
22
- * const environments = await sdk.listEnvironments();
23
- * console.log('Available environments:', environments.length);
24
- * ```
25
- */
26
- listEnvironments(): Promise<Environment[]>;
27
- /**
28
- * Create a new computational runtime.
29
- *
30
- * @param data - Runtime creation parameters
31
- * @returns Promise resolving to created runtime
32
- *
33
- * @example
34
- * ```typescript
35
- * const runtime = await sdk.createRuntime({
36
- * environment_name: 'python-cpu-env',
37
- * credits_limit: 100
38
- * });
39
- * console.log('Runtime created:', runtime.podName);
40
- * ```
41
- */
42
- createRuntime(data: CreateRuntimeRequest): Promise<Runtime>;
43
- /**
44
- * List all runtimes.
45
- *
46
- * @returns Promise resolving to array of runtimes
47
- *
48
- * @example
49
- * ```typescript
50
- * const allRuntimes = await sdk.listRuntimes();
51
- * console.log('Total runtimes:', allRuntimes.length);
52
- * ```
53
- */
54
- listRuntimes(): Promise<Runtime[]>;
55
- /**
56
- * Get details for a specific runtime by pod name or Runtime instance.
57
- *
58
- * @param podNameOrRuntime - Runtime pod name (string) or Runtime instance
59
- * @returns Promise resolving to runtime details
60
- *
61
- * @example
62
- * ```typescript
63
- * const runtime = await sdk.getRuntime('runtime-abc123');
64
- * const refreshed = await sdk.getRuntime(runtime);
65
- * ```
66
- */
67
- getRuntime(podNameOrRuntime: string | Runtime): Promise<Runtime>;
68
- /**
69
- * Delete a runtime permanently.
70
- *
71
- * @param podNameOrRuntime - Runtime pod name (string) or Runtime instance
72
- *
73
- * @example
74
- * ```typescript
75
- * await sdk.deleteRuntime('runtime-abc123');
76
- * await sdk.deleteRuntime(runtime);
77
- * ```
78
- */
79
- deleteRuntime(podNameOrRuntime: string | Runtime): Promise<void>;
80
- /**
81
- * Create a snapshot of a runtime.
82
- *
83
- * @param data - Snapshot creation parameters
84
- * @returns Promise resolving to created snapshot
85
- *
86
- * @example
87
- * ```typescript
88
- * const snapshot = await sdk.createSnapshot({
89
- * pod_name: 'runtime-abc123',
90
- * name: 'my-checkpoint',
91
- * description: 'Before major changes'
92
- * });
93
- * ```
94
- */
95
- createSnapshot(data: CreateRuntimeSnapshotRequest): Promise<Snapshot>;
96
- /**
97
- * List all runtime snapshots.
98
- *
99
- * @returns Promise resolving to array of snapshots
100
- *
101
- * @example
102
- * ```typescript
103
- * const allSnapshots = await sdk.listSnapshots();
104
- * console.log('Total snapshots:', allSnapshots.length);
105
- * ```
106
- */
107
- listSnapshots(): Promise<Snapshot[]>;
108
- /**
109
- * Get details for a specific snapshot by ID or Snapshot instance.
110
- *
111
- * @param idOrSnapshot - Snapshot ID (string) or Snapshot instance
112
- * @returns Promise resolving to snapshot details
113
- *
114
- * @example
115
- * ```typescript
116
- * const snapshot = await sdk.getSnapshot('snapshot-abc123');
117
- * const refreshed = await sdk.getSnapshot(snapshot);
118
- * ```
119
- */
120
- getSnapshot(idOrSnapshot: string | Snapshot): Promise<Snapshot>;
121
- /**
122
- * Delete a snapshot permanently.
123
- *
124
- * @param idOrSnapshot - Snapshot ID (string) or Snapshot instance
125
- *
126
- * @example
127
- * ```typescript
128
- * await sdk.deleteSnapshot('snapshot-abc123');
129
- * await sdk.deleteSnapshot(snapshot);
130
- * ```
131
- */
132
- deleteSnapshot(idOrSnapshot: string | Snapshot): Promise<void>;
133
- };
134
- } & TBase;
@@ -1,221 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- /**
6
- * @module sdk/client/mixins/RuntimesMixin
7
- * @description Runtimes mixin for the Datalayer SDK.
8
- *
9
- * This mixin provides intuitive methods for managing computational environments,
10
- * runtimes, and snapshots that are mixed into the main DatalayerSDK class.
11
- */
12
- import { environments, runtimes, snapshots } from '../../../api/runtimes';
13
- import { Runtime } from '../models/Runtime';
14
- import { Snapshot } from '../models/Snapshot';
15
- /**
16
- * Runtimes mixin that provides computational environment and runtime management.
17
- *
18
- * This mixin is applied to the DatalayerSDK class to provide clean, intuitive
19
- * methods for managing environments and runtimes.
20
- */
21
- export function RuntimesMixin(Base) {
22
- return class extends Base {
23
- // ========================================================================
24
- // Helper Functions
25
- // ========================================================================
26
- _extractRuntimePodName(runtimePodNameOrInstance) {
27
- return typeof runtimePodNameOrInstance === 'string'
28
- ? runtimePodNameOrInstance
29
- : runtimePodNameOrInstance.podName;
30
- }
31
- _extractSnapshotId(snapshotIdOrInstance) {
32
- return typeof snapshotIdOrInstance === 'string'
33
- ? snapshotIdOrInstance
34
- : snapshotIdOrInstance.uid;
35
- }
36
- // ========================================================================
37
- // Environments
38
- // ========================================================================
39
- /**
40
- * List all available computational environments.
41
- *
42
- * @returns Promise resolving to array of environments
43
- *
44
- * @example
45
- * ```typescript
46
- * const environments = await sdk.listEnvironments();
47
- * console.log('Available environments:', environments.length);
48
- * ```
49
- */
50
- async listEnvironments() {
51
- const token = this.getToken();
52
- const runtimesRunUrl = this.getRuntimesRunUrl();
53
- const response = await environments.listEnvironments(token, runtimesRunUrl);
54
- return response.environments;
55
- }
56
- // ========================================================================
57
- // Runtimes
58
- // ========================================================================
59
- /**
60
- * Create a new computational runtime.
61
- *
62
- * @param data - Runtime creation parameters
63
- * @returns Promise resolving to created runtime
64
- *
65
- * @example
66
- * ```typescript
67
- * const runtime = await sdk.createRuntime({
68
- * environment_name: 'python-cpu-env',
69
- * credits_limit: 100
70
- * });
71
- * console.log('Runtime created:', runtime.podName);
72
- * ```
73
- */
74
- async createRuntime(data) {
75
- const token = this.getToken();
76
- const runtimesRunUrl = this.getRuntimesRunUrl();
77
- const response = await runtimes.createRuntime(token, data, runtimesRunUrl);
78
- return new Runtime(response.runtime, this);
79
- }
80
- /**
81
- * List all runtimes.
82
- *
83
- * @returns Promise resolving to array of runtimes
84
- *
85
- * @example
86
- * ```typescript
87
- * const allRuntimes = await sdk.listRuntimes();
88
- * console.log('Total runtimes:', allRuntimes.length);
89
- * ```
90
- */
91
- async listRuntimes() {
92
- const token = this.getToken();
93
- const runtimesRunUrl = this.getRuntimesRunUrl();
94
- const response = await runtimes.listRuntimes(token, runtimesRunUrl);
95
- return response.runtimes.map(r => new Runtime(r, this));
96
- }
97
- /**
98
- * Get details for a specific runtime by pod name or Runtime instance.
99
- *
100
- * @param podNameOrRuntime - Runtime pod name (string) or Runtime instance
101
- * @returns Promise resolving to runtime details
102
- *
103
- * @example
104
- * ```typescript
105
- * const runtime = await sdk.getRuntime('runtime-abc123');
106
- * const refreshed = await sdk.getRuntime(runtime);
107
- * ```
108
- */
109
- async getRuntime(podNameOrRuntime) {
110
- const podName = this._extractRuntimePodName(podNameOrRuntime);
111
- const token = this.getToken();
112
- const runtimesRunUrl = this.getRuntimesRunUrl();
113
- const runtimeData = await runtimes.getRuntime(token, podName, runtimesRunUrl);
114
- return new Runtime(runtimeData, this);
115
- }
116
- /**
117
- * Delete a runtime permanently.
118
- *
119
- * @param podNameOrRuntime - Runtime pod name (string) or Runtime instance
120
- *
121
- * @example
122
- * ```typescript
123
- * await sdk.deleteRuntime('runtime-abc123');
124
- * await sdk.deleteRuntime(runtime);
125
- * ```
126
- */
127
- async deleteRuntime(podNameOrRuntime) {
128
- const podName = this._extractRuntimePodName(podNameOrRuntime);
129
- const token = this.getToken();
130
- const runtimesRunUrl = this.getRuntimesRunUrl();
131
- await runtimes.deleteRuntime(token, podName, runtimesRunUrl);
132
- // If a Runtime instance was passed, mark it as deleted
133
- if (typeof podNameOrRuntime !== 'string' &&
134
- podNameOrRuntime instanceof Runtime) {
135
- podNameOrRuntime._deleted = true;
136
- }
137
- }
138
- // ========================================================================
139
- // Snapshots
140
- // ========================================================================
141
- /**
142
- * Create a snapshot of a runtime.
143
- *
144
- * @param data - Snapshot creation parameters
145
- * @returns Promise resolving to created snapshot
146
- *
147
- * @example
148
- * ```typescript
149
- * const snapshot = await sdk.createSnapshot({
150
- * pod_name: 'runtime-abc123',
151
- * name: 'my-checkpoint',
152
- * description: 'Before major changes'
153
- * });
154
- * ```
155
- */
156
- async createSnapshot(data) {
157
- const token = this.getToken();
158
- const runtimesRunUrl = this.getRuntimesRunUrl();
159
- const response = await snapshots.createSnapshot(token, data, runtimesRunUrl);
160
- return new Snapshot(response.snapshot, this);
161
- }
162
- /**
163
- * List all runtime snapshots.
164
- *
165
- * @returns Promise resolving to array of snapshots
166
- *
167
- * @example
168
- * ```typescript
169
- * const allSnapshots = await sdk.listSnapshots();
170
- * console.log('Total snapshots:', allSnapshots.length);
171
- * ```
172
- */
173
- async listSnapshots() {
174
- const token = this.getToken();
175
- const runtimesRunUrl = this.getRuntimesRunUrl();
176
- const response = await snapshots.listSnapshots(token, runtimesRunUrl);
177
- return response.snapshots.map(s => new Snapshot(s, this));
178
- }
179
- /**
180
- * Get details for a specific snapshot by ID or Snapshot instance.
181
- *
182
- * @param idOrSnapshot - Snapshot ID (string) or Snapshot instance
183
- * @returns Promise resolving to snapshot details
184
- *
185
- * @example
186
- * ```typescript
187
- * const snapshot = await sdk.getSnapshot('snapshot-abc123');
188
- * const refreshed = await sdk.getSnapshot(snapshot);
189
- * ```
190
- */
191
- async getSnapshot(idOrSnapshot) {
192
- const snapshotId = this._extractSnapshotId(idOrSnapshot);
193
- const token = this.getToken();
194
- const runtimesRunUrl = this.getRuntimesRunUrl();
195
- const response = await snapshots.getSnapshot(token, snapshotId, runtimesRunUrl);
196
- return new Snapshot(response.snapshot, this);
197
- }
198
- /**
199
- * Delete a snapshot permanently.
200
- *
201
- * @param idOrSnapshot - Snapshot ID (string) or Snapshot instance
202
- *
203
- * @example
204
- * ```typescript
205
- * await sdk.deleteSnapshot('snapshot-abc123');
206
- * await sdk.deleteSnapshot(snapshot);
207
- * ```
208
- */
209
- async deleteSnapshot(idOrSnapshot) {
210
- const snapshotId = this._extractSnapshotId(idOrSnapshot);
211
- const token = this.getToken();
212
- const runtimesRunUrl = this.getRuntimesRunUrl();
213
- await snapshots.deleteSnapshot(token, snapshotId, runtimesRunUrl);
214
- // If a Snapshot instance was passed, mark it as deleted
215
- if (typeof idOrSnapshot !== 'string' &&
216
- idOrSnapshot instanceof Snapshot) {
217
- idOrSnapshot._deleted = true;
218
- }
219
- }
220
- };
221
- }