@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,239 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /**
6
+ * Space domain model for the Datalayer SDK.
7
+ *
8
+ * @module models/SpaceDTO
9
+ */
10
+ import * as users from '../api/spacer/users';
11
+ import * as items from '../api/spacer/items';
12
+ import * as notebooks from '../api/spacer/notebooks';
13
+ import * as lexicals from '../api/spacer/lexicals';
14
+ import { NotebookDTO } from './NotebookDTO';
15
+ import { LexicalDTO } from './LexicalDTO';
16
+ import { ItemTypes } from '../client/constants';
17
+ import { convertSpaceItemsToModels } from '../client/utils/spacerUtils';
18
+ import { validateJSON } from '../api/utils/validation';
19
+ /**
20
+ * Space domain model that wraps API responses with convenient methods.
21
+ * Provides workspace management with data refresh and content creation operations.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const space = spaces[0];
26
+ * const items = await space.getItems();
27
+ * const notebook = await space.createNotebook({ name: 'Analysis' });
28
+ * ```
29
+ */
30
+ export class SpaceDTO {
31
+ _data;
32
+ _sdk;
33
+ _items = null;
34
+ _deleted = false;
35
+ /**
36
+ * Create a Space instance.
37
+ *
38
+ * @param data - Space data from API
39
+ * @param sdk - SDK instance
40
+ */
41
+ constructor(data, sdk) {
42
+ this._data = data;
43
+ this._sdk = sdk;
44
+ }
45
+ // ========================================================================
46
+ // Helper Methods
47
+ // ========================================================================
48
+ /**
49
+ * Check if this space has been deleted and throw error if so.
50
+ * @throws Error if deleted
51
+ */
52
+ _checkDeleted() {
53
+ if (this._deleted) {
54
+ throw new Error(`Space ${this._data.uid} has been deleted and no longer exists`);
55
+ }
56
+ }
57
+ /**
58
+ * Refresh space data from the API by fetching user's spaces.
59
+ */
60
+ async refresh() {
61
+ const token = this._sdk.getToken();
62
+ const spacerRunUrl = this._sdk.getSpacerRunUrl();
63
+ const response = await users.getMySpaces(token, spacerRunUrl);
64
+ const freshSpace = response.spaces.find(s => s.uid === this.uid);
65
+ if (freshSpace) {
66
+ this._data = freshSpace;
67
+ }
68
+ }
69
+ // ========================================================================
70
+ // Static Properties (set at creation, never change)
71
+ // ========================================================================
72
+ /** Unique identifier for the space. */
73
+ get uid() {
74
+ this._checkDeleted();
75
+ return this._data.uid;
76
+ }
77
+ /** URL-friendly handle for the space. */
78
+ get handle() {
79
+ this._checkDeleted();
80
+ return this._data.handle_s;
81
+ }
82
+ /** Space variant type. */
83
+ get variant() {
84
+ this._checkDeleted();
85
+ return this._data.variant_s;
86
+ }
87
+ /**
88
+ * The name of the space.
89
+ */
90
+ get name() {
91
+ return this._data.name_t;
92
+ }
93
+ /**
94
+ * The description of the space.
95
+ */
96
+ get description() {
97
+ return this._data.description_t;
98
+ }
99
+ // ========================================================================
100
+ // Space-specific Methods
101
+ // ========================================================================
102
+ /**
103
+ * Helper method to create items in this space.
104
+ *
105
+ * @param itemType - Type of item to create
106
+ * @param data - Creation configuration
107
+ * @returns Created model instance
108
+ * @internal
109
+ */
110
+ async _createItem(data) {
111
+ this._checkDeleted();
112
+ // Get necessary configuration from SDK
113
+ const token = this._sdk.getToken();
114
+ const spacerRunUrl = this._sdk.getSpacerRunUrl();
115
+ if (data.type === ItemTypes.NOTEBOOK) {
116
+ const requestData = {
117
+ spaceId: this.uid,
118
+ name: data.name,
119
+ description: data.description,
120
+ notebookType: data.type,
121
+ file: data.file,
122
+ };
123
+ const response = await notebooks.createNotebook(token, requestData, spacerRunUrl);
124
+ if (!response.notebook) {
125
+ throw new Error('Failed to create notebook: No notebook returned');
126
+ }
127
+ else {
128
+ return new NotebookDTO(response.notebook, this._sdk);
129
+ }
130
+ }
131
+ else if (data.type === ItemTypes.LEXICAL) {
132
+ const requestData = {
133
+ spaceId: this.uid,
134
+ name: data.name,
135
+ description: data.description,
136
+ documentType: data.type,
137
+ file: data.file,
138
+ };
139
+ const response = await lexicals.createLexical(token, requestData, spacerRunUrl);
140
+ if (!response.document) {
141
+ throw new Error('Failed to create lexical document: No document returned');
142
+ }
143
+ else {
144
+ return new LexicalDTO(response.document, this._sdk);
145
+ }
146
+ }
147
+ else {
148
+ throw new Error(`Unsupported item type: ${data.type}`);
149
+ }
150
+ }
151
+ /**
152
+ * Get all items in this space as model instances.
153
+ *
154
+ * @returns Array of Notebook and Lexical model instances
155
+ */
156
+ async getItems() {
157
+ this._checkDeleted();
158
+ const token = this._sdk.getToken();
159
+ const spacerRunUrl = this._sdk.getSpacerRunUrl();
160
+ const response = await items.getSpaceItems(token, this.uid, spacerRunUrl);
161
+ // Use shared utility function to convert items to model instances
162
+ this._items = convertSpaceItemsToModels(response.items || [], this._sdk);
163
+ return this._items;
164
+ }
165
+ /**
166
+ * Create a new notebook in this space.
167
+ *
168
+ * @param data - Notebook creation configuration
169
+ * @returns Created Notebook instance
170
+ */
171
+ async createNotebook(data) {
172
+ return this._createItem({
173
+ name: data.name,
174
+ type: ItemTypes.NOTEBOOK,
175
+ description: data.description,
176
+ file: data.file,
177
+ });
178
+ }
179
+ /**
180
+ * Create a new lexical document in this space.
181
+ *
182
+ * @param data - Lexical creation configuration
183
+ * @returns Created Lexical instance
184
+ */
185
+ async createLexical(data) {
186
+ return this._createItem({
187
+ name: data.name,
188
+ type: ItemTypes.LEXICAL,
189
+ description: data.description,
190
+ file: data.file,
191
+ });
192
+ }
193
+ // ========================================================================
194
+ // Utility Methods
195
+ // ========================================================================
196
+ /**
197
+ * Get raw space data object.
198
+ * Returns cached data without refreshing.
199
+ *
200
+ * @returns Raw space data object
201
+ */
202
+ /**
203
+ * Get space data in camelCase format.
204
+ * Returns only the core fields that consumers need.
205
+ * This provides a stable interface regardless of API changes.
206
+ *
207
+ * @returns Core space data with camelCase properties
208
+ */
209
+ toJSON() {
210
+ this._checkDeleted();
211
+ const obj = {
212
+ uid: this.uid,
213
+ name: this.name,
214
+ description: this.description,
215
+ variant: this.variant,
216
+ handle: this.handle,
217
+ items: this._data.items
218
+ ? convertSpaceItemsToModels(this._data.items, this._sdk).map(item => item.toJSON())
219
+ : [],
220
+ };
221
+ validateJSON(obj, 'Space');
222
+ return obj;
223
+ }
224
+ /**
225
+ * Get the raw space data exactly as received from the API.
226
+ * This preserves the original snake_case naming from the API response.
227
+ *
228
+ * @returns Raw space data from API
229
+ */
230
+ rawData() {
231
+ this._checkDeleted();
232
+ return this._data;
233
+ }
234
+ /** String representation of the space. */
235
+ toString() {
236
+ this._checkDeleted();
237
+ return `Space(${this.uid}, ${this.name})`;
238
+ }
239
+ }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * User model for the Datalayer SDK with rich functionality.
3
+ *
4
+ * @module models/UserDTO
5
+ */
6
+ import type { DatalayerClient } from '../index';
7
+ /**
8
+ * Represents a user in the Datalayer platform
9
+ * @interface UserData
10
+ */
11
+ export interface UserData {
12
+ /** uuid for the user */
13
+ id: string;
14
+ /** ulid for the user */
15
+ uid: string;
16
+ /** User's handle or nickname */
17
+ handle_s: string;
18
+ /** User's email address */
19
+ email_s: string;
20
+ /** User's first name */
21
+ first_name_t: string;
22
+ /** User's last name */
23
+ last_name_t: string;
24
+ /** Display name shown in the UI */
25
+ avatar_url_s: string;
26
+ /** Additional fields that may be present in the response */
27
+ [key: string]: any;
28
+ }
29
+ export interface UserJSON {
30
+ /** uuid for the user */
31
+ id: string;
32
+ /** ulid for the user */
33
+ uid: string;
34
+ /** First name of the user */
35
+ firstName: string;
36
+ /** Last name of the user */
37
+ lastName: string;
38
+ /** Display name of the user */
39
+ displayName: string;
40
+ /** Email address of the user */
41
+ email: string;
42
+ /** Description of the user */
43
+ handle: string;
44
+ /** URL to the user's avatar image */
45
+ avatarUrl: string;
46
+ }
47
+ /**
48
+ * User model representing a Datalayer platform user.
49
+ * Provides rich functionality for accessing user data and authentication providers.
50
+ */
51
+ export declare class UserDTO {
52
+ protected _data: UserData;
53
+ /**
54
+ * Create a User instance.
55
+ *
56
+ * @param data - User data from API
57
+ * @param sdk - SDK instance (currently unused but kept for compatibility)
58
+ */
59
+ constructor(data: UserData, sdk?: DatalayerClient);
60
+ get id(): string;
61
+ get uid(): string;
62
+ get email(): string;
63
+ get handle(): string;
64
+ get firstName(): string;
65
+ get lastName(): string;
66
+ get displayName(): string;
67
+ get avatarUrl(): string;
68
+ /**
69
+ * Get user data in camelCase format.
70
+ * Returns only the core fields that consumers need.
71
+ * This provides a stable interface regardless of API changes.
72
+ *
73
+ * @returns Core user data with camelCase properties
74
+ */
75
+ toJSON(): UserJSON;
76
+ /**
77
+ * Get the raw user data exactly as received from the API.
78
+ * This preserves the original snake_case naming from the API response.
79
+ *
80
+ * @returns Raw user data from API
81
+ */
82
+ rawData(): UserData;
83
+ /** String representation of the user. */
84
+ toString(): string;
85
+ }
86
+ export default UserDTO;
@@ -0,0 +1,84 @@
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
+ * User model representing a Datalayer platform user.
8
+ * Provides rich functionality for accessing user data and authentication providers.
9
+ */
10
+ export class UserDTO {
11
+ _data;
12
+ /**
13
+ * Create a User instance.
14
+ *
15
+ * @param data - User data from API
16
+ * @param sdk - SDK instance (currently unused but kept for compatibility)
17
+ */
18
+ constructor(data, sdk) {
19
+ this._data = data;
20
+ }
21
+ // Basic properties
22
+ get id() {
23
+ return this._data.id;
24
+ }
25
+ get uid() {
26
+ return this._data.uid;
27
+ }
28
+ get email() {
29
+ return this._data.email_s;
30
+ }
31
+ get handle() {
32
+ return this._data.handle_s;
33
+ }
34
+ get firstName() {
35
+ return this._data.first_name_t;
36
+ }
37
+ get lastName() {
38
+ return this._data.last_name_t;
39
+ }
40
+ get displayName() {
41
+ return `${this.firstName} ${this.lastName}`.trim();
42
+ }
43
+ get avatarUrl() {
44
+ return this._data.avatar_url_s;
45
+ }
46
+ // ========================================================================
47
+ // Utility Methods
48
+ // ========================================================================
49
+ /**
50
+ * Get user data in camelCase format.
51
+ * Returns only the core fields that consumers need.
52
+ * This provides a stable interface regardless of API changes.
53
+ *
54
+ * @returns Core user data with camelCase properties
55
+ */
56
+ toJSON() {
57
+ const obj = {
58
+ id: this.id,
59
+ uid: this.uid,
60
+ firstName: this.firstName,
61
+ lastName: this.lastName,
62
+ displayName: this.displayName,
63
+ email: this.email,
64
+ handle: this.handle,
65
+ avatarUrl: this.avatarUrl,
66
+ };
67
+ validateJSON(obj, 'User');
68
+ return obj;
69
+ }
70
+ /**
71
+ * Get the raw user data exactly as received from the API.
72
+ * This preserves the original snake_case naming from the API response.
73
+ *
74
+ * @returns Raw user data from API
75
+ */
76
+ rawData() {
77
+ return this._data;
78
+ }
79
+ /** String representation of the user. */
80
+ toString() {
81
+ return `User(${this.uid}, ${this.displayName})`;
82
+ }
83
+ }
84
+ export default UserDTO;
@@ -1,9 +1,40 @@
1
+ /**
2
+ * Models definitions for all Datalayer API services.
3
+ *
4
+ * This module consolidates all type definitions used by the SDK, providing
5
+ * comprehensive TypeScript support for requests, responses, and data models
6
+ * across all Datalayer services.
7
+ *
8
+ * These types follow the exact backend API format (snake_case naming) to
9
+ * ensure compatibility. For frontend business logic types with camelCase
10
+ * naming, see the models in `/src/models/`.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import type {
15
+ * Runtime,
16
+ * Environment,
17
+ * Space,
18
+ * Notebook,
19
+ * User,
20
+ * LoginRequest
21
+ * } from '@datalayer/core/api/types';
22
+ *
23
+ * // Use types for function parameters and return values
24
+ * function createRuntime(config: CreateRuntimeRequest): Promise<Runtime> {
25
+ * // Implementation
26
+ * }
27
+ * ```
28
+ *
29
+ * @module models
30
+ */
1
31
  export * from './AIAgent';
