@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,173 @@
1
+ /**
2
+ * Snapshot domain model for the Datalayer SDK.
3
+ *
4
+ * @module models/RuntimeSnapshotDTO
5
+ */
6
+ import type { DatalayerClient } from '../index';
7
+ import { RuntimeDTO } from './RuntimeDTO';
8
+ /**
9
+ * Represents a runthime snapshot of a runtime's state and files.
10
+ * @interface RuntimeSnapshotData
11
+ */
12
+ export interface RuntimeSnapshotData {
13
+ /** Unique identifier for the snapshot */
14
+ uid: string;
15
+ /** Name of the snapshot */
16
+ name: string;
17
+ /** Optional description of the snapshot */
18
+ description?: string;
19
+ /** Name of the environment used by the runtime */
20
+ environment: string;
21
+ /** Metadata associated with the snapshot */
22
+ metadata?: {
23
+ version?: string;
24
+ language_info?: any;
25
+ [key: string]: any;
26
+ };
27
+ /** Size of the snapshot in bytes */
28
+ size?: number;
29
+ /** Format of the snapshot */
30
+ format?: string;
31
+ /** Format version of the snapshot */
32
+ format_version?: string;
33
+ /** Status of the snapshot */
34
+ status?: string;
35
+ /** ISO 8601 timestamp when the snapshot was last updated */
36
+ updated_at: string;
37
+ /** List of files included in the snapshot */
38
+ files?: any[];
39
+ }
40
+ /**
41
+ * Stable public interface for Snapshot data.
42
+ * This is the contract that SDK consumers can rely on.
43
+ * The raw API may change, but this interface remains stable.
44
+ */
45
+ export interface RuntimeSnapshotJSON {
46
+ /** Unique identifier for the snapshot */
47
+ uid: string;
48
+ /** Name of the snapshot */
49
+ name: string;
50
+ /** Optional description of the snapshot */
51
+ description?: string;
52
+ /** Name of the environment used by the runtime */
53
+ environment: string;
54
+ /** ISO 8601 timestamp when the snapshot was last updated */
55
+ updatedAt: string;
56
+ }
57
+ /**
58
+ * Request payload for creating a runtime snapshot
59
+ * @interface CreateRuntimeSnapshotRequest
60
+ */
61
+ export interface CreateRuntimeSnapshotRequest {
62
+ /** Pod name of the runtime to snapshot */
63
+ pod_name: string;
64
+ /** Name for the snapshot */
65
+ name: string;
66
+ /** Description of the snapshot */
67
+ description: string;
68
+ /** Whether to stop the runtime after creating snapshot */
69
+ stop: boolean;
70
+ }
71
+ /**
72
+ * Response for getting a specific runtime snapshot
73
+ * @interface GetRuntimeSnapshotResponse
74
+ */
75
+ export interface GetRuntimeSnapshotResponse {
76
+ /** Indicates if the request was successful */
77
+ success: boolean;
78
+ /** Response message */
79
+ message: string;
80
+ /** The snapshot details */
81
+ snapshot: RuntimeSnapshotData;
82
+ }
83
+ /**
84
+ * Response for creating a runtime snapshot
85
+ * @interface CreateRuntimeSnapshotResponse
86
+ */
87
+ export interface CreateRuntimeSnapshotResponse {
88
+ /** Indicates if the request was successful */
89
+ success: boolean;
90
+ /** Response message */
91
+ message: string;
92
+ /** The created snapshot details */
93
+ snapshot: RuntimeSnapshotData;
94
+ }
95
+ /**
96
+ * Response from listing runtime snapshots
97
+ * @interface RuntimeSnapshotsListResponse
98
+ */
99
+ export interface ListRuntimeSnapshotsResponse {
100
+ /** Whether the request was successful */
101
+ success: boolean;
102
+ /** Response message from the server */
103
+ message: string;
104
+ /** Array of runtime snapshots */
105
+ snapshots: RuntimeSnapshotData[];
106
+ }
107
+ /**
108
+ * Snapshot domain model that wraps API responses with convenient methods.
109
+ * Provides runtime snapshot management with data refresh and lifecycle operations.
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * const snapshot = await runtime.createSnapshot('my-checkpoint');
114
+ * const runtime = await snapshot.restore();
115
+ * ```
116
+ */
117
+ export declare class RuntimeSnapshotDTO {
118
+ protected _data: RuntimeSnapshotData;
119
+ private _sdk;
120
+ private _deleted;
121
+ /**
122
+ * Create a Runtime Snapshot instance.
123
+ *
124
+ * @param data - Snapshot data from API
125
+ * @param sdk - SDK instance
126
+ */
127
+ constructor(data: RuntimeSnapshotData, sdk: DatalayerClient);
128
+ /**
129
+ * Check if this snapshot has been deleted and throw error if so.
130
+ * @throws Error if deleted
131
+ */
132
+ private _checkDeleted;
133
+ /** Unique identifier for the snapshot. */
134
+ get uid(): string;
135
+ /** Name of the snapshot. */
136
+ get name(): string;
137
+ /** Description of the snapshot. */
138
+ get description(): string;
139
+ /** Name of the environment used by the runtime. */
140
+ get environment(): string;
141
+ /** When the snapshot was last updated. */
142
+ get updatedAt(): Date;
143
+ /**
144
+ * Delete this snapshot permanently.
145
+ * After deletion, subsequent calls to dynamic methods will throw errors.
146
+ */
147
+ delete(): Promise<void>;
148
+ /**
149
+ * Create a runtime from this snapshot (restore functionality).
150
+ *
151
+ * @param config - Optional runtime configuration to override defaults
152
+ * @returns Created Runtime instance
153
+ */
154
+ restore(minutesLimit: number): Promise<RuntimeDTO>;
155
+ /**
156
+ * Get snapshot data in camelCase format.
157
+ * Returns only the core fields that consumers need.
158
+ * This provides a stable interface regardless of API changes.
159
+ * Note: Returns current cached state - call getStatus() first if you need fresh data.
160
+ *
161
+ * @returns Core snapshot data with camelCase properties
162
+ */
163
+ toJSON(): RuntimeSnapshotJSON;
164
+ /**
165
+ * Get the raw snapshot data exactly as received from the API.
166
+ * This preserves the original snake_case naming from the API response.
167
+ *
168
+ * @returns Raw snapshot data from API
169
+ */
170
+ rawData(): RuntimeSnapshotData;
171
+ /** String representation of the snapshot. */
172
+ toString(): string;
173
+ }
@@ -0,0 +1,139 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ import { snapshots } from '../api/runtimes';
6
+ import { validateJSON } from '../api/utils/validation';
7
+ /**
8
+ * Snapshot domain model that wraps API responses with convenient methods.
9
+ * Provides runtime snapshot management with data refresh and lifecycle operations.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const snapshot = await runtime.createSnapshot('my-checkpoint');
14
+ * const runtime = await snapshot.restore();
15
+ * ```
16
+ */
17
+ export class RuntimeSnapshotDTO {
18
+ _data;
19
+ _sdk;
20
+ _deleted = false;
21
+ /**
22
+ * Create a Runtime Snapshot instance.
23
+ *
24
+ * @param data - Snapshot data from API
25
+ * @param sdk - SDK instance
26
+ */
27
+ constructor(data, sdk) {
28
+ this._data = data;
29
+ this._sdk = sdk;
30
+ }
31
+ // ========================================================================
32
+ // Helper Methods
33
+ // ========================================================================
34
+ /**
35
+ * Check if this snapshot has been deleted and throw error if so.
36
+ * @throws Error if deleted
37
+ */
38
+ _checkDeleted() {
39
+ if (this._deleted) {
40
+ throw new Error(`Snapshot ${this._data.uid} has been deleted and no longer exists`);
41
+ }
42
+ }
43
+ // ========================================================================
44
+ // Static Properties (set at creation, never change)
45
+ // ========================================================================
46
+ /** Unique identifier for the snapshot. */
47
+ get uid() {
48
+ this._checkDeleted();
49
+ return this._data.uid;
50
+ }
51
+ /** Name of the snapshot. */
52
+ get name() {
53
+ this._checkDeleted();
54
+ return this._data.name;
55
+ }
56
+ /** Description of the snapshot. */
57
+ get description() {
58
+ this._checkDeleted();
59
+ return this._data.description || '';
60
+ }
61
+ /** Name of the environment used by the runtime. */
62
+ get environment() {
63
+ this._checkDeleted();
64
+ return this._data.environment;
65
+ }
66
+ /** When the snapshot was last updated. */
67
+ get updatedAt() {
68
+ this._checkDeleted();
69
+ return new Date(this._data.updated_at);
70
+ }
71
+ // ========================================================================
72
+ // Action Methods
73
+ // ========================================================================
74
+ /**
75
+ * Delete this snapshot permanently.
76
+ * After deletion, subsequent calls to dynamic methods will throw errors.
77
+ */
78
+ async delete() {
79
+ this._checkDeleted();
80
+ const token = this._sdk.getToken();
81
+ const runtimesRunUrl = this._sdk.getRuntimesRunUrl();
82
+ await snapshots.deleteSnapshot(token, this.uid, runtimesRunUrl);
83
+ this._deleted = true;
84
+ }
85
+ /**
86
+ * Create a runtime from this snapshot (restore functionality).
87
+ *
88
+ * @param config - Optional runtime configuration to override defaults
89
+ * @returns Created Runtime instance
90
+ */
91
+ async restore(minutesLimit) {
92
+ this._checkDeleted();
93
+ return await this._sdk.createRuntime({
94
+ environmentName: this.environment,
95
+ type: 'notebook',
96
+ givenName: `Restored from ${this.name}`,
97
+ minutesLimit: minutesLimit,
98
+ fromSnapshotId: this.uid,
99
+ });
100
+ }
101
+ // ========================================================================
102
+ // Utility Methods
103
+ // ========================================================================
104
+ /**
105
+ * Get snapshot data in camelCase format.
106
+ * Returns only the core fields that consumers need.
107
+ * This provides a stable interface regardless of API changes.
108
+ * Note: Returns current cached state - call getStatus() first if you need fresh data.
109
+ *
110
+ * @returns Core snapshot data with camelCase properties
111
+ */
112
+ toJSON() {
113
+ this._checkDeleted();
114
+ const obj = {
115
+ uid: this.uid,
116
+ name: this.name,
117
+ description: this.description,
118
+ environment: this.environment,
119
+ updatedAt: this.updatedAt.toISOString(),
120
+ };
121
+ validateJSON(obj, 'Snapshot');
122
+ return obj;
123
+ }
124
+ /**
125
+ * Get the raw snapshot data exactly as received from the API.
126
+ * This preserves the original snake_case naming from the API response.
127
+ *
128
+ * @returns Raw snapshot data from API
129
+ */
130
+ rawData() {
131
+ this._checkDeleted();
132
+ return this._data;
133
+ }
134
+ /** String representation of the snapshot. */
135
+ toString() {
136
+ this._checkDeleted();
137
+ return `Snapshot(${this.uid}, ${this.name})`;
138
+ }
139
+ }
@@ -0,0 +1,280 @@
1
+ import type { DatalayerClient } from '../index';
2
+ import { NotebookDTO, type NotebookJSON } from './NotebookDTO';
3
+ import { NotebookData } from './NotebookDTO';
4
+ import { LexicalDTO, type LexicalJSON } from './LexicalDTO';
5
+ /**
6
+ * Represents a workspace or project space in Datalayer
7
+ * @interface SpaceData
8
+ */
9
+ export interface SpaceData {
10
+ uid: string;
11
+ name_t: string;
12
+ handle_s: string;
13
+ variant_s: string;
14
+ description_t: string;
15
+ tags_ss?: string[];
16
+ members?: any[];
17
+ items?: any[];
18
+ }
19
+ /**
20
+ * Stable public interface for Space data.
21
+ * This is the contract that SDK consumers can rely on.
22
+ * The raw API may change, but this interface remains stable.
23
+ */
24
+ export interface SpaceJSON {
25
+ /** ulid for the space */
26
+ uid: string;
27
+ /** Name of the space */
28
+ name: string;
29
+ /** Handle for the space */
30
+ handle: string;
31
+ /** Variant of the space */
32
+ variant: string;
33
+ /** Description of the space */
34
+ description: string;
35
+ /** Items contained in the space (as JSON) */
36
+ items: Array<NotebookJSON | LexicalJSON>;
37
+ }
38
+ /**
39
+ * Space domain model that wraps API responses with convenient methods.
40
+ * Provides workspace management with data refresh and content creation operations.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const space = spaces[0];
45
+ * const items = await space.getItems();
46
+ * const notebook = await space.createNotebook({ name: 'Analysis' });
47
+ * ```
48
+ */
49
+ export declare class SpaceDTO {
50
+ protected _data: SpaceData;
51
+ private _sdk;
52
+ private _items;
53
+ private _deleted;
54
+ /**
55
+ * Create a Space instance.
56
+ *
57
+ * @param data - Space data from API
58
+ * @param sdk - SDK instance
59
+ */
60
+ constructor(data: SpaceData, sdk: DatalayerClient);
61
+ /**
62
+ * Check if this space has been deleted and throw error if so.
63
+ * @throws Error if deleted
64
+ */
65
+ private _checkDeleted;
66
+ /**
67
+ * Refresh space data from the API by fetching user's spaces.
68
+ */
69
+ refresh(): Promise<void>;
70
+ /** Unique identifier for the space. */
71
+ get uid(): string;
72
+ /** URL-friendly handle for the space. */
73
+ get handle(): string;
74
+ /** Space variant type. */
75
+ get variant(): string;
76
+ /**
77
+ * The name of the space.
78
+ */
79
+ get name(): string;
80
+ /**
81
+ * The description of the space.
82
+ */
83
+ get description(): string;
84
+ /**
85
+ * Helper method to create items in this space.
86
+ *
87
+ * @param itemType - Type of item to create
88
+ * @param data - Creation configuration
89
+ * @returns Created model instance
90
+ * @internal
91
+ */
92
+ private _createItem;
93
+ /**
94
+ * Get all items in this space as model instances.
95
+ *
96
+ * @returns Array of Notebook and Lexical model instances
97
+ */
98
+ getItems(): Promise<(NotebookDTO | LexicalDTO)[]>;
99
+ /**
100
+ * Create a new notebook in this space.
101
+ *
102
+ * @param data - Notebook creation configuration
103
+ * @returns Created Notebook instance
104
+ */
105
+ createNotebook(data: {
106
+ name: string;
107
+ description: string;
108
+ file?: File | Blob;
109
+ }): Promise<NotebookDTO>;
110
+ /**
111
+ * Create a new lexical document in this space.
112
+ *
113
+ * @param data - Lexical creation configuration
114
+ * @returns Created Lexical instance
115
+ */
116
+ createLexical(data: {
117
+ name: string;
118
+ description: string;
119
+ file?: File | Blob;
120
+ }): Promise<LexicalDTO>;
121
+ /**
122
+ * Get raw space data object.
123
+ * Returns cached data without refreshing.
124
+ *
125
+ * @returns Raw space data object
126
+ */
127
+ /**
128
+ * Get space data in camelCase format.
129
+ * Returns only the core fields that consumers need.
130
+ * This provides a stable interface regardless of API changes.
131
+ *
132
+ * @returns Core space data with camelCase properties
133
+ */
134
+ toJSON(): SpaceJSON;
135
+ /**
136
+ * Get the raw space data exactly as received from the API.
137
+ * This preserves the original snake_case naming from the API response.
138
+ *
139
+ * @returns Raw space data from API
140
+ */
141
+ rawData(): SpaceData;
142
+ /** String representation of the space. */
143
+ toString(): string;
144
+ }
145
+ /**
146
+ * Request payload for creating a new space
147
+ * @interface CreateSpaceRequest
148
+ */
149
+ export interface CreateSpaceRequest {
150
+ name: string;
151
+ description: string;
152
+ variant: string;
153
+ spaceHandle: string;
154
+ organizationId: string;
155
+ seedSpaceId: string;
156
+ public: boolean;
157
+ }
158
+ /**
159
+ * Response from getting a collaboration session ID
160
+ * @interface CollaborationSessionResponse
161
+ */
162
+ export interface CollaborationSessionResponse {
163
+ success: boolean;
164
+ sessionId?: string;
165
+ error?: string;
166
+ }
167
+ /**
168
+ * Response from creating a space
169
+ * @interface CreateSpaceResponse
170
+ */
171
+ export interface CreateSpaceResponse {
172
+ success: boolean;
173
+ message: string;
174
+ space?: SpaceData;
175
+ }
176
+ /**
177
+ * Request payload for creating a new notebook (multipart/form-data)
178
+ * @interface CreateNotebookRequest
179
+ */
180
+ export interface CreateNotebookRequest {
181
+ spaceId: string;
182
+ notebookType: string;
183
+ name: string;
184
+ description: string;
185
+ file?: File | Blob;
186
+ }
187
+ /**
188
+ * Response from creating a notebook
189
+ * @interface CreateNotebookResponse
190
+ */
191
+ export interface CreateNotebookResponse {
192
+ success: boolean;
193
+ message: string;
194
+ notebook?: NotebookData;
195
+ }
196
+ /**
197
+ * Response from getting a notebook
198
+ * @interface GetNotebookResponse
199
+ */
200
+ export interface GetNotebookResponse {
201
+ success: boolean;
202
+ message: string;
203
+ notebook?: NotebookData;
204
+ }
205
+ /**
206
+ * Request payload for creating a notebook
207
+ * @interface CreateNotebookRequest
208
+ */
209
+ export interface CreateNotebookRequest {
210
+ spaceId: string;
211
+ notebookType: string;
212
+ name: string;
213
+ description: string;
214
+ file?: File | Blob;
215
+ }
216
+ /**
217
+ * Request payload for updating a notebook
218
+ * @interface UpdateNotebookRequest
219
+ */
220
+ export interface UpdateNotebookRequest {
221
+ name?: string;
222
+ description?: string;
223
+ }
224
+ /**
225
+ * Response from updating a notebook
226
+ * @interface UpdateNotebookResponse
227
+ */
228
+ export interface UpdateNotebookResponse {
229
+ success: boolean;
230
+ message: string;
231
+ notebook?: NotebookData;
232
+ }
233
+ /**
234
+ * Represents an item within a space
235
+ * @interface SpaceItem
236
+ */
237
+ export interface SpaceItem {
238
+ id: string;
239
+ type_s: 'notebook' | 'lexical';
240
+ space_id: string;
241
+ item_id: string;
242
+ name: string;
243
+ created_at: string;
244
+ updated_at?: string;
245
+ }
246
+ /**
247
+ * Response from getting space items
248
+ * @interface GetSpaceItemsResponse
249
+ */
250
+ export interface GetSpaceItemsResponse {
251
+ success: boolean;
252
+ message: string;
253
+ items: SpaceItem[];
254
+ }
255
+ /**
256
+ * Response from deleting a space item
257
+ * @interface DeleteSpaceItemResponse
258
+ */
259
+ export interface DeleteSpaceItemResponse {
260
+ success: boolean;
261
+ message: string;
262
+ }
263
+ /**
264
+ * Response from getting a single space item
265
+ * @interface GetSpaceItemResponse
266
+ */
267
+ export interface GetSpaceItemResponse {
268
+ success: boolean;
269
+ message: string;
270
+ item?: any;
271
+ }
272
+ /**
273
+ * Response from getting spaces for a user
274
+ * @interface SpacesForUserResponse
275
+ */
276
+ export interface SpacesForUserResponse {
277
+ success: boolean;
278
+ message: string;
279
+ spaces: SpaceData[];
280
+ }