@datalayer/core 0.0.12 → 0.0.14

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 (249) hide show
  1. package/README.md +2 -2
  2. package/lib/api/DatalayerApi.d.ts +38 -26
  3. package/lib/api/DatalayerApi.js +52 -13
  4. package/lib/api/iam/authentication.d.ts +9 -8
  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 +18 -0
  15. package/lib/api/iam/usage.js +39 -0
  16. package/lib/api/index.d.ts +6 -6
  17. package/lib/api/index.js +6 -7
  18. package/lib/api/runtimes/environments.d.ts +2 -2
  19. package/lib/api/runtimes/environments.js +3 -2
  20. package/lib/api/runtimes/healthz.d.ts +3 -13
  21. package/lib/api/runtimes/healthz.js +4 -3
  22. package/lib/api/runtimes/index.d.ts +3 -2
  23. package/lib/api/runtimes/index.js +3 -2
  24. package/lib/api/runtimes/runtimes.d.ts +4 -4
  25. package/lib/api/runtimes/runtimes.js +17 -6
  26. package/lib/api/runtimes/snapshots.d.ts +4 -4
  27. package/lib/api/runtimes/snapshots.js +3 -2
  28. package/lib/api/spacer/documents.d.ts +12 -0
  29. package/lib/api/spacer/documents.js +43 -0
  30. package/lib/api/spacer/healthz.d.ts +3 -13
  31. package/lib/api/spacer/healthz.js +4 -3
  32. package/lib/api/spacer/index.d.ts +4 -2
  33. package/lib/api/spacer/index.js +4 -2
  34. package/lib/api/spacer/items.d.ts +9 -1
  35. package/lib/api/spacer/items.js +17 -2
  36. package/lib/api/spacer/lexicals.d.ts +1 -1
  37. package/lib/api/spacer/lexicals.js +3 -2
  38. package/lib/api/spacer/notebooks.d.ts +1 -1
  39. package/lib/api/spacer/notebooks.js +3 -2
  40. package/lib/api/spacer/spaces.d.ts +1 -1
  41. package/lib/api/spacer/spaces.js +3 -2
  42. package/lib/api/spacer/users.d.ts +1 -1
  43. package/lib/api/spacer/users.js +3 -2
  44. package/lib/api/utils/validation.d.ts +24 -1
  45. package/lib/api/utils/validation.js +62 -1
  46. package/lib/client/base.d.ts +75 -0
  47. package/lib/client/base.js +199 -0
  48. package/lib/client/constants.d.ts +22 -0
  49. package/lib/client/constants.js +22 -0
  50. package/lib/client/index.d.ts +108 -0
  51. package/lib/client/index.js +79 -0
  52. package/lib/client/mixins/IAMMixin.d.ts +54 -0
  53. package/lib/client/mixins/IAMMixin.js +181 -0
  54. package/lib/client/mixins/RuntimesMixin.d.ts +93 -0
  55. package/lib/client/mixins/RuntimesMixin.js +229 -0
  56. package/lib/client/mixins/SpacerMixin.d.ts +111 -0
  57. package/lib/client/mixins/SpacerMixin.js +340 -0
  58. package/lib/client/utils/mixins.d.ts +12 -0
  59. package/lib/{sdk/client → client}/utils/mixins.js +0 -28
  60. package/lib/client/utils/spacerUtils.d.ts +18 -0
  61. package/lib/client/utils/spacerUtils.js +32 -0
  62. package/lib/collaboration/DatalayerCollaboration.d.ts +6 -1
  63. package/lib/collaboration/DatalayerCollaboration.js +2 -2
  64. package/lib/collaboration/DatalayerCollaborationProvider.d.ts +5 -0
  65. package/lib/collaboration/DatalayerCollaborationProvider.js +10 -9
  66. package/lib/components/progress/CreditsIndicator.d.ts +1 -1
  67. package/lib/components/runtimes/RuntimeCellVariablesDialog.js +1 -1
  68. package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +1 -1
  69. package/lib/components/runtimes/RuntimeLauncherDialog.js +2 -2
  70. package/lib/components/runtimes/RuntimePickerBase.d.ts +1 -1
  71. package/lib/components/runtimes/RuntimePickerBase.js +1 -1
  72. package/lib/components/runtimes/RuntimePickerCell.js +3 -3
  73. package/lib/components/runtimes/RuntimePickerNotebook.d.ts +1 -1
  74. package/lib/components/runtimes/RuntimePickerNotebook.js +2 -2
  75. package/lib/components/runtimes/RuntimeTransfer.d.ts +2 -2
  76. package/lib/components/runtimes/RuntimeUtils.d.ts +1 -1
  77. package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -1
  78. package/lib/components/snapshots/RuntimeSnapshotMenu.js +27 -20
  79. package/lib/config/Configuration.d.ts +8 -0
  80. package/lib/hooks/useDatalayer.js +1 -1
  81. package/lib/hooks/useRuntimes.js +1 -1
  82. package/lib/hooks/useToast.js +1 -1
  83. package/lib/index.d.ts +2 -3
  84. package/lib/index.js +4 -3
  85. package/lib/models/Common.d.ts +64 -0
  86. package/lib/models/CreditsDTO.d.ts +124 -0
  87. package/lib/models/CreditsDTO.js +135 -0
  88. package/lib/models/Environment.d.ts +1 -1
  89. package/lib/models/EnvironmentDTO.d.ts +125 -0
  90. package/lib/models/EnvironmentDTO.js +88 -0
  91. package/lib/models/HealthCheck.d.ts +72 -0
  92. package/lib/models/HealthCheck.js +107 -0
  93. package/lib/{api/types/iam.d.ts → models/IAM.d.ts} +15 -78
  94. package/lib/models/ItemDTO.d.ts +74 -0
  95. package/lib/models/ItemDTO.js +186 -0
  96. package/lib/models/LexicalDTO.d.ts +155 -0
  97. package/lib/models/LexicalDTO.js +157 -0
  98. package/lib/models/NotebookDTO.d.ts +96 -0
  99. package/lib/models/NotebookDTO.js +153 -0
  100. package/lib/models/Profile.d.ts +65 -0
  101. package/lib/models/RuntimeDTO.d.ts +191 -0
  102. package/lib/models/RuntimeDTO.js +204 -0
  103. package/lib/models/RuntimeSnapshotDTO.d.ts +173 -0
  104. package/lib/models/RuntimeSnapshotDTO.js +139 -0
  105. package/lib/models/SpaceDTO.d.ts +280 -0
  106. package/lib/models/SpaceDTO.js +239 -0
  107. package/lib/models/UserDTO.d.ts +86 -0
  108. package/lib/models/UserDTO.js +84 -0
  109. package/lib/models/index.d.ts +45 -4
  110. package/lib/models/index.js +45 -4
  111. package/lib/sdk/index.d.ts +5 -4
  112. package/lib/sdk/index.js +6 -5
  113. package/lib/services/DatalayerServiceManager.js +1 -1
  114. package/lib/state/substates/CoreState.js +2 -0
  115. package/lib/state/substates/RuntimesState.d.ts +1 -1
  116. package/lib/state/substates/RuntimesState.js +1 -1
  117. package/lib/{sdk/stateful → stateful}/index.d.ts +1 -1
  118. package/lib/{sdk/stateful → stateful}/index.js +1 -1
  119. package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.d.ts +1 -41
  120. package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.js +1 -20
  121. package/lib/{sdk/stateful → stateful}/runtimes/actions.d.ts +3 -3
  122. package/lib/{sdk/stateful → stateful}/runtimes/actions.js +8 -8
  123. package/lib/{sdk/stateful → stateful}/runtimes/apis.d.ts +8 -8
  124. package/package.json +13 -10
  125. package/lib/__tests__/hooks.test.d.ts +0 -1
  126. package/lib/__tests__/hooks.test.js +0 -19
  127. package/lib/__tests__/index.test.d.ts +0 -1
  128. package/lib/__tests__/index.test.js +0 -27
  129. package/lib/__tests__/integration.test.d.ts +0 -1
  130. package/lib/__tests__/integration.test.js +0 -57
  131. package/lib/__tests__/shared/cleanup-shared.d.ts +0 -4
  132. package/lib/__tests__/shared/cleanup-shared.js +0 -228
  133. package/lib/__tests__/shared/test-config.d.ts +0 -51
  134. package/lib/__tests__/shared/test-config.js +0 -110
  135. package/lib/__tests__/shared/test-constants.d.ts +0 -66
  136. package/lib/__tests__/shared/test-constants.js +0 -79
  137. package/lib/__tests__/utils.test.d.ts +0 -1
  138. package/lib/__tests__/utils.test.js +0 -59
  139. package/lib/api/__tests__/iam.authentication.integration.test.d.ts +0 -1
  140. package/lib/api/__tests__/iam.authentication.integration.test.js +0 -247
  141. package/lib/api/__tests__/iam.healthz.integration.test.d.ts +0 -1
  142. package/lib/api/__tests__/iam.healthz.integration.test.js +0 -63
  143. package/lib/api/__tests__/iam.profile.integration.test.d.ts +0 -1
  144. package/lib/api/__tests__/iam.profile.integration.test.js +0 -252
  145. package/lib/api/__tests__/runtimes.environments.integration.test.d.ts +0 -1
  146. package/lib/api/__tests__/runtimes.environments.integration.test.js +0 -122
  147. package/lib/api/__tests__/runtimes.healthz.integration.test.d.ts +0 -1
  148. package/lib/api/__tests__/runtimes.healthz.integration.test.js +0 -50
  149. package/lib/api/__tests__/runtimes.integration.test.d.ts +0 -1
  150. package/lib/api/__tests__/runtimes.integration.test.js +0 -369
  151. package/lib/api/__tests__/spacer.healthz.integration.test.d.ts +0 -1
  152. package/lib/api/__tests__/spacer.healthz.integration.test.js +0 -50
  153. package/lib/api/__tests__/spacer.integration.test.d.ts +0 -1
  154. package/lib/api/__tests__/spacer.integration.test.js +0 -519
  155. package/lib/api/iam/__tests__/authentication.unit.test.d.ts +0 -1
  156. package/lib/api/iam/__tests__/authentication.unit.test.js +0 -63
  157. package/lib/api/iam/__tests__/healthz.unit.test.d.ts +0 -1
  158. package/lib/api/iam/__tests__/healthz.unit.test.js +0 -60
  159. package/lib/api/iam/__tests__/profile.unit.test.d.ts +0 -1
  160. package/lib/api/iam/__tests__/profile.unit.test.js +0 -57
  161. package/lib/api/runtimes/__tests__/environments.unit.test.d.ts +0 -1
  162. package/lib/api/runtimes/__tests__/environments.unit.test.js +0 -77
  163. package/lib/api/runtimes/__tests__/healthz.unit.test.d.ts +0 -1
  164. package/lib/api/runtimes/__tests__/healthz.unit.test.js +0 -57
  165. package/lib/api/runtimes/__tests__/runtimes.unit.test.d.ts +0 -1
  166. package/lib/api/runtimes/__tests__/runtimes.unit.test.js +0 -139
  167. package/lib/api/runtimes/__tests__/snapshots.unit.test.d.ts +0 -1
  168. package/lib/api/runtimes/__tests__/snapshots.unit.test.js +0 -96
  169. package/lib/api/spacer/__tests__/healthz.unit.test.d.ts +0 -1
  170. package/lib/api/spacer/__tests__/healthz.unit.test.js +0 -57
  171. package/lib/api/spacer/__tests__/items.unit.test.d.ts +0 -1
  172. package/lib/api/spacer/__tests__/items.unit.test.js +0 -165
  173. package/lib/api/spacer/__tests__/lexicals.unit.test.d.ts +0 -1
  174. package/lib/api/spacer/__tests__/lexicals.unit.test.js +0 -323
  175. package/lib/api/spacer/__tests__/notebooks.unit.test.d.ts +0 -1
  176. package/lib/api/spacer/__tests__/notebooks.unit.test.js +0 -224
  177. package/lib/api/spacer/__tests__/users.unit.test.d.ts +0 -1
  178. package/lib/api/spacer/__tests__/users.unit.test.js +0 -132
  179. package/lib/api/types/index.d.ts +0 -32
  180. package/lib/api/types/index.js +0 -36
  181. package/lib/api/types/runtimes.d.ts +0 -235
  182. package/lib/api/types/spacer.d.ts +0 -271
  183. package/lib/api/types/spacer.js +0 -5
  184. package/lib/api/utils/__tests__/validation.test.d.ts +0 -1
  185. package/lib/api/utils/__tests__/validation.test.js +0 -109
  186. package/lib/sdk/client/__tests__/sdk.health.integration.test.d.ts +0 -1
  187. package/lib/sdk/client/__tests__/sdk.health.integration.test.js +0 -110
  188. package/lib/sdk/client/__tests__/sdk.iam.integration.test.d.ts +0 -1
  189. package/lib/sdk/client/__tests__/sdk.iam.integration.test.js +0 -179
  190. package/lib/sdk/client/__tests__/sdk.models.integration.test.d.ts +0 -1
  191. package/lib/sdk/client/__tests__/sdk.models.integration.test.js +0 -376
  192. package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.d.ts +0 -1
  193. package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.js +0 -276
  194. package/lib/sdk/client/__tests__/sdk.spacer.integration.test.d.ts +0 -1
  195. package/lib/sdk/client/__tests__/sdk.spacer.integration.test.js +0 -361
  196. package/lib/sdk/client/base.d.ts +0 -88
  197. package/lib/sdk/client/base.js +0 -112
  198. package/lib/sdk/client/index.d.ts +0 -192
  199. package/lib/sdk/client/index.js +0 -128
  200. package/lib/sdk/client/mixins/HealthMixin.d.ts +0 -100
  201. package/lib/sdk/client/mixins/HealthMixin.js +0 -133
  202. package/lib/sdk/client/mixins/IAMMixin.d.ts +0 -59
  203. package/lib/sdk/client/mixins/IAMMixin.js +0 -83
  204. package/lib/sdk/client/mixins/RuntimesMixin.d.ts +0 -134
  205. package/lib/sdk/client/mixins/RuntimesMixin.js +0 -221
  206. package/lib/sdk/client/mixins/SpacerMixin.d.ts +0 -184
  207. package/lib/sdk/client/mixins/SpacerMixin.js +0 -278
  208. package/lib/sdk/client/models/Lexical.d.ts +0 -156
  209. package/lib/sdk/client/models/Lexical.js +0 -275
  210. package/lib/sdk/client/models/Notebook.d.ts +0 -174
  211. package/lib/sdk/client/models/Notebook.js +0 -311
  212. package/lib/sdk/client/models/Runtime.d.ts +0 -221
  213. package/lib/sdk/client/models/Runtime.js +0 -341
  214. package/lib/sdk/client/models/Snapshot.d.ts +0 -156
  215. package/lib/sdk/client/models/Snapshot.js +0 -244
  216. package/lib/sdk/client/models/Space.d.ts +0 -182
  217. package/lib/sdk/client/models/Space.js +0 -276
  218. package/lib/sdk/client/models/__tests__/Lexical.test.d.ts +0 -1
  219. package/lib/sdk/client/models/__tests__/Lexical.test.js +0 -288
  220. package/lib/sdk/client/models/__tests__/Notebook.test.d.ts +0 -1
  221. package/lib/sdk/client/models/__tests__/Notebook.test.js +0 -206
  222. package/lib/sdk/client/models/__tests__/Runtime.test.d.ts +0 -1
  223. package/lib/sdk/client/models/__tests__/Runtime.test.js +0 -133
  224. package/lib/sdk/client/models/__tests__/Snapshot.test.d.ts +0 -1
  225. package/lib/sdk/client/models/__tests__/Snapshot.test.js +0 -244
  226. package/lib/sdk/client/models/__tests__/Space.test.d.ts +0 -1
  227. package/lib/sdk/client/models/__tests__/Space.test.js +0 -334
  228. package/lib/sdk/client/models/index.d.ts +0 -30
  229. package/lib/sdk/client/models/index.js +0 -30
  230. package/lib/sdk/client/utils/mixins.d.ts +0 -42
  231. /package/lib/{api/types/iam.js → models/Common.js} +0 -0
  232. /package/lib/{api/types/runtimes.js → models/IAM.js} +0 -0
  233. /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.d.ts +0 -0
  234. /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.js +0 -0
  235. /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.d.ts +0 -0
  236. /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.js +0 -0
  237. /package/lib/{sdk/stateful → stateful}/jupyter/index.d.ts +0 -0
  238. /package/lib/{sdk/stateful → stateful}/jupyter/index.js +0 -0
  239. /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.d.ts +0 -0
  240. /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.js +0 -0
  241. /package/lib/{sdk/stateful → stateful}/runtimes/apis.js +0 -0
  242. /package/lib/{sdk/stateful → stateful}/runtimes/index.d.ts +0 -0
  243. /package/lib/{sdk/stateful → stateful}/runtimes/index.js +0 -0
  244. /package/lib/{sdk/stateful → stateful}/runtimes/settings.d.ts +0 -0
  245. /package/lib/{sdk/stateful → stateful}/runtimes/settings.js +0 -0
  246. /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.d.ts +0 -0
  247. /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.js +0 -0
  248. /package/lib/{sdk/stateful → stateful}/runtimes/utils.d.ts +0 -0
  249. /package/lib/{sdk/stateful → stateful}/runtimes/utils.js +0 -0
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Environment domain model for the Datalayer SDK.
3
+ *
4
+ * @module models/EnvironmentDTO
5
+ */
6
+ import type { DatalayerClient } from '../index';
7
+ /**
8
+ * Represents a computing environment available in the Datalayer platform.
9
+ * @interface EnvironmentData
10
+ */
11
+ export interface EnvironmentData {
12
+ /** Human-readable title for the environment */
13
+ title: string;
14
+ /** Detailed description of the environment */
15
+ description: string;
16
+ /** Docker image used for this environment */
17
+ dockerImage: string;
18
+ /** Example usage or description */
19
+ example?: string;
20
+ /** Code snippets for this environment */
21
+ snippets?: any[];
22
+ /** Content mounts for this environment */
23
+ contents?: any[];
24
+ /** Kernel configuration */
25
+ runtime?: {
26
+ /** Template for kernel naming */
27
+ givenNameTemplate?: string;
28
+ };
29
+ /** Programming language (e.g., "python", "r") */
30
+ language: string;
31
+ /** Resource ranges configuration */
32
+ resourcesRanges?: any;
33
+ /** Credits consumed per hour when running */
34
+ burning_rate: number;
35
+ /** Simple resource specification */
36
+ resources?: any;
37
+ /** Name identifier for the environment */
38
+ name: string;
39
+ /** Docker registry for the image */
40
+ dockerRegistry?: string;
41
+ /** Icon or avatar URL for the environment */
42
+ icon?: string;
43
+ /** Whether the environment is enabled */
44
+ enabled?: boolean;
45
+ /** Tags associated with the environment */
46
+ tags?: string[];
47
+ }
48
+ /**
49
+ * Stable public interface for Environment data.
50
+ * This is the contract that SDK consumers can rely on.
51
+ * The raw API may change, but this interface remains stable.
52
+ */
53
+ export interface EnvironmentJSON {
54
+ /** Human-readable title for the environment */
55
+ title: string;
56
+ /** Unique name identifier for the environment */
57
+ name: string;
58
+ /** Credits consumed per hour for this environment */
59
+ burningRate: number;
60
+ /** Description of the environment (contains HTML markup) */
61
+ description: string;
62
+ /** Rich description of the environment (contains HTML markup) */
63
+ richDescription: string;
64
+ }
65
+ /**
66
+ * Response from listing available environments
67
+ * @interface ListEnvironmentsResponse
68
+ */
69
+ export interface ListEnvironmentsResponse {
70
+ /** Whether the request was successful */
71
+ success: boolean;
72
+ /** Response message from the server */
73
+ message: string;
74
+ /** Array of available environments */
75
+ environments: EnvironmentData[];
76
+ }
77
+ /**
78
+ * Environment domain model that wraps API responses with convenient methods.
79
+ * Provides information about available computational environments.
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * const environments = await sdk.listEnvironments();
84
+ * const aiEnv = environments.find(env => env.name === 'ai-env');
85
+ * console.log(aiEnv.title); // "AI Environment"
86
+ * ```
87
+ */
88
+ export declare class EnvironmentDTO {
89
+ /** @internal */
90
+ _data: EnvironmentData;
91
+ /**
92
+ * Create an Environment instance.
93
+ *
94
+ * @param data - Environment data from API
95
+ * @param _sdk - SDK instance (not currently used but kept for consistency)
96
+ */
97
+ constructor(data: EnvironmentData, _sdk: DatalayerClient);
98
+ /** Human-readable title for the environment (e.g., 'AI Environment', 'Python CPU Environment'). */
99
+ get title(): string;
100
+ /** Unique name identifier for the environment (e.g., 'ai-env', 'python-cpu-env'). */
101
+ get name(): string;
102
+ /** Credits consumed per hour for this environment. */
103
+ get burningRate(): number;
104
+ /** Rich description of the environment (contains HTML markup). */
105
+ get richDescription(): string;
106
+ /** Clean description without HTML tags. */
107
+ get description(): string;
108
+ /**
109
+ * Get environment data in camelCase format.
110
+ * Returns only the core fields that consumers need.
111
+ * This provides a stable interface regardless of API changes.
112
+ *
113
+ * @returns Core environment data with camelCase properties
114
+ */
115
+ toJSON(): EnvironmentJSON;
116
+ /**
117
+ * Get the raw environment data exactly as received from the API.
118
+ * This preserves the original snake_case naming from the API response.
119
+ *
120
+ * @returns Raw environment data from API
121
+ */
122
+ rawData(): EnvironmentData;
123
+ /** String representation of the environment. */
124
+ toString(): string;
125
+ }
@@ -0,0 +1,88 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ import { validateJSON } from '../api/utils/validation';
6
+ /**
7
+ * Environment domain model that wraps API responses with convenient methods.
8
+ * Provides information about available computational environments.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const environments = await sdk.listEnvironments();
13
+ * const aiEnv = environments.find(env => env.name === 'ai-env');
14
+ * console.log(aiEnv.title); // "AI Environment"
15
+ * ```
16
+ */
17
+ export class EnvironmentDTO {
18
+ /** @internal */
19
+ _data;
20
+ /**
21
+ * Create an Environment instance.
22
+ *
23
+ * @param data - Environment data from API
24
+ * @param _sdk - SDK instance (not currently used but kept for consistency)
25
+ */
26
+ constructor(data, _sdk) {
27
+ this._data = data;
28
+ // SDK instance not currently used but kept for future extensibility
29
+ }
30
+ // ========================================================================
31
+ // Properties
32
+ // ========================================================================
33
+ /** Human-readable title for the environment (e.g., 'AI Environment', 'Python CPU Environment'). */
34
+ get title() {
35
+ return this._data.title;
36
+ }
37
+ /** Unique name identifier for the environment (e.g., 'ai-env', 'python-cpu-env'). */
38
+ get name() {
39
+ return this._data.name;
40
+ }
41
+ /** Credits consumed per hour for this environment. */
42
+ get burningRate() {
43
+ return this._data.burning_rate;
44
+ }
45
+ /** Rich description of the environment (contains HTML markup). */
46
+ get richDescription() {
47
+ return this._data.description;
48
+ }
49
+ /** Clean description without HTML tags. */
50
+ get description() {
51
+ // Simple HTML tag removal
52
+ return this._data.description.replace(/<[^>]*>/g, '').trim();
53
+ }
54
+ // ========================================================================
55
+ // Utility Methods
56
+ // ========================================================================
57
+ /**
58
+ * Get environment data in camelCase format.
59
+ * Returns only the core fields that consumers need.
60
+ * This provides a stable interface regardless of API changes.
61
+ *
62
+ * @returns Core environment data with camelCase properties
63
+ */
64
+ toJSON() {
65
+ const obj = {
66
+ title: this.title,
67
+ name: this.name,
68
+ burningRate: this.burningRate,
69
+ description: this.description,
70
+ richDescription: this.richDescription,
71
+ };
72
+ validateJSON(obj, 'Environment');
73
+ return obj;
74
+ }
75
+ /**
76
+ * Get the raw environment data exactly as received from the API.
77
+ * This preserves the original snake_case naming from the API response.
78
+ *
79
+ * @returns Raw environment data from API
80
+ */
81
+ rawData() {
82
+ return this._data;
83
+ }
84
+ /** String representation of the environment. */
85
+ toString() {
86
+ return `Environment(${this.name}, ${this.title})`;
87
+ }
88
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Represents a health check response from a Datalayer service.
3
+ * Provides standardized health status information across all services.
4
+ */
5
+ export declare class HealthCheck {
6
+ healthy: boolean;
7
+ status: string;
8
+ responseTime: number;
9
+ errors: string[];
10
+ timestamp: Date;
11
+ /**
12
+ * Create a HealthCheck instance.
13
+ * @param data - The health check data
14
+ * @param sdk - Reference to the SDK instance (unused but kept for consistency)
15
+ */
16
+ constructor(data: any, sdk: any);
17
+ /**
18
+ * Check if the service is healthy.
19
+ * @returns True if the service is healthy
20
+ */
21
+ isHealthy(): boolean;
22
+ /**
23
+ * Get the service status.
24
+ * @returns The status string
25
+ */
26
+ getStatus(): string;
27
+ /**
28
+ * Get the response time in milliseconds.
29
+ * @returns The response time
30
+ */
31
+ getResponseTime(): number;
32
+ /**
33
+ * Get any errors reported during the health check.
34
+ * @returns Array of error messages
35
+ */
36
+ getErrors(): string[];
37
+ /**
38
+ * Get the timestamp of the health check.
39
+ * @returns The timestamp
40
+ */
41
+ getTimestamp(): Date;
42
+ /**
43
+ * Check if there are any errors.
44
+ * @returns True if there are errors
45
+ */
46
+ hasErrors(): boolean;
47
+ /**
48
+ * Get a human-readable summary of the health check.
49
+ * @returns Summary string
50
+ */
51
+ getSummary(): string;
52
+ /**
53
+ * Convert to a plain object.
54
+ * @returns Plain object representation
55
+ */
56
+ toJSON(): Promise<HealthCheckJSON>;
57
+ /**
58
+ * Get a string representation.
59
+ * @returns String representation
60
+ */
61
+ toString(): string;
62
+ }
63
+ /**
64
+ * JSON representation of a HealthCheck.
65
+ */
66
+ export interface HealthCheckJSON {
67
+ healthy: boolean;
68
+ status: string;
69
+ responseTime: number;
70
+ errors: string[];
71
+ timestamp: string;
72
+ }
@@ -0,0 +1,107 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ import { validateJSON } from '../api/utils/validation';
6
+ /**
7
+ * Represents a health check response from a Datalayer service.
8
+ * Provides standardized health status information across all services.
9
+ */
10
+ export class HealthCheck {
11
+ // Properties
12
+ healthy;
13
+ status;
14
+ responseTime;
15
+ errors;
16
+ timestamp;
17
+ /**
18
+ * Create a HealthCheck instance.
19
+ * @param data - The health check data
20
+ * @param sdk - Reference to the SDK instance (unused but kept for consistency)
21
+ */
22
+ constructor(data, sdk) {
23
+ // Initialize properties
24
+ this.healthy = data.healthy || false;
25
+ this.status = data.status || 'unknown';
26
+ this.responseTime = data.responseTime || 0;
27
+ this.errors = data.errors || [];
28
+ this.timestamp = data.timestamp ? new Date(data.timestamp) : new Date();
29
+ }
30
+ /**
31
+ * Check if the service is healthy.
32
+ * @returns True if the service is healthy
33
+ */
34
+ isHealthy() {
35
+ return this.healthy;
36
+ }
37
+ /**
38
+ * Get the service status.
39
+ * @returns The status string
40
+ */
41
+ getStatus() {
42
+ return this.status;
43
+ }
44
+ /**
45
+ * Get the response time in milliseconds.
46
+ * @returns The response time
47
+ */
48
+ getResponseTime() {
49
+ return this.responseTime;
50
+ }
51
+ /**
52
+ * Get any errors reported during the health check.
53
+ * @returns Array of error messages
54
+ */
55
+ getErrors() {
56
+ return this.errors;
57
+ }
58
+ /**
59
+ * Get the timestamp of the health check.
60
+ * @returns The timestamp
61
+ */
62
+ getTimestamp() {
63
+ return this.timestamp;
64
+ }
65
+ /**
66
+ * Check if there are any errors.
67
+ * @returns True if there are errors
68
+ */
69
+ hasErrors() {
70
+ return this.errors.length > 0;
71
+ }
72
+ /**
73
+ * Get a human-readable summary of the health check.
74
+ * @returns Summary string
75
+ */
76
+ getSummary() {
77
+ if (this.healthy) {
78
+ return `Service is healthy (${this.responseTime}ms response time)`;
79
+ }
80
+ else {
81
+ const errorCount = this.errors.length;
82
+ return `Service is unhealthy: ${this.status} (${errorCount} error${errorCount !== 1 ? 's' : ''})`;
83
+ }
84
+ }
85
+ /**
86
+ * Convert to a plain object.
87
+ * @returns Plain object representation
88
+ */
89
+ async toJSON() {
90
+ const obj = {
91
+ healthy: this.healthy,
92
+ status: this.status,
93
+ responseTime: this.responseTime,
94
+ errors: this.errors,
95
+ timestamp: this.timestamp.toISOString(),
96
+ };
97
+ validateJSON(obj, 'HealthCheck');
98
+ return obj;
99
+ }
100
+ /**
101
+ * Get a string representation.
102
+ * @returns String representation
103
+ */
104
+ toString() {
105
+ return `HealthCheck(${this.status}, healthy=${this.healthy}, responseTime=${this.responseTime}ms)`;
106
+ }
107
+ }
@@ -1,41 +1,4 @@
1
- /**
2
- * Represents a user in the Datalayer platform
3
- * @interface User
4
- */
5
- export interface User {
6
- /** Unique identifier for the user */
7
- id: string;
8
- /** Alternative unique identifier (UUID format) */
9
- uid?: string;
10
- /** User ID in the authentication system */
11
- user_id?: string;
12
- /** Username for login */
13
- username?: string;
14
- /** User's handle or nickname */
15
- handle?: string;
16
- /** User's email address */
17
- email: string;
18
- /** User's first name */
19
- first_name?: string;
20
- /** User's last name */
21
- last_name?: string;
22
- /** Display name shown in the UI */
23
- display_name?: string;
24
- /** URL to the user's avatar image */
25
- avatar_url?: string;
26
- /** Alternative property name for avatar URL (for backwards compatibility) */
27
- avatarUrl?: string;
28
- /** ISO 8601 timestamp of when the user was created */
29
- created_at?: string;
30
- /** ISO 8601 timestamp of when the user was last updated */
31
- updated_at?: string;
32
- /** Whether the user account is active */
33
- is_active?: boolean;
34
- /** Whether the user's email has been verified */
35
- is_verified?: boolean;
36
- /** Whether multi-factor authentication is enabled */
37
- mfa_enabled?: boolean;
38
- }
1
+ import { Profile } from './Profile';
39
2
  /**
40
3
  * Request payload for user login
41
4
  * @interface LoginRequest
@@ -112,16 +75,18 @@ export interface UserMeResponse {
112
75
  uid: string;
113
76
  /** User handle (username) */
114
77
  handle: string;
115
- /** Email address of the user */
78
+ /** Email address of the user (may be empty string) */
116
79
  email: string;
117
- /** First name of the user */
80
+ /** First name of the user (may be empty string) */
118
81
  firstName: string;
119
- /** Last name of the user */
82
+ /** Last name of the user (may be empty string) */
120
83
  lastName: string;
121
- /** Avatar URL for the user */
84
+ /** Avatar URL for the user (may be empty string) */
122
85
  avatarUrl: string;
123
86
  /** Array of roles assigned to the user */
124
87
  roles: string[];
88
+ /** Allow additional fields that may come from the server */
89
+ [key: string]: any;
125
90
  };
