@datalayer/core 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/README.md +2 -2
  2. package/lib/api/DatalayerApi.d.ts +38 -26
  3. package/lib/api/DatalayerApi.js +35 -8
  4. package/lib/api/iam/authentication.d.ts +8 -7
  5. package/lib/api/iam/authentication.js +14 -15
  6. package/lib/api/iam/healthz.d.ts +3 -2
  7. package/lib/api/iam/healthz.js +5 -3
  8. package/lib/api/iam/index.d.ts +9 -4
  9. package/lib/api/iam/index.js +9 -4
  10. package/lib/api/iam/oauth2.d.ts +115 -0
  11. package/lib/api/iam/oauth2.js +309 -0
  12. package/lib/api/iam/profile.d.ts +8 -1
  13. package/lib/api/iam/profile.js +17 -2
  14. package/lib/api/iam/usage.d.ts +56 -0
  15. package/lib/api/iam/usage.js +39 -0
  16. package/lib/api/index.d.ts +6 -5
  17. package/lib/api/index.js +6 -5
  18. package/lib/api/runtimes/environments.js +3 -2
  19. package/lib/api/runtimes/healthz.d.ts +3 -13
  20. package/lib/api/runtimes/healthz.js +4 -3
  21. package/lib/api/runtimes/index.d.ts +3 -2
  22. package/lib/api/runtimes/index.js +3 -2
  23. package/lib/api/runtimes/runtimes.js +17 -6
  24. package/lib/api/runtimes/snapshots.js +3 -2
  25. package/lib/api/spacer/documents.d.ts +12 -0
  26. package/lib/api/spacer/documents.js +43 -0
  27. package/lib/api/spacer/healthz.d.ts +3 -13
  28. package/lib/api/spacer/healthz.js +4 -3
  29. package/lib/api/spacer/index.d.ts +4 -2
  30. package/lib/api/spacer/index.js +4 -2
  31. package/lib/api/spacer/items.d.ts +9 -1
  32. package/lib/api/spacer/items.js +17 -2
  33. package/lib/api/spacer/lexicals.js +3 -2
  34. package/lib/api/spacer/notebooks.js +3 -2
  35. package/lib/api/spacer/spaces.js +3 -2
  36. package/lib/api/spacer/users.js +3 -2
  37. package/lib/api/types/common.d.ts +64 -0
  38. package/lib/api/types/iam.d.ts +88 -65
  39. package/lib/api/types/index.d.ts +4 -2
  40. package/lib/api/types/index.js +4 -2
  41. package/lib/api/types/runtimes.d.ts +9 -39
  42. package/lib/api/types/spacer.d.ts +37 -65
  43. package/lib/api/utils/validation.d.ts +24 -1
  44. package/lib/api/utils/validation.js +62 -1
  45. package/lib/client/base.d.ts +75 -0
  46. package/lib/client/base.js +199 -0
  47. package/lib/client/constants.d.ts +22 -0
  48. package/lib/client/constants.js +22 -0
  49. package/lib/client/index.d.ts +108 -0
  50. package/lib/client/index.js +79 -0
  51. package/lib/client/mixins/IAMMixin.d.ts +54 -0
  52. package/lib/client/mixins/IAMMixin.js +181 -0
  53. package/lib/client/mixins/RuntimesMixin.d.ts +93 -0
  54. package/lib/client/mixins/RuntimesMixin.js +229 -0
  55. package/lib/client/mixins/SpacerMixin.d.ts +111 -0
  56. package/lib/client/mixins/SpacerMixin.js +340 -0
  57. package/lib/client/models/Credits.d.ts +91 -0
  58. package/lib/client/models/Credits.js +130 -0
  59. package/lib/client/models/Environment.d.ts +73 -0
  60. package/lib/client/models/Environment.js +88 -0
  61. package/lib/client/models/HealthCheck.d.ts +72 -0
  62. package/lib/client/models/HealthCheck.js +107 -0
  63. package/lib/client/models/Item.d.ts +69 -0
  64. package/lib/client/models/Item.js +191 -0
  65. package/lib/client/models/Lexical.d.ts +83 -0
  66. package/lib/client/models/Lexical.js +152 -0
  67. package/lib/client/models/Notebook.d.ts +87 -0
  68. package/lib/client/models/Notebook.js +153 -0
  69. package/lib/client/models/Runtime.d.ts +122 -0
  70. package/lib/client/models/Runtime.js +204 -0
  71. package/lib/client/models/Snapshot.d.ts +92 -0
  72. package/lib/client/models/Snapshot.js +139 -0
  73. package/lib/client/models/Space.d.ts +135 -0
  74. package/lib/client/models/Space.js +234 -0
  75. package/lib/client/models/User.d.ts +64 -0
  76. package/lib/client/models/User.js +83 -0
  77. package/lib/client/models/index.d.ts +26 -0
  78. package/lib/client/models/index.js +25 -0
  79. package/lib/client/utils/mixins.d.ts +12 -0
  80. package/lib/{sdk/client → client}/utils/mixins.js +0 -28
  81. package/lib/client/utils/spacerUtils.d.ts +18 -0
  82. package/lib/client/utils/spacerUtils.js +32 -0
  83. package/lib/collaboration/DatalayerCollaboration.d.ts +6 -1
  84. package/lib/collaboration/DatalayerCollaboration.js +2 -2
  85. package/lib/collaboration/DatalayerCollaborationProvider.d.ts +5 -0
  86. package/lib/collaboration/DatalayerCollaborationProvider.js +10 -9
  87. package/lib/components/progress/CreditsIndicator.d.ts +1 -1
  88. package/lib/components/runtimes/RuntimeCellVariablesDialog.js +1 -1
  89. package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +1 -1
  90. package/lib/components/runtimes/RuntimePickerBase.d.ts +1 -1
  91. package/lib/components/runtimes/RuntimePickerBase.js +1 -1
  92. package/lib/components/runtimes/RuntimePickerCell.js +2 -2
  93. package/lib/components/runtimes/RuntimePickerNotebook.d.ts +1 -1
  94. package/lib/components/runtimes/RuntimePickerNotebook.js +1 -1
  95. package/lib/components/runtimes/RuntimeTransfer.d.ts +1 -1
  96. package/lib/components/runtimes/RuntimeUtils.d.ts +1 -1
  97. package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -1
  98. package/lib/components/snapshots/RuntimeSnapshotMenu.js +27 -20
  99. package/lib/config/Configuration.d.ts +8 -0
  100. package/lib/hooks/useDatalayer.js +1 -1
  101. package/lib/hooks/useRuntimes.js +1 -1
  102. package/lib/hooks/useToast.js +1 -1
  103. package/lib/index.d.ts +2 -2
  104. package/lib/index.js +4 -2
  105. package/lib/sdk/index.d.ts +5 -4
  106. package/lib/sdk/index.js +6 -5
  107. package/lib/services/DatalayerServiceManager.js +1 -1
  108. package/lib/state/substates/CoreState.js +2 -0
  109. package/lib/state/substates/RuntimesState.d.ts +1 -1
  110. package/lib/state/substates/RuntimesState.js +1 -1
  111. package/lib/{sdk/stateful → stateful}/index.d.ts +1 -1
  112. package/lib/{sdk/stateful → stateful}/index.js +1 -1
  113. package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.d.ts +1 -41
  114. package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.js +1 -20
  115. package/lib/{sdk/stateful → stateful}/runtimes/actions.d.ts +3 -3
  116. package/lib/{sdk/stateful → stateful}/runtimes/actions.js +8 -8
  117. package/lib/{sdk/stateful → stateful}/runtimes/apis.d.ts +8 -8
  118. package/lib/stateful/runtimes/apis.js +5 -0
  119. package/package.json +12 -10
  120. package/lib/__tests__/hooks.test.d.ts +0 -1
  121. package/lib/__tests__/hooks.test.js +0 -19
  122. package/lib/__tests__/index.test.d.ts +0 -1
  123. package/lib/__tests__/index.test.js +0 -27
  124. package/lib/__tests__/integration.test.d.ts +0 -1
  125. package/lib/__tests__/integration.test.js +0 -57
  126. package/lib/__tests__/shared/cleanup-shared.d.ts +0 -4
  127. package/lib/__tests__/shared/cleanup-shared.js +0 -228
  128. package/lib/__tests__/shared/test-config.d.ts +0 -51
  129. package/lib/__tests__/shared/test-config.js +0 -110
  130. package/lib/__tests__/shared/test-constants.d.ts +0 -66
  131. package/lib/__tests__/shared/test-constants.js +0 -79
  132. package/lib/__tests__/utils.test.d.ts +0 -1
  133. package/lib/__tests__/utils.test.js +0 -59
  134. package/lib/api/__tests__/iam.authentication.integration.test.d.ts +0 -1
  135. package/lib/api/__tests__/iam.authentication.integration.test.js +0 -247
  136. package/lib/api/__tests__/iam.healthz.integration.test.d.ts +0 -1
  137. package/lib/api/__tests__/iam.healthz.integration.test.js +0 -63
  138. package/lib/api/__tests__/iam.profile.integration.test.d.ts +0 -1
  139. package/lib/api/__tests__/iam.profile.integration.test.js +0 -252
  140. package/lib/api/__tests__/runtimes.environments.integration.test.d.ts +0 -1
  141. package/lib/api/__tests__/runtimes.environments.integration.test.js +0 -122
  142. package/lib/api/__tests__/runtimes.healthz.integration.test.d.ts +0 -1
  143. package/lib/api/__tests__/runtimes.healthz.integration.test.js +0 -50
  144. package/lib/api/__tests__/runtimes.integration.test.d.ts +0 -1
  145. package/lib/api/__tests__/runtimes.integration.test.js +0 -369
  146. package/lib/api/__tests__/spacer.healthz.integration.test.d.ts +0 -1
  147. package/lib/api/__tests__/spacer.healthz.integration.test.js +0 -50
  148. package/lib/api/__tests__/spacer.integration.test.d.ts +0 -1
  149. package/lib/api/__tests__/spacer.integration.test.js +0 -519
  150. package/lib/api/iam/__tests__/authentication.unit.test.d.ts +0 -1
  151. package/lib/api/iam/__tests__/authentication.unit.test.js +0 -63
  152. package/lib/api/iam/__tests__/healthz.unit.test.d.ts +0 -1
  153. package/lib/api/iam/__tests__/healthz.unit.test.js +0 -60
  154. package/lib/api/iam/__tests__/profile.unit.test.d.ts +0 -1
  155. package/lib/api/iam/__tests__/profile.unit.test.js +0 -57
  156. package/lib/api/runtimes/__tests__/environments.unit.test.d.ts +0 -1
  157. package/lib/api/runtimes/__tests__/environments.unit.test.js +0 -77
  158. package/lib/api/runtimes/__tests__/healthz.unit.test.d.ts +0 -1
  159. package/lib/api/runtimes/__tests__/healthz.unit.test.js +0 -57
  160. package/lib/api/runtimes/__tests__/runtimes.unit.test.d.ts +0 -1
  161. package/lib/api/runtimes/__tests__/runtimes.unit.test.js +0 -139
  162. package/lib/api/runtimes/__tests__/snapshots.unit.test.d.ts +0 -1
  163. package/lib/api/runtimes/__tests__/snapshots.unit.test.js +0 -96
  164. package/lib/api/spacer/__tests__/healthz.unit.test.d.ts +0 -1
  165. package/lib/api/spacer/__tests__/healthz.unit.test.js +0 -57
  166. package/lib/api/spacer/__tests__/items.unit.test.d.ts +0 -1
  167. package/lib/api/spacer/__tests__/items.unit.test.js +0 -165
  168. package/lib/api/spacer/__tests__/lexicals.unit.test.d.ts +0 -1
  169. package/lib/api/spacer/__tests__/lexicals.unit.test.js +0 -323
  170. package/lib/api/spacer/__tests__/notebooks.unit.test.d.ts +0 -1
  171. package/lib/api/spacer/__tests__/notebooks.unit.test.js +0 -224
  172. package/lib/api/spacer/__tests__/users.unit.test.d.ts +0 -1
  173. package/lib/api/spacer/__tests__/users.unit.test.js +0 -132
  174. package/lib/api/utils/__tests__/validation.test.d.ts +0 -1
  175. package/lib/api/utils/__tests__/validation.test.js +0 -109
  176. package/lib/sdk/client/__tests__/sdk.health.integration.test.d.ts +0 -1
  177. package/lib/sdk/client/__tests__/sdk.health.integration.test.js +0 -110
  178. package/lib/sdk/client/__tests__/sdk.iam.integration.test.d.ts +0 -1
  179. package/lib/sdk/client/__tests__/sdk.iam.integration.test.js +0 -179
  180. package/lib/sdk/client/__tests__/sdk.models.integration.test.d.ts +0 -1
  181. package/lib/sdk/client/__tests__/sdk.models.integration.test.js +0 -376
  182. package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.d.ts +0 -1
  183. package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.js +0 -276
  184. package/lib/sdk/client/__tests__/sdk.spacer.integration.test.d.ts +0 -1
  185. package/lib/sdk/client/__tests__/sdk.spacer.integration.test.js +0 -361
  186. package/lib/sdk/client/base.d.ts +0 -88
  187. package/lib/sdk/client/base.js +0 -112
  188. package/lib/sdk/client/index.d.ts +0 -192
  189. package/lib/sdk/client/index.js +0 -128
  190. package/lib/sdk/client/mixins/HealthMixin.d.ts +0 -100
  191. package/lib/sdk/client/mixins/HealthMixin.js +0 -133
  192. package/lib/sdk/client/mixins/IAMMixin.d.ts +0 -59
  193. package/lib/sdk/client/mixins/IAMMixin.js +0 -83
  194. package/lib/sdk/client/mixins/RuntimesMixin.d.ts +0 -134
  195. package/lib/sdk/client/mixins/RuntimesMixin.js +0 -221
  196. package/lib/sdk/client/mixins/SpacerMixin.d.ts +0 -184
  197. package/lib/sdk/client/mixins/SpacerMixin.js +0 -278
  198. package/lib/sdk/client/models/Lexical.d.ts +0 -156
  199. package/lib/sdk/client/models/Lexical.js +0 -275
  200. package/lib/sdk/client/models/Notebook.d.ts +0 -174
  201. package/lib/sdk/client/models/Notebook.js +0 -311
  202. package/lib/sdk/client/models/Runtime.d.ts +0 -221
  203. package/lib/sdk/client/models/Runtime.js +0 -341
  204. package/lib/sdk/client/models/Snapshot.d.ts +0 -156
  205. package/lib/sdk/client/models/Snapshot.js +0 -244
  206. package/lib/sdk/client/models/Space.d.ts +0 -182
  207. package/lib/sdk/client/models/Space.js +0 -276
  208. package/lib/sdk/client/models/__tests__/Lexical.test.d.ts +0 -1
  209. package/lib/sdk/client/models/__tests__/Lexical.test.js +0 -288
  210. package/lib/sdk/client/models/__tests__/Notebook.test.d.ts +0 -1
  211. package/lib/sdk/client/models/__tests__/Notebook.test.js +0 -206
  212. package/lib/sdk/client/models/__tests__/Runtime.test.d.ts +0 -1
  213. package/lib/sdk/client/models/__tests__/Runtime.test.js +0 -133
  214. package/lib/sdk/client/models/__tests__/Snapshot.test.d.ts +0 -1
  215. package/lib/sdk/client/models/__tests__/Snapshot.test.js +0 -244
  216. package/lib/sdk/client/models/__tests__/Space.test.d.ts +0 -1
  217. package/lib/sdk/client/models/__tests__/Space.test.js +0 -334
  218. package/lib/sdk/client/models/index.d.ts +0 -30
  219. package/lib/sdk/client/models/index.js +0 -30
  220. package/lib/sdk/client/utils/mixins.d.ts +0 -42
  221. /package/lib/{sdk/stateful/runtimes/apis.js → api/types/common.js} +0 -0
  222. /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.d.ts +0 -0
  223. /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.js +0 -0
  224. /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.d.ts +0 -0
  225. /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.js +0 -0
  226. /package/lib/{sdk/stateful → stateful}/jupyter/index.d.ts +0 -0
  227. /package/lib/{sdk/stateful → stateful}/jupyter/index.js +0 -0
  228. /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.d.ts +0 -0
  229. /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.js +0 -0
  230. /package/lib/{sdk/stateful → stateful}/runtimes/index.d.ts +0 -0
  231. /package/lib/{sdk/stateful → stateful}/runtimes/index.js +0 -0
  232. /package/lib/{sdk/stateful → stateful}/runtimes/settings.d.ts +0 -0
  233. /package/lib/{sdk/stateful → stateful}/runtimes/settings.js +0 -0
  234. /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.d.ts +0 -0
  235. /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.js +0 -0
  236. /package/lib/{sdk/stateful → stateful}/runtimes/utils.d.ts +0 -0
  237. /package/lib/{sdk/stateful → stateful}/runtimes/utils.js +0 -0
@@ -1,184 +0,0 @@
1
- import type { CreateSpaceRequest, CreateNotebookRequest, UpdateNotebookRequest, CreateLexicalRequest, UpdateLexicalRequest, GetSpaceItemsResponse, DeleteSpaceItemResponse } from '../../../api/types/spacer';
2
- import type { Constructor } from '../utils/mixins';
3
- import { Notebook } from '../models/Notebook';
4
- import { Lexical } from '../models/Lexical';
5
- import { Space } from '../models/Space';
6
- /**
7
- * Spacer mixin that provides workspace and content management.
8
- *
9
- * This mixin is applied to the DatalayerSDK class to provide clean, intuitive
10
- * methods for managing spaces, notebooks, and cells.
11
- */
12
- export declare function SpacerMixin<TBase extends Constructor>(Base: TBase): {
13
- new (...args: any[]): {
14
- /**
15
- * Get all workspaces for the authenticated user.
16
- *
17
- * @returns Promise resolving to array of Space instances
18
- *
19
- * @example
20
- * ```typescript
21
- * const mySpaces = await sdk.getMySpaces();
22
- * console.log('My spaces:', mySpaces.length);
23
- * for (const space of mySpaces) {
24
- * const name = await space.getName();
25
- * console.log(`- ${name} (${space.visibility})`);
26
- * }
27
- * ```
28
- */
29
- getMySpaces(): Promise<Space[]>;
30
- /**
31
- * Create a new workspace.
32
- *
33
- * @param data - Space creation parameters
34
- * @returns Promise resolving to created Space instance
35
- *
36
- * @example
37
- * ```typescript
38
- * const space = await sdk.createSpace({
39
- * name: 'My Research Project',
40
- * description: 'Data analysis workspace',
41
- * variant: 'default',
42
- * spaceHandle: 'research-project',
43
- * organizationId: 'org-123',
44
- * seedSpaceId: 'seed-456',
45
- * public: false
46
- * });
47
- * const name = await space.getName();
48
- * console.log('Space created:', name);
49
- * ```
50
- */
51
- createSpace(data: CreateSpaceRequest): Promise<Space>;
52
- _extractNotebookId(notebookIdOrInstance: string | Notebook): string;
53
- _extractLexicalId(lexicalIdOrInstance: string | Lexical): string;
54
- /**
55
- * Create a new notebook.
56
- *
57
- * @param data - Notebook creation parameters
58
- * @returns Promise resolving to created Notebook instance
59
- *
60
- * @example
61
- * ```typescript
62
- * const notebook = await sdk.createNotebook({
63
- * spaceId: 'space-123',
64
- * name: 'Data Analysis',
65
- * description: 'Analysis notebook',
66
- * notebookType: 'jupyter',
67
- * });
68
- * ```
69
- */
70
- createNotebook(data: CreateNotebookRequest): Promise<Notebook>;
71
- /**
72
- * Get a notebook by ID or Notebook instance.
73
- *
74
- * @param idOrNotebook - Notebook ID (string) or Notebook instance
75
- * @returns Promise resolving to Notebook instance
76
- *
77
- * @example
78
- * ```typescript
79
- * const notebook = await sdk.getNotebook('notebook-123');
80
- * const refreshed = await sdk.getNotebook(notebook);
81
- * ```
82
- */
83
- getNotebook(idOrNotebook: string | Notebook): Promise<Notebook>;
84
- /**
85
- * Update a notebook.
86
- *
87
- * @param idOrNotebook - Notebook ID (string) or Notebook instance
88
- * @param data - Update data with optional name and/or description
89
- * @returns Promise resolving to updated Notebook instance
90
- *
91
- * @example
92
- * ```typescript
93
- * const updated = await sdk.updateNotebook('notebook-123', {
94
- * name: 'Updated Analysis',
95
- * description: 'Updated description'
96
- * });
97
- * const updated2 = await sdk.updateNotebook(notebook, {
98
- * name: 'Updated Analysis',
99
- * description: 'Updated description'
100
- * });
101
- * ```
102
- */
103
- updateNotebook(idOrNotebook: string | Notebook, data: UpdateNotebookRequest): Promise<Notebook>;
104
- /**
105
- * Create a new lexical document.
106
- *
107
- * @param data - Document creation parameters
108
- * @returns Promise resolving to created Lexical instance
109
- *
110
- * @example
111
- * ```typescript
112
- * const lexical = await sdk.createLexical({
113
- * spaceId: 'space-123',
114
- * name: 'Project Documentation',
115
- * description: 'Main project docs',
116
- * documentType: 'document',
117
- * });
118
- * ```
119
- */
120
- createLexical(data: CreateLexicalRequest): Promise<Lexical>;
121
- /**
122
- * Get a lexical document by ID or Lexical instance.
123
- *
124
- * @param idOrLexical - Document ID (string) or Lexical instance
125
- * @returns Promise resolving to Lexical instance
126
- *
127
- * @example
128
- * ```typescript
129
- * const lexical = await sdk.getLexical('lexical-123');
130
- * const refreshed = await sdk.getLexical(lexical);
131
- * ```
132
- */
133
- getLexical(idOrLexical: string | Lexical): Promise<Lexical>;
134
- /**
135
- * Update a lexical document.
136
- *
137
- * @param idOrLexical - Document ID (string) or Lexical instance
138
- * @param data - Update data with optional name and/or description
139
- * @returns Promise resolving to updated Lexical instance
140
- *
141
- * @example
142
- * ```typescript
143
- * const updated = await sdk.updateLexical('lexical-123', {
144
- * name: 'Updated Documentation',
145
- * description: 'Updated description'
146
- * });
147
- * const updated2 = await sdk.updateLexical(lexical, {
148
- * name: 'Updated Documentation',
149
- * description: 'Updated description'
150
- * });
151
- * ```
152
- */
153
- updateLexical(idOrLexical: string | Lexical, data: UpdateLexicalRequest): Promise<Lexical>;
154
- /**
155
- * Get the items of a space.
156
- *
157
- * @param spaceId - Space ID
158
- * @returns Promise resolving to space items
159
- *
160
- * @example
161
- * ```typescript
162
- * const response = await sdk.getSpaceItems('space-123');
163
- * console.log('Space items:', response.items.length);
164
- * response.items.forEach(item => {
165
- * console.log(`- ${item.name} (${item.type})`);
166
- * });
167
- * ```
168
- */
169
- getSpaceItems(spaceId: string): Promise<GetSpaceItemsResponse>;
170
- /**
171
- * Delete an item from a space.
172
- *
173
- * @param itemId - Item ID to delete
174
- * @returns Promise resolving when deletion is complete
175
- *
176
- * @example
177
- * ```typescript
178
- * const response = await sdk.deleteSpaceItem('item-123');
179
- * console.log('Item deleted:', response.message);
180
- * ```
181
- */
182
- deleteSpaceItem(itemId: string): Promise<DeleteSpaceItemResponse>;
183
- };
184
- } & TBase;
@@ -1,278 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- /**
6
- * @module sdk/client/mixins/SpacerMixin
7
- * @description Spacer mixin for the Datalayer SDK.
8
- *
9
- * This mixin provides intuitive methods for managing workspaces, notebooks,
10
- * and content that are mixed into the main DatalayerSDK class.
11
- */
12
- import { spaces, notebooks, users, lexicals, items } from '../../../api/spacer';
13
- import { Notebook } from '../models/Notebook';
14
- import { Lexical } from '../models/Lexical';
15
- import { Space } from '../models/Space';
16
- /**
17
- * Spacer mixin that provides workspace and content management.
18
- *
19
- * This mixin is applied to the DatalayerSDK class to provide clean, intuitive
20
- * methods for managing spaces, notebooks, and cells.
21
- */
22
- export function SpacerMixin(Base) {
23
- return class extends Base {
24
- // ========================================================================
25
- // User
26
- // ========================================================================
27
- /**
28
- * Get all workspaces for the authenticated user.
29
- *
30
- * @returns Promise resolving to array of Space instances
31
- *
32
- * @example
33
- * ```typescript
34
- * const mySpaces = await sdk.getMySpaces();
35
- * console.log('My spaces:', mySpaces.length);
36
- * for (const space of mySpaces) {
37
- * const name = await space.getName();
38
- * console.log(`- ${name} (${space.visibility})`);
39
- * }
40
- * ```
41
- */
42
- async getMySpaces() {
43
- const token = this.getToken();
44
- const spacerRunUrl = this.getSpacerRunUrl();
45
- const response = await users.getMySpaces(token, spacerRunUrl);
46
- return response.spaces.map(s => new Space(s, this));
47
- }
48
- // ========================================================================
49
- // Spaces
50
- // ========================================================================
51
- /**
52
- * Create a new workspace.
53
- *
54
- * @param data - Space creation parameters
55
- * @returns Promise resolving to created Space instance
56
- *
57
- * @example
58
- * ```typescript
59
- * const space = await sdk.createSpace({
60
- * name: 'My Research Project',
61
- * description: 'Data analysis workspace',
62
- * variant: 'default',
63
- * spaceHandle: 'research-project',
64
- * organizationId: 'org-123',
65
- * seedSpaceId: 'seed-456',
66
- * public: false
67
- * });
68
- * const name = await space.getName();
69
- * console.log('Space created:', name);
70
- * ```
71
- */
72
- async createSpace(data) {
73
- const token = this.getToken();
74
- const spacerRunUrl = this.getSpacerRunUrl();
75
- const response = await spaces.createSpace(token, data, spacerRunUrl);
76
- return new Space(response.space, this);
77
- }
78
- // ========================================================================
79
- // Notebooks
80
- // ========================================================================
81
- // ========================================================================
82
- // Helper Functions
83
- // ========================================================================
84
- _extractNotebookId(notebookIdOrInstance) {
85
- return typeof notebookIdOrInstance === 'string'
86
- ? notebookIdOrInstance
87
- : notebookIdOrInstance.uid;
88
- }
89
- _extractLexicalId(lexicalIdOrInstance) {
90
- return typeof lexicalIdOrInstance === 'string'
91
- ? lexicalIdOrInstance
92
- : lexicalIdOrInstance.uid;
93
- }
94
- /**
95
- * Create a new notebook.
96
- *
97
- * @param data - Notebook creation parameters
98
- * @returns Promise resolving to created Notebook instance
99
- *
100
- * @example
101
- * ```typescript
102
- * const notebook = await sdk.createNotebook({
103
- * spaceId: 'space-123',
104
- * name: 'Data Analysis',
105
- * description: 'Analysis notebook',
106
- * notebookType: 'jupyter',
107
- * });
108
- * ```
109
- */
110
- async createNotebook(data) {
111
- const spacerRunUrl = this.getSpacerRunUrl();
112
- const token = this.getToken();
113
- const response = await notebooks.createNotebook(token, data, spacerRunUrl);
114
- return new Notebook(response.notebook, this);
115
- }
116
- /**
117
- * Get a notebook by ID or Notebook instance.
118
- *
119
- * @param idOrNotebook - Notebook ID (string) or Notebook instance
120
- * @returns Promise resolving to Notebook instance
121
- *
122
- * @example
123
- * ```typescript
124
- * const notebook = await sdk.getNotebook('notebook-123');
125
- * const refreshed = await sdk.getNotebook(notebook);
126
- * ```
127
- */
128
- async getNotebook(idOrNotebook) {
129
- const notebookId = this._extractNotebookId(idOrNotebook);
130
- const spacerRunUrl = this.getSpacerRunUrl();
131
- const token = this.getToken();
132
- const response = await notebooks.getNotebook(token, notebookId, spacerRunUrl);
133
- if (!response.notebook) {
134
- throw new Error(`Notebook with ID '${notebookId}' not found`);
135
- }
136
- return new Notebook(response.notebook, this);
137
- }
138
- /**
139
- * Update a notebook.
140
- *
141
- * @param idOrNotebook - Notebook ID (string) or Notebook instance
142
- * @param data - Update data with optional name and/or description
143
- * @returns Promise resolving to updated Notebook instance
144
- *
145
- * @example
146
- * ```typescript
147
- * const updated = await sdk.updateNotebook('notebook-123', {
148
- * name: 'Updated Analysis',
149
- * description: 'Updated description'
150
- * });
151
- * const updated2 = await sdk.updateNotebook(notebook, {
152
- * name: 'Updated Analysis',
153
- * description: 'Updated description'
154
- * });
155
- * ```
156
- */
157
- async updateNotebook(idOrNotebook, data) {
158
- const notebookId = this._extractNotebookId(idOrNotebook);
159
- const spacerRunUrl = this.getSpacerRunUrl();
160
- const token = this.getToken();
161
- const response = await notebooks.updateNotebook(token, notebookId, data, spacerRunUrl);
162
- return new Notebook(response.notebook, this);
163
- }
164
- // ========================================================================
165
- // Lexicals
166
- // ========================================================================
167
- /**
168
- * Create a new lexical document.
169
- *
170
- * @param data - Document creation parameters
171
- * @returns Promise resolving to created Lexical instance
172
- *
173
- * @example
174
- * ```typescript
175
- * const lexical = await sdk.createLexical({
176
- * spaceId: 'space-123',
177
- * name: 'Project Documentation',
178
- * description: 'Main project docs',
179
- * documentType: 'document',
180
- * });
181
- * ```
182
- */
183
- async createLexical(data) {
184
- const spacerRunUrl = this.getSpacerRunUrl();
185
- const token = this.getToken();
186
- const response = await lexicals.createLexical(token, data, spacerRunUrl);
187
- return new Lexical(response.document, this);
188
- }
189
- /**
190
- * Get a lexical document by ID or Lexical instance.
191
- *
192
- * @param idOrLexical - Document ID (string) or Lexical instance
193
- * @returns Promise resolving to Lexical instance
194
- *
195
- * @example
196
- * ```typescript
197
- * const lexical = await sdk.getLexical('lexical-123');
198
- * const refreshed = await sdk.getLexical(lexical);
199
- * ```
200
- */
201
- async getLexical(idOrLexical) {
202
- const lexicalId = this._extractLexicalId(idOrLexical);
203
- const spacerRunUrl = this.getSpacerRunUrl();
204
- const token = this.getToken();
205
- const response = await lexicals.getLexical(token, lexicalId, spacerRunUrl);
206
- if (!response.document) {
207
- throw new Error(`Lexical document with ID '${lexicalId}' not found`);
208
- }
209
- return new Lexical(response.document, this);
210
- }
211
- /**
212
- * Update a lexical document.
213
- *
214
- * @param idOrLexical - Document ID (string) or Lexical instance
215
- * @param data - Update data with optional name and/or description
216
- * @returns Promise resolving to updated Lexical instance
217
- *
218
- * @example
219
- * ```typescript
220
- * const updated = await sdk.updateLexical('lexical-123', {
221
- * name: 'Updated Documentation',
222
- * description: 'Updated description'
223
- * });
224
- * const updated2 = await sdk.updateLexical(lexical, {
225
- * name: 'Updated Documentation',
226
- * description: 'Updated description'
227
- * });
228
- * ```
229
- */
230
- async updateLexical(idOrLexical, data) {
231
- const lexicalId = this._extractLexicalId(idOrLexical);
232
- const spacerRunUrl = this.getSpacerRunUrl();
233
- const token = this.getToken();
234
- const response = await lexicals.updateLexical(token, lexicalId, data, spacerRunUrl);
235
- return new Lexical(response.document, this);
236
- }
237
- // ========================================================================
238
- // Items
239
- // ========================================================================
240
- /**
241
- * Get the items of a space.
242
- *
243
- * @param spaceId - Space ID
244
- * @returns Promise resolving to space items
245
- *
246
- * @example
247
- * ```typescript
248
- * const response = await sdk.getSpaceItems('space-123');
249
- * console.log('Space items:', response.items.length);
250
- * response.items.forEach(item => {
251
- * console.log(`- ${item.name} (${item.type})`);
252
- * });
253
- * ```
254
- */
255
- async getSpaceItems(spaceId) {
256
- const spacerRunUrl = this.getSpacerRunUrl();
257
- const token = this.getToken();
258
- return await items.getSpaceItems(token, spaceId, spacerRunUrl);
259
- }
260
- /**
261
- * Delete an item from a space.
262
- *
263
- * @param itemId - Item ID to delete
264
- * @returns Promise resolving when deletion is complete
265
- *
266
- * @example
267
- * ```typescript
268
- * const response = await sdk.deleteSpaceItem('item-123');
269
- * console.log('Item deleted:', response.message);
270
- * ```
271
- */
272
- async deleteSpaceItem(itemId) {
273
- const spacerRunUrl = this.getSpacerRunUrl();
274
- const token = this.getToken();
275
- return await items.deleteItem(token, itemId, spacerRunUrl);
276
- }
277
- };
278
- }
@@ -1,156 +0,0 @@
1
- /**
2
- * @module sdk/client/models/Lexical
3
- * @description Lexical domain model for the Datalayer SDK.
4
- *
5
- * This model provides a rich, object-oriented interface for working with
6
- * Lexical documents, including content management and lifecycle operations.
7
- */
8
- import type { Lexical as LexicalData, UpdateLexicalRequest } from '../../../api/types/spacer';
9
- import type { DatalayerSDK } from '../index';
10
- /**
11
- * Lexical domain model that wraps API responses with convenient methods.
12
- *
13
- * Provides a rich, object-oriented interface for managing Lexical documents
14
- * with automatic data refresh and lifecycle operations.
15
- *
16
- * @example
17
- * ```typescript
18
- * const formData = new FormData();
19
- * formData.append('spaceId', 'space-123');
20
- * formData.append('name', 'Project Documentation');
21
- * const lexical = await sdk.createLexical(formData);
22
- *
23
- * // Static properties - instant access
24
- * console.log(lexical.id);
25
- * console.log(lexical.spaceId);
26
- *
27
- * // Dynamic data - always fresh from API
28
- * const currentName = await lexical.getName();
29
- * const content = await lexical.getContent();
30
- *
31
- * // Update document
32
- * const updated = await lexical.update({ name: 'Updated Documentation' });
33
- * ```
34
- */
35
- export declare class Lexical {
36
- protected _data: LexicalData;
37
- private _sdk;
38
- private _deleted;
39
- private _freshData;
40
- private _lastFetch;
41
- private _cacheTimeout;
42
- /**
43
- * Create a Lexical instance.
44
- *
45
- * @param data - Raw lexical data from API
46
- * @param sdk - DatalayerSDK instance for making API calls
47
- */
48
- constructor(data: LexicalData, sdk: DatalayerSDK);
49
- /**
50
- * Check if this lexical document has been deleted.
51
- */
52
- get isDeleted(): boolean;
53
- /**
54
- * Check if this lexical document has been deleted and throw error if so.
55
- * @throws Error if the document has been deleted
56
- */
57
- private _checkDeleted;
58
- /**
59
- * Get fresh data from API with caching to avoid redundant calls.
60
- * @returns Current LexicalData from API or cache
61
- */
62
- private _getFreshData;
63
- /**
64
- * Lexical document ID.
65
- */
66
- get id(): string;
67
- /**
68
- * Unique identifier for the document.
69
- */
70
- get uid(): string;
71
- /**
72
- * Parent space ID.
73
- */
74
- get spaceId(): string;
75
- /**
76
- * Owner user ID.
77
- */
78
- get ownerId(): string;
79
- /**
80
- * When the document was created.
81
- */
82
- get createdAt(): Date;
83
- /**
84
- * Get the current name of the document.
85
- *
86
- * This method fetches fresh data from the API (with caching) and updates
87
- * the internal data to keep everything in sync.
88
- *
89
- * @returns Promise resolving to current document name
90
- * @throws Error if the document has been deleted
91
- */
92
- getName(): Promise<string>;
93
- /**
94
- * Get the document content.
95
- *
96
- * @returns Promise resolving to document content
97
- */
98
- getContent(): Promise<any>;
99
- /**
100
- * Get when the document was last updated.
101
- *
102
- * @returns Promise resolving to last update time
103
- */
104
- getUpdatedAt(): Promise<Date>;
105
- /**
106
- * Update the document name and/or description.
107
- *
108
- * @param data - Update data containing name and/or description
109
- * @returns Promise resolving to updated Lexical instance
110
- *
111
- * @example
112
- * ```typescript
113
- * const updated = await lexical.update({
114
- * name: 'Updated Documentation',
115
- * description: 'Updated document description'
116
- * });
117
- * ```
118
- */
119
- update(data: UpdateLexicalRequest): Promise<Lexical>;
120
- /**
121
- * Delete this document permanently.
122
- *
123
- * After deletion, this object will be marked as deleted and subsequent
124
- * calls to dynamic methods will throw errors.
125
- *
126
- * @example
127
- * ```typescript
128
- * await lexical.delete();
129
- * console.log('Document deleted');
130
- * // lexical.getName() will now throw an error
131
- * ```
132
- */
133
- delete(): Promise<void>;
134
- /**
135
- * Get raw document data object with latest information.
136
- *
137
- * This method ensures the returned data includes the most recent information
138
- * by refreshing from the API before returning.
139
- *
140
- * @returns Promise resolving to raw document data
141
- *
142
- * @example
143
- * ```typescript
144
- * const latestData = await lexical.toJSON();
145
- * console.log('Current name:', latestData.name);
146
- * ```
147
- */
148
- toJSON(): Promise<LexicalData>;
149
- /**
150
- * String representation of the document.
151
- *
152
- * @returns String representation for logging/debugging
153
- */
154
- toString(): string;
155
- }
156
- export type { LexicalData };