@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
@@ -3,27 +3,14 @@
3
3
  * @interface Space
4
4
  */
5
5
  export interface Space {
6
- id?: string;
7
6
  uid: string;
8
- name?: string;
9
- name_t?: string;
10
- handle_s?: string;
11
- variant_s?: string;
12
- description?: string;
13
- description_t?: string;
14
- visibility?: 'public' | 'private' | 'organization';
15
- owner_id?: string;
16
- organization_id?: string;
17
- created_at?: string;
18
- updated_at?: string;
19
- creation_ts_dt?: string;
20
- last_update_ts_dt?: string;
21
- notebooks_count?: number;
22
- members_count?: number;
23
- tags?: string[];
7
+ name_t: string;
8
+ handle_s: string;
9
+ variant_s: string;
10
+ description_t: string;
24
11
  tags_ss?: string[];
25
- items?: any[];
26
12
  members?: any[];
13
+ items?: any[];
27
14
  }
28
15
  /**
29
16
  * Represents a Jupyter notebook document
@@ -32,46 +19,13 @@ export interface Space {
32
19
  export interface Notebook {
33
20
  id: string;
34
21
  uid: string;
35
- name?: string;
36
- name_t?: string;
37
- path?: string;
38
- content?: any;
39
- space_id?: string;
40
- owner_id?: string;
41
- creator_uid?: string;
42
- creator_handle_s?: string;
43
- created_at?: string;
44
- creation_ts_dt?: string;
45
- updated_at?: string;
46
- last_update_ts_dt?: string;
47
- version?: number;
48
- kernel_spec?: any;
49
- metadata?: Record<string, any>;
50
- type_s?: string;
51
- public_b?: boolean;
52
- description_t?: string;
53
- notebook_name_s?: string;
54
- notebook_extension_s?: string;
55
- notebook_format_s?: string;
56
- content_length_i?: number;
57
- content_type_s?: string;
58
- mime_type_s?: string;
59
- s3_path_s?: string;
60
- s3_url_s?: string;
61
- cdn_url_s?: string;
62
- model_s?: string;
63
- }
64
- /**
65
- * Represents a single cell in a Jupyter notebook
66
- * @interface Cell
67
- */
68
- export interface Cell {
69
- id: string;
70
- cell_type: 'code' | 'markdown' | 'raw';
71
- source: string | string[];
72
- outputs?: any[];
73
- execution_count?: number | null;
74
- metadata?: Record<string, any>;
22
+ name_t: string;
23
+ description_t: string;
24
+ type_s: string;
25
+ notebook_extension_s: string;
26
+ s3_path_s: string;
27
+ s3_url_s: string;
28
+ cdn_url_s: string;
75
29
  }
76
30
  /**
77
31
  * Request payload for creating a new space
@@ -86,6 +40,15 @@ export interface CreateSpaceRequest {
86
40
  seedSpaceId: string;
87
41
  public: boolean;
88
42
  }
43
+ /**
44
+ * Response from getting a collaboration session ID
45
+ * @interface CollaborationSessionResponse
46
+ */
47
+ export interface CollaborationSessionResponse {
48
+ success: boolean;
49
+ sessionId?: string;
50
+ error?: string;
51
+ }
89
52
  /**
90
53
  * Response from creating a space
91
54
  * @interface CreateSpaceResponse
@@ -93,7 +56,7 @@ export interface CreateSpaceRequest {
93
56
  export interface CreateSpaceResponse {
94
57
  success: boolean;
95
58
  message: string;
96
- space: Space;
59
+ space?: Space;
97
60
  }
98
61
  /**
99
62
  * Request payload for creating a new notebook (multipart/form-data)
@@ -113,7 +76,7 @@ export interface CreateNotebookRequest {
113
76
  export interface CreateNotebookResponse {
114
77
  success: boolean;
115
78
  message: string;
116
- notebook: Notebook;
79
+ notebook?: Notebook;
117
80
  }
118
81
  /**
119
82
  * Response from getting a notebook
@@ -150,7 +113,7 @@ export interface UpdateNotebookRequest {
150
113
  export interface UpdateNotebookResponse {
151
114
  success: boolean;
152
115
  message: string;
153
- notebook: Notebook;
116
+ notebook?: Notebook;
154
117
  }
155
118
  /**
156
119
  * Represents an item within a space
@@ -158,7 +121,7 @@ export interface UpdateNotebookResponse {
158
121
  */