2
- export * from './Base';
3
32
  export * from './Assignment';
33
+ export * from './Base';
4
34
  export * from './Cell';
5
35
  export * from './CodeBlock';
6
36
  export * from './CodefeedBlocks';
37
+ export * from './Common';
7
38
  export * from './Contact';
8
39
  export * from './ContactEvent';
9
40
  export * from './ContactIAMProvider';
@@ -11,29 +42,35 @@ export * from './ContactTags';
11
42
  export * from './Content';
12
43
  export * from './Course';
13
44
  export * from './Credits';
14
- export * from './Datasource';
45
+ export * from './CreditsDTO';
15
46
  export * from './Dataset';
47
+ export * from './Datasource';
16
48
  export * from './Dean';
17
49
  export * from './Document';
18
50
  export * from './Environment';
51
+ export * from './EnvironmentDTO';
19
52
  export * from './Errors';
20
53
  export * from './Exercise';
21
54
  export * from './GrowthKPI';
55
+ export * from './IAM';
22
56
  export * from './IAMProviderLinked';
23
57
  export * from './IAMProviderPost';
24
- export * from './IAMProvidersSpecs';
25
58
  export * from './IAMProviderUsers';
26
- export * from './Instructor';
59
+ export * from './IAMProvidersSpecs';
27
60
  export * from './IAMToken';