126
91
  }
127
92
  /**
@@ -134,47 +99,19 @@ export interface WhoAmIResponse {
134
99
  /** Response message from the server */
135
100
  message: string;
136
101
  /** User profile information */
137
- profile: {
138
- /** ISO 8601 timestamp of when the user was created */
139
- creation_ts_dt: string;
140
- /** Unique identifier for the user */
141
- id: string;
142
- /** ISO 8601 timestamp of when the user requested to join */
143
- join_request_ts_dt: string | null;
144
- /** ISO 8601 timestamp of when the user joined */
145
- join_ts_dt: string;
146
- /** ISO 8601 timestamp of last update */
147
- last_update_ts_dt: string;
148
- /** Origin of the user account */
149
- origin_s: string;
150
- /** Type of the record */
151
- type_s: string;
152
- /** User ID */
153
- uid: string;
154
- /** Email address */
155
- email_s: string;
156
- /** First name */
157
- first_name_t: string;
158
- /** User handle */
159
- handle_s: string;
160
- /** Last name */
161
- last_name_t: string;
162
- };
102
+ profile: Profile;
163
103
  }
164
104
  /**
165
- * Response from the health check ping endpoint
166
- * @interface HealthzPingResponse
105
+ * Response from the /memberships endpoint
106
+ * @interface MembershipsResponse
167
107
  */
168
- export interface HealthzPingResponse {
108
+ export interface MembershipsResponse {
169
109
  /** Whether the request was successful */
170
110
  success: boolean;
171
111
  /** Response message from the server */
172
112
  message: string;
173
- /** Service status information */
174
- status: {
175
- /** Status indicator (e.g., "OK") */
176
- status: string;
177
- };
178
- /** API version */
179
- version: string;
113
+ /** User profile information */
114
+ profile: Profile;
115
+ /** Memberships information */
116
+ memberships: any[];
180
117
  }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Abstract base class for all Datalayer content items.
3
+ *
4
+ * @module models/ItemDTO
5
+ */
6
+ import type { DatalayerClient } from '../index';
7
+ /**
8
+ * Abstract base class for all Datalayer content items.
9
+ * Provides common functionality for content management including lifecycle tracking.
10
+ *
11
+ * @template TData - Raw data type from API
12
+ * @template TUpdateRequest - Update request type for API
13
+ */
14
+ export declare abstract class ItemDTO<TData> {
15
+ protected _data: TData;
16
+ private _sdk;
17
+ private _deleted;
18
+ /**
19
+ * Create an Item instance.
20
+ * @param data - Item data from API
21
+ * @param sdk - SDK instance
22
+ */
23
+ constructor(data: TData, sdk: DatalayerClient);
24
+ /** Check if this item has been deleted. */
25
+ get isDeleted(): boolean;
26
+ /**
27
+ * Check if this item has been deleted and throw error if so.
28
+ * @throws Error if deleted
29
+ */
30
+ protected _checkDeleted(): void;
31
+ /** Item ID. */
32
+ get id(): string;
33
+ /** Unique identifier for the item. */
34
+ get uid(): string;
35
+ /** Parent space ID. */
36
+ get spaceId(): string;
37
+ /** Owner user ID. */
38
+ get ownerId(): string;
39
+ /** When the item was created. */
40
+ get createdAt(): Date;
41
+ /** The cached update time. */
42
+ get updatedAt(): Date;
43
+ /** Get the item type identifier. */
44
+ abstract get type(): string;
45
+ /** The cached name. */
46
+ abstract get name(): string;
47
+ /** Get the current name from API. */
48
+ abstract getName(): Promise<string>;
49
+ /** The cached content. */
50
+ abstract get content(): any;
51
+ /** Get when the item was last updated from API. */
52
+ abstract getUpdatedAt(): Promise<Date>;
53
+ /** Update the item. */
54
+ abstract update(...args: any[]): Promise<this>;
55
+ /**
56
+ * Delete this item permanently.
57
+ * After deletion, all subsequent method calls will throw errors.
58
+ */
59
+ delete(): Promise<void>;
60
+ /** Get the document content from API. */
61
+ getContent(): Promise<any>;
62
+ /** Get raw item data object. */
63
+ rawData(): TData;
64
+ /** Convert to JSON representation - must be implemented by subclasses. */
65
+ abstract toJSON(): any;
66
+ /** String representation of the item. */
67
+ toString(): string;
68
+ /** Get SDK token for API calls. */
69
+ protected _getToken(): string;
70
+ /** Get spacer API URL for API calls. */
71
+ protected _getSpacerRunUrl(): string;
72
+ /** Update internal data after API call. */
73
+ protected _updateData(newData: TData): void;
74
+ }