159
122
  export interface SpaceItem {
160
123
  id: string;
161
- type: 'notebook' | 'lexical' | 'cell';
124
+ type_s: 'notebook' | 'lexical';
162
125
  space_id: string;
163
126
  item_id: string;
164
127
  name: string;
@@ -183,18 +146,18 @@ export interface Lexical {
183
146
  creation_ts_dt?: string;
184
147
  updated_at?: string;
185
148
  last_update_ts_dt?: string;
149
+ cdn_url_s: string;
186
150
  type_s?: string;
187
151
  public_b?: boolean;
188
152
  description_t?: string;
189
153
  document_name_s?: string;
190
- document_extension_s?: string;
154
+ document_extension_s: string;
191
155
  document_format_s?: string;
192
156
  content_length_i?: number;
193
157
  content_type_s?: string;
194
158
  mime_type_s?: string;
195
159
  s3_path_s?: string;
196
160
  s3_url_s?: string;
197
- cdn_url_s?: string;
198
161
  model_s?: string;
199
162
  }
200
163
  /**
@@ -215,7 +178,7 @@ export interface CreateLexicalRequest {
215
178
  export interface CreateLexicalResponse {
216
179
  success: boolean;
217
180
  message: string;
218
- document: Lexical;
181
+ document?: Lexical;
219
182
  }
220
183
  /**
221
184
  * Response from getting a Lexical document
@@ -260,6 +223,15 @@ export interface DeleteSpaceItemResponse {
260
223
  success: boolean;
261
224
  message: string;
262
225
  }
226
+ /**
227
+ * Response from getting a single space item
228
+ * @interface GetSpaceItemResponse
229
+ */
230
+ export interface GetSpaceItemResponse {
231
+ success: boolean;
232
+ message: string;
233
+ item?: any;
234
+ }
263
235
  /**
264
236
  * Response from getting spaces for a user
265
237
  * @interface SpacesForUserResponse
@@ -1,6 +1,7 @@
1
1
  /**
2
+ * Utility functions for API parameter validation
3
+ *
2
4
  * @module api/utils/validation
3
- * @description Utility functions for API parameter validation
4
5
  */
5
6
  /**
6
7
  * Validates that an authentication token is provided and is a valid JWT format
@@ -22,3 +23,25 @@ export declare const validateRequired: (value: any, paramName: string) => void;
22
23
  * @throws {Error} If the value is missing, null, undefined, or empty/whitespace
23
24
  */
24
25
  export declare const validateRequiredString: (value: string | undefined | null, paramName: string) => void;
26
+ /**
27
+ * Validates that all properties in an object are defined (not undefined).
28
+ * Recursively checks nested objects and arrays to ensure complete data integrity.
29
+ * This is used to validate model toJSON() outputs and ensure SDK contract compliance.
30
+ *
31
+ * @param obj - The object to validate
32
+ * @param modelName - Name of the model class for error messages (e.g., 'Runtime')
33
+ * @param path - Current property path for recursive validation (internal use)
34
+ * @throws {Error} If any property value is undefined, with full path to the undefined property
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const runtimeData = {
39
+ * uid: 'abc123',
40
+ * podName: 'my-pod',
41
+ * environmentName: undefined // This will throw
42
+ * };
43
+ * validateJSON(runtimeData, 'Runtime');
44
+ * // Error: Runtime.toJSON(): Property 'environmentName' is undefined
45
+ * ```
46
+ */
47
+ export declare const validateJSON: (obj: Record<string, any>, modelName: string, path?: string) => void;
@@ -3,8 +3,9 @@
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
  /**
6
+ * Utility functions for API parameter validation
7
+ *
6
8
  * @module api/utils/validation
7
- * @description Utility functions for API parameter validation
8
9
  */
9
10
  /**
10
11
  * Validates that an authentication token is provided and is a valid JWT format
@@ -131,3 +132,63 @@ export const validateRequiredString = (value, paramName) => {
131
132
  throw new Error(`${paramName} is required`);
132
133
  }
133
134
  };
135
+ /**
136
+ * Validates that all properties in an object are defined (not undefined).
137
+ * Recursively checks nested objects and arrays to ensure complete data integrity.
138
+ * This is used to validate model toJSON() outputs and ensure SDK contract compliance.
139
+ *
140
+ * @param obj - The object to validate
141
+ * @param modelName - Name of the model class for error messages (e.g., 'Runtime')
142
+ * @param path - Current property path for recursive validation (internal use)
143
+ * @throws {Error} If any property value is undefined, with full path to the undefined property
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * const runtimeData = {
148
+ * uid: 'abc123',
149
+ * podName: 'my-pod',
150
+ * environmentName: undefined // This will throw
151
+ * };
152
+ * validateJSON(runtimeData, 'Runtime');
153
+ * // Error: Runtime.toJSON(): Property 'environmentName' is undefined
154
+ * ```
155
+ */
156
+ export const validateJSON = (obj, modelName, path = '') => {
157
+ // Iterate over all enumerable properties
158
+ for (const key in obj) {
159
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) {
160
+ continue;
161
+ }
162
+ const value = obj[key];
163
+ const currentPath = path ? `${path}.${key}` : key;
164
+ // Check if value is undefined - this is the error case
165
+ if (value === undefined) {
166
+ throw new Error(`${modelName}.toJSON(): Property '${currentPath}' is undefined`);
167
+ }
168
+ // Skip null, functions, and symbols - these are valid
169
+ if (value === null ||
170
+ typeof value === 'function' ||
171
+ typeof value === 'symbol') {
172
+ continue;
173
+ }
174
+ // Recursively validate arrays
175
+ if (Array.isArray(value)) {
176
+ value.forEach((item, index) => {
177
+ if (item === undefined) {
178
+ throw new Error(`${modelName}.toJSON(): Array element at '${currentPath}[${index}]' is undefined`);
179
+ }
180
+ // If array element is an object, recurse into it
181
+ if (item !== null && typeof item === 'object') {
182
+ validateJSON(item, modelName, `${currentPath}[${index}]`);
183
+ }
184
+ });
185
+ continue;
186
+ }
187
+ // Recursively validate nested objects
188
+ // Note: typeof null === 'object', but we already checked for null above
189
+ if (typeof value === 'object') {
190
+ validateJSON(value, modelName, currentPath);
191
+ }
192
+ // Primitives (string, number, boolean) are valid - no further checks needed
193
+ }
194
+ };
@@ -0,0 +1,75 @@
1
+ import { Environment } from './models/Environment';
2
+ /** Handlers for SDK method lifecycle events. */
3
+ export interface SDKHandlers {
4
+ /** Called before any SDK method execution */
5
+ beforeCall?: (methodName: string, args: any[]) => void | Promise<void>;
6
+ /** Called after successful SDK method execution */
7
+ afterCall?: (methodName: string, result: any) => void | Promise<void>;
8
+ /** Called when an SDK method throws an error */
9
+ onError?: (methodName: string, error: any) => void | Promise<void>;
10
+ }
11
+ /** Configuration options for the Datalayer Client. */
12
+ export interface DatalayerClientConfig {
13
+ /** Authentication token for API requests */
14
+ token?: string;
15
+ /** URL for the IAM service */
16
+ iamRunUrl?: string;
17
+ /** URL for the Runtimes service */
18
+ runtimesRunUrl?: string;
19
+ /** URL for the Spacer service */
20
+ spacerRunUrl?: string;
21
+ /** Handlers for intercepting SDK method calls */
22
+ handlers?: SDKHandlers;
23
+ }
24
+ /** Base Client class providing core configuration and token management. */
25
+ export declare class DatalayerClientBase {
26
+ /** URL for IAM service */
27
+ readonly iamRunUrl: string;
28
+ /** URL for Runtimes service */
29
+ readonly runtimesRunUrl: string;
30
+ /** URL for Spacer service */
31
+ readonly spacerRunUrl: string;
32
+ /** Authentication token */
33
+ token?: string;
34
+ /** Environments */
35
+ readonly environments: Environment[];
36
+ /** Method lifecycle handlers */
37
+ readonly handlers?: SDKHandlers;
38
+ /**
39
+ * Create a DatalayerClient base instance.
40
+ * @param config - Client configuration options
41
+ */
42
+ constructor(config: DatalayerClientConfig);
43
+ /**
44
+ * Get the current configuration including service URLs and token.
45
+ * @returns Current configuration
46
+ */
47
+ getConfig(): DatalayerClientConfig;
48
+ /** Get the IAM service URL. */
49
+ getIamRunUrl(): string;
50
+ /** Get the Runtimes service URL. */
51
+ getRuntimesRunUrl(): string;
52
+ /** Get the Spacer service URL. */
53
+ getSpacerRunUrl(): string;
54
+ /** Get the current authentication token. */
55
+ getToken(): string | undefined;
56
+ /**
57
+ * set the authentication token for all API requests.
58
+ * @param token - New authentication token
59
+ */
60
+ setToken(token: string): Promise<void>;
61
+ /**
62
+ * Wrap all SDK methods with handlers for cross-cutting concerns.
63
+ * Called automatically by the DatalayerClient constructor.
64
+ *
65
+ * @internal
66
+ */
67
+ protected wrapAllMethods(): void;
68
+ /**
69
+ * Get all method names from mixins only.
70
+ * @returns Array of mixin method names to wrap
71
+ * @internal
72
+ */
73
+ private getAllMethodNames;
74
+ calculateCreditsFromMinutes(minutes: number, burningRate: number): number;
75
+ }
@@ -0,0 +1,199 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /**
6
+ * Base SDK class providing core configuration and token management.
7
+ * @module client/base
8
+ */
9
+ import { DEFAULT_SERVICE_URLS } from '../api/constants';
10
+ /** Base Client class providing core configuration and token management. */
11
+ export class DatalayerClientBase {
12
+ /** URL for IAM service */
13
+ iamRunUrl;
14
+ /** URL for Runtimes service */
15
+ runtimesRunUrl;
16
+ /** URL for Spacer service */
17
+ spacerRunUrl;
18
+ /** Authentication token */
19
+ token;
20
+ /** Environments */
21
+ environments = [];
22
+ /** Method lifecycle handlers */
23
+ handlers;
24
+ /**
25
+ * Create a DatalayerClient base instance.
26
+ * @param config - Client configuration options
27
+ */
28
+ constructor(config) {
29
+ this.iamRunUrl = config.iamRunUrl || DEFAULT_SERVICE_URLS.IAM;
30
+ this.runtimesRunUrl =
31
+ config.runtimesRunUrl || DEFAULT_SERVICE_URLS.RUNTIMES;
32
+ this.spacerRunUrl = config.spacerRunUrl || DEFAULT_SERVICE_URLS.SPACER;
33
+ this.token = config.token;
34
+ this.handlers = config.handlers;
35
+ }
36
+ /**
37
+ * Get the current configuration including service URLs and token.
38
+ * @returns Current configuration
39
+ */
40
+ getConfig() {
41
+ return {
42
+ iamRunUrl: this.iamRunUrl,
43
+ runtimesRunUrl: this.runtimesRunUrl,
44
+ spacerRunUrl: this.spacerRunUrl,
45
+ token: this.token,
46
+ };
47
+ }
48
+ /** Get the IAM service URL. */
49
+ getIamRunUrl() {
50
+ return this.iamRunUrl;
51
+ }
52
+ /** Get the Runtimes service URL. */
53
+ getRuntimesRunUrl() {
54
+ return this.runtimesRunUrl;
55
+ }
56
+ /** Get the Spacer service URL. */
57
+ getSpacerRunUrl() {
58
+ return this.spacerRunUrl;
59
+ }
60
+ /** Get the current authentication token. */
61
+ getToken() {
62
+ return this.token;
63
+ }
64
+ /**
65
+ * set the authentication token for all API requests.
66
+ * @param token - New authentication token
67
+ */
68
+ async setToken(token) {
69
+ this.token = token;
70
+ }
71
+ /**
72
+ * Wrap all SDK methods with handlers for cross-cutting concerns.
73
+ * Called automatically by the DatalayerClient constructor.
74
+ *
75
+ * @internal
76
+ */
77
+ wrapAllMethods() {
78
+ if (!this.handlers) {
79
+ return; // No handlers configured, nothing to wrap
80
+ }
81
+ // Get all method names from the prototype chain
82
+ const methodNames = this.getAllMethodNames();
83
+ // Wrap each method with handlers
84
+ methodNames.forEach(methodName => {
85
+ const original = this[methodName];
86
+ if (typeof original !== 'function') {
87
+ return;
88
+ }
89
+ // Detect if the original method is async by checking if it's an AsyncFunction
90
+ const isAsync = original.constructor.name === 'AsyncFunction';
91
+ if (isAsync) {
92
+ // Create async wrapped version for originally async methods
93
+ this[methodName] = async (...args) => {
94
+ // Call beforeCall handler if defined
95
+ if (this.handlers?.beforeCall) {
96
+ await Promise.resolve(this.handlers.beforeCall(methodName, args));
97
+ }
98
+ try {
99
+ // Call the original async method
100
+ const result = await original.apply(this, args);
101
+ // Call afterCall handler if defined
102
+ if (this.handlers?.afterCall) {
103
+ await Promise.resolve(this.handlers.afterCall(methodName, result));
104
+ }
105
+ return result;
106
+ }
107
+ catch (error) {
108
+ // Call onError handler if defined
109
+ if (this.handlers?.onError) {
110
+ await Promise.resolve(this.handlers.onError(methodName, error));
111
+ }
112
+ throw error;
113
+ }
114
+ };
115
+ }
116
+ else {
117
+ // Create sync wrapped version for originally sync methods
118
+ this[methodName] = (...args) => {
119
+ // Call beforeCall handler if defined (sync version)
120
+ if (this.handlers?.beforeCall) {
121
+ const beforeResult = this.handlers.beforeCall(methodName, args);
122
+ // If beforeCall returns a Promise, we can't await it in sync context
123
+ if (beforeResult instanceof Promise) {
124
+ // Promise ignored in sync context
125
+ }
126
+ }
127
+ try {
128
+ // Call the original sync method
129
+ const result = original.apply(this, args);
130
+ // Call afterCall handler if defined (sync version)
131
+ if (this.handlers?.afterCall) {
132
+ const afterResult = this.handlers.afterCall(methodName, result);
133
+ if (afterResult instanceof Promise) {
134
+ // Promise ignored in sync context
135
+ }
136
+ }
137
+ return result;
138
+ }
139
+ catch (error) {
140
+ // Call onError handler if defined (sync version)
141
+ if (this.handlers?.onError) {
142
+ const errorResult = this.handlers.onError(methodName, error);
143
+ if (errorResult instanceof Promise) {
144
+ // Promise ignored in sync context
145
+ }
146
+ }
147
+ throw error;
148
+ }
149
+ };
150
+ }
151
+ });
152
+ }
153
+ /**
154
+ * Get all method names from mixins only.
155
+ * @returns Array of mixin method names to wrap
156
+ * @internal
157
+ */
158
+ getAllMethodNames() {
159
+ const methodNames = new Set();
160
+ // First, collect all base class methods to exclude
161
+ const baseClassMethods = new Set();
162
+ const basePrototype = DatalayerClientBase.prototype;
163
+ Object.getOwnPropertyNames(basePrototype).forEach(name => {
164
+ baseClassMethods.add(name);
165
+ });
166
+ // Also exclude methods from the concrete SDK class itself
167
+ const sdkPrototype = Object.getPrototypeOf(this).constructor.prototype;
168
+ Object.getOwnPropertyNames(sdkPrototype).forEach(name => {
169
+ baseClassMethods.add(name);
170
+ });
171
+ // Now walk the prototype chain and only include mixin methods
172
+ let obj = Object.getPrototypeOf(this);
173
+ while (obj && obj !== Object.prototype) {
174
+ const names = Object.getOwnPropertyNames(obj);
175
+ names.forEach(name => {
176
+ // Only include if:
177
+ // 1. Not a constructor
178
+ // 2. Not a private method (starts with _)
179
+ // 3. Not a base class method
180
+ // 4. Is actually a function
181
+ if (name !== 'constructor' &&
182
+ !name.startsWith('_') &&
183
+ !baseClassMethods.has(name)) {
184
+ const descriptor = Object.getOwnPropertyDescriptor(obj, name);
185
+ if (descriptor && typeof descriptor.value === 'function') {
186
+ methodNames.add(name);
187
+ }
188
+ }
189
+ });
190
+ obj = Object.getPrototypeOf(obj);
191
+ }
192
+ return Array.from(methodNames);
193
+ }
194
+ // Utility Methods
195
+ calculateCreditsFromMinutes(minutes, burningRate) {
196
+ const burningRatePerMinute = burningRate * 60;
197
+ return Math.ceil(minutes * burningRatePerMinute);
198
+ }
199
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Constants for the Datalayer SDK.
3
+ *
4
+ * @module client/constants
5
+ */
6
+ /**
7
+ * Item types used throughout the SDK and consuming applications.
8
+ * These constants define the type identifiers for different Datalayer items.
9
+ * Values match what the Datalayer API returns.
10
+ */
11
+ export declare const ItemTypes: {
12
+ readonly NOTEBOOK: "notebook";
13
+ readonly LEXICAL: "document";
14
+ readonly EXERCISE: "exercise";
15
+ readonly CELL: "cell";
16
+ readonly SPACE: "space";
17
+ readonly UNKNOWN: "unknown";
18
+ };
19
+ /**
20
+ * Type representing valid item types.
21
+ */
22
+ export type ItemType = (typeof ItemTypes)[keyof typeof ItemTypes];
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /**
6
+ * Constants for the Datalayer SDK.
7
+ *
8
+ * @module client/constants
9
+ */
10
+ /**
11
+ * Item types used throughout the SDK and consuming applications.
12
+ * These constants define the type identifiers for different Datalayer items.
13
+ * Values match what the Datalayer API returns.
14
+ */
15
+ export const ItemTypes = {
16
+ NOTEBOOK: 'notebook',
17
+ LEXICAL: 'document',
18
+ EXERCISE: 'exercise',
19
+ CELL: 'cell',
20
+ SPACE: 'space',
21
+ UNKNOWN: 'unknown',
22
+ };