28
61
  export * from './Inbound';
62
+ export * from './Instructor';
29
63
  export * from './Invite';
30
64
  export * from './Item';
65
+ export * from './ItemDTO';
31
66
  export * from './ItemType';
32
67
  export * from './LandingRoles';
33
68
  export * from './Lesson';
69
+ export * from './LexicalDTO';
34
70
  export * from './Library';
35
71
  export * from './Member';
36
72
  export * from './Notebook';
73
+ export * from './NotebookDTO';
37
74
  export * from './Organization';
38
75
  export * from './OrganizationMember';
39
76
  export * from './Outbound';
@@ -45,10 +82,13 @@ export * from './RolesOrganization';
45
82
  export * from './RolesPlatform';
46
83
  export * from './RolesTeam';
47
84
  export * from './Runtime';
85
+ export * from './RuntimeDTO';
48
86
  export * from './RuntimeSnapshot';
87
+ export * from './RuntimeSnapshotDTO';
49
88
  export * from './School';
50
89
  export * from './Secret';
51
90
  export * from './Space';
91
+ export * from './SpaceDTO';
52
92
  export * from './SpaceItem';
53
93
  export * from './SpaceMember';
54
94
  export * from './Student';
@@ -59,6 +99,7 @@ export * from './TeamMember';
59
99
  export * from './URN';
60
100
  export * from './Usage';
61
101
  export * from './User';
102
+ export * from './UserDTO';
62
103
  export * from './UserEvent';
63
104
  export * from './UserOnboarding';
64
105
  export * from './UserSettings';
@@ -2,12 +2,43 @@
2
2
  * Copyright (c) 2023-2025 Datalayer, Inc.
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
+ /**
6
+ * Models definitions for all Datalayer API services.
7
+ *
8
+ * This module consolidates all type definitions used by the SDK, providing
9
+ * comprehensive TypeScript support for requests, responses, and data models
10
+ * across all Datalayer services.
11
+ *
12
+ * These types follow the exact backend API format (snake_case naming) to
13
+ * ensure compatibility. For frontend business logic types with camelCase
14
+ * naming, see the models in `/src/models/`.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import type {
19
+ * Runtime,
20
+ * Environment,
21
+ * Space,
22
+ * Notebook,
23
+ * User,
24
+ * LoginRequest
25
+ * } from '@datalayer/core/api/types';
26
+ *
27
+ * // Use types for function parameters and return values
28
+ * function createRuntime(config: CreateRuntimeRequest): Promise<Runtime> {
29
+ * // Implementation
30
+ * }
31
+ * ```
32
+ *
33
+ * @module models
34
+ */
5
35
  export * from './AIAgent';
6
- export * from './Base';
7
36
  export * from './Assignment';
37
+ export * from './Base';
8
38
  export * from './Cell';
9
39
  export * from './CodeBlock';
10
40
  export * from './CodefeedBlocks';
41
+ export * from './Common';
11
42
  export * from './Contact';
12
43
  export * from './ContactEvent';
13
44
  export * from './ContactIAMProvider';
@@ -15,29 +46,35 @@ export * from './ContactTags';
15
46
  export * from './Content';
16
47
  export * from './Course';
17
48
  export * from './Credits';
18
- export * from './Datasource';
49
+ export * from './CreditsDTO';
19
50
  export * from './Dataset';
51
+ export * from './Datasource';
20
52
  export * from './Dean';
21
53
  export * from './Document';
22
54
  export * from './Environment';
55
+ export * from './EnvironmentDTO';
23
56
  export * from './Errors';
24
57
  export * from './Exercise';
25
58
  export * from './GrowthKPI';
59
+ export * from './IAM';
26
60
  export * from './IAMProviderLinked';
27
61
  export * from './IAMProviderPost';
28
- export * from './IAMProvidersSpecs';
29
62
  export * from './IAMProviderUsers';
30
- export * from './Instructor';
63
+ export * from './IAMProvidersSpecs';
31
64
  export * from './IAMToken';
32
65
  export * from './Inbound';
66
+ export * from './Instructor';
33
67
  export * from './Invite';
34
68
  export * from './Item';
69
+ export * from './ItemDTO';
35
70
  export * from './ItemType';
36
71
  export * from './LandingRoles';
37
72
  export * from './Lesson';
73
+ export * from './LexicalDTO';
38
74
  export * from './Library';
39
75
  export * from './Member';
40
76
  export * from './Notebook';
77
+ export * from './NotebookDTO';
41
78
  export * from './Organization';
42
79
  export * from './OrganizationMember';
43
80
  export * from './Outbound';
@@ -49,10 +86,13 @@ export * from './RolesOrganization';
49
86
  export * from './RolesPlatform';
50
87
  export * from './RolesTeam';
51
88
  export * from './Runtime';
89
+ export * from './RuntimeDTO';
52
90
  export * from './RuntimeSnapshot';
91
+ export * from './RuntimeSnapshotDTO';
53
92
  export * from './School';
54
93
  export * from './Secret';
55
94
  export * from './Space';
95
+ export * from './SpaceDTO';
56
96
  export * from './SpaceItem';
57
97
  export * from './SpaceMember';
58
98
  export * from './Student';
@@ -63,6 +103,7 @@ export * from './TeamMember';
63
103
  export * from './URN';
64
104
  export * from './Usage';
65
105
  export * from './User';
106
+ export * from './UserDTO';
66
107
  export * from './UserEvent';
67
108
  export * from './UserOnboarding';
68
109
  export * from './UserSettings';
@@ -1,6 +1,5 @@
1
1
  /**
2
- * @module sdk
3
- * @description Main SDK entry point for the Datalayer platform.
2
+ * Main SDK entry point for the Datalayer platform.
4
3
  *
5
4
  * This module provides the unified DatalayerSDK class with a flat, intuitive API
6
5
  * for all Datalayer platform services. The SDK uses TypeScript mixins to provide
@@ -21,6 +20,8 @@
21
20
  * const runtime = await sdk.createRuntime(config);
22
21
  * const notebook = await sdk.createNotebook(data);
23
22
  * ```
23
+ *
24
+ * @module sdk
24
25
  */
25
- export { DatalayerSDK, type DatalayerSDKConfig } from './client';
26
- export * from './stateful';
26
+ export { DatalayerClient, type DatalayerClientConfig } from '../client';
27
+ export * from '../stateful';
package/lib/sdk/index.js CHANGED
@@ -3,8 +3,7 @@
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
  /**
6
- * @module sdk
7
- * @description Main SDK entry point for the Datalayer platform.
6
+ * Main SDK entry point for the Datalayer platform.
8
7
  *
9
8
  * This module provides the unified DatalayerSDK class with a flat, intuitive API
10
9
  * for all Datalayer platform services. The SDK uses TypeScript mixins to provide
@@ -25,8 +24,10 @@
25
24
  * const runtime = await sdk.createRuntime(config);
26
25
  * const notebook = await sdk.createNotebook(data);
27
26
  * ```
27
+ *
28
+ * @module sdk
28
29
  */
29
- // Export the main SDK class with flat API
30
- export { DatalayerSDK } from './client';
30
+ // Export the main Client class with flat API
31
+ export { DatalayerClient } from '../client';
31
32
  // Export stateful modules for advanced use cases
32
- export * from './stateful';
33
+ export * from '../stateful';
@@ -5,7 +5,7 @@
5
5
  import { ServerConnection, ServiceManager } from '@jupyterlab/services';
6
6
  import { coreStore } from '../state/substates/CoreState';
7
7
  import { DEFAULT_DATALAYER_CONFIG } from '../config/Configuration';
8
- import { createRuntime } from '../sdk/stateful/runtimes/actions';
8
+ import { createRuntime } from '../stateful/runtimes/actions';
9
9
  /**
10
10
  * Creates a ServiceManager configured for Datalayer.
11
11
  *
@@ -21,6 +21,8 @@ let initialConfiguration = {
21
21
  libraryRunUrl: 'https://prod1.datalayer.run',
22
22
  spacerRunUrl: 'https://prod1.datalayer.run',
23
23
  aiagentsRunUrl: 'https://prod1.datalayer.run',
24
+ aiinferenceRunUrl: 'https://prod1.datalayer.run',
25
+ mcpserversRunUrl: 'https://prod1.datalayer.run',
24
26
  growthRunUrl: 'https://prod1.datalayer.run',
25
27
  inboundsRunUrl: 'https://prod1.datalayer.run',
26
28
  successRunUrl: 'https://prod1.datalayer.run',
@@ -1,4 +1,4 @@
1
- import type { IMultiServiceManager } from '../../sdk/stateful/runtimes';
1
+ import type { IMultiServiceManager } from '../../stateful/runtimes';
2
2
  import type { IRuntimesConfiguration } from '../../config';
3
3
  import type { IRuntimePod, IRuntimeSnapshot, IRuntimeModel } from '../../models';
4
4
  /**