@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
@@ -1,271 +0,0 @@
1
- /**
2
- * Represents a workspace or project space in Datalayer
3
- * @interface Space
4
- */
5
- export interface Space {
6
- id?: string;
7
- 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[];
24
- tags_ss?: string[];
25
- items?: any[];
26
- members?: any[];
27
- }
28
- /**
29
- * Represents a Jupyter notebook document
30
- * @interface Notebook
31
- */
32
- export interface Notebook {
33
- id: string;
34
- 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>;
75
- }
76
- /**
77
- * Request payload for creating a new space
78
- * @interface CreateSpaceRequest
79
- */
80
- export interface CreateSpaceRequest {
81
- name: string;
82
- description: string;
83
- variant: string;
84
- spaceHandle: string;
85
- organizationId: string;
86
- seedSpaceId: string;
87
- public: boolean;
88
- }
89
- /**
90
- * Response from creating a space
91
- * @interface CreateSpaceResponse
92
- */
93
- export interface CreateSpaceResponse {
94
- success: boolean;
95
- message: string;
96
- space: Space;
97
- }
98
- /**
99
- * Request payload for creating a new notebook (multipart/form-data)
100
- * @interface CreateNotebookRequest
101
- */
102
- export interface CreateNotebookRequest {
103
- spaceId: string;
104
- notebookType: string;
105
- name: string;
106
- description: string;
107
- file?: File | Blob;
108
- }
109
- /**
110
- * Response from creating a notebook
111
- * @interface CreateNotebookResponse
112
- */
113
- export interface CreateNotebookResponse {
114
- success: boolean;
115
- message: string;
116
- notebook: Notebook;
117
- }
118
- /**
119
- * Response from getting a notebook
120
- * @interface GetNotebookResponse
121
- */
122
- export interface GetNotebookResponse {
123
- success: boolean;
124
- message: string;
125
- notebook?: Notebook;
126
- }
127
- /**
128
- * Request payload for creating a notebook
129
- * @interface CreateNotebookRequest
130
- */
131
- export interface CreateNotebookRequest {
132
- spaceId: string;
133
- notebookType: string;
134
- name: string;
135
- description: string;
136
- file?: File | Blob;
137
- }
138
- /**
139
- * Request payload for updating a notebook
140
- * @interface UpdateNotebookRequest
141
- */
142
- export interface UpdateNotebookRequest {
143
- name?: string;
144
- description?: string;
145
- }
146
- /**
147
- * Response from updating a notebook
148
- * @interface UpdateNotebookResponse
149
- */
150
- export interface UpdateNotebookResponse {
151
- success: boolean;
152
- message: string;
153
- notebook: Notebook;
154
- }
155
- /**
156
- * Represents an item within a space
157
- * @interface SpaceItem
158
- */
159
- export interface SpaceItem {
160
- id: string;
161
- type: 'notebook' | 'lexical' | 'cell';
162
- space_id: string;
163
- item_id: string;
164
- name: string;
165
- created_at: string;
166
- updated_at?: string;
167
- }
168
- /**
169
- * Represents a Lexical document (rich text editor)
170
- * @interface Lexical
171
- */
172
- export interface Lexical {
173
- id: string;
174
- uid: string;
175
- name?: string;
176
- name_t?: string;
177
- content?: any;
178
- space_id?: string;
179
- owner_id?: string;
180
- creator_uid?: string;
181
- creator_handle_s?: string;
182
- created_at?: string;
183
- creation_ts_dt?: string;
184
- updated_at?: string;
185
- last_update_ts_dt?: string;
186
- type_s?: string;
187
- public_b?: boolean;
188
- description_t?: string;
189
- document_name_s?: string;
190
- document_extension_s?: string;
191
- document_format_s?: string;
192
- content_length_i?: number;
193
- content_type_s?: string;
194
- mime_type_s?: string;
195
- s3_path_s?: string;
196
- s3_url_s?: string;
197
- cdn_url_s?: string;
198
- model_s?: string;
199
- }
200
- /**
201
- * Request payload for creating a Lexical document
202
- * @interface CreateLexicalRequest
203
- */
204
- export interface CreateLexicalRequest {
205
- spaceId: string;
206
- documentType: string;
207
- name: string;
208
- description: string;
209
- file?: File | Blob;
210
- }
211
- /**
212
- * Response from creating a Lexical document
213
- * @interface CreateLexicalResponse
214
- */
215
- export interface CreateLexicalResponse {
216
- success: boolean;
217
- message: string;
218
- document: Lexical;
219
- }
220
- /**
221
- * Response from getting a Lexical document
222
- * @interface GetLexicalResponse
223
- */
224
- export interface GetLexicalResponse {
225
- success: boolean;
226
- message: string;
227
- document?: Lexical;
228
- }
229
- /**
230
- * Request payload for updating a Lexical document
231
- * @interface UpdateLexicalRequest
232
- */
233
- export interface UpdateLexicalRequest {
234
- name?: string;
235
- description?: string;
236
- }
237
- /**
238
- * Response from updating a Lexical document
239
- * @interface UpdateLexicalResponse
240
- */
241
- export interface UpdateLexicalResponse {
242
- success: boolean;
243
- message: string;
244
- document: Lexical;
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 spaces for a user
265
- * @interface SpacesForUserResponse
266
- */
267
- export interface SpacesForUserResponse {
268
- success: boolean;
269
- message: string;
270
- spaces: Space[];
271
- }
@@ -1,5 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,109 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- import { describe, it, expect } from 'vitest';
6
- import { validateToken, validateRequired, validateRequiredString, } from '../validation';
7
- describe('validation utilities', () => {
8
- describe('validateToken', () => {
9
- const validToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjk5OTk5OTk5OTl9.Vg30C57s3l90JNap_VgMhKZjfc-p7SoBXaSAy8c6BS8';
10
- it('should accept valid JWT tokens', () => {
11
- expect(() => validateToken(validToken)).not.toThrow();
12
- });
13
- it('should reject null or undefined tokens', () => {
14
- expect(() => validateToken(null)).toThrow('Authentication token is required');
15
- expect(() => validateToken(undefined)).toThrow('Authentication token is required');
16
- });
17
- it('should reject empty or whitespace tokens', () => {
18
- expect(() => validateToken('')).toThrow('Authentication token is required');
19
- expect(() => validateToken(' ')).toThrow('Authentication token is required');
20
- });
21
- it('should reject tokens without three parts', () => {
22
- expect(() => validateToken('part1.part2')).toThrow('Invalid token format: JWT must have three parts separated by dots');
23
- expect(() => validateToken('part1.part2.part3.part4')).toThrow('Invalid token format: JWT must have three parts separated by dots');
24
- expect(() => validateToken('singlepart')).toThrow('Invalid token format: JWT must have three parts separated by dots');
25
- });
26
- it('should reject tokens with empty parts', () => {
27
- expect(() => validateToken('.part2.part3')).toThrow('Invalid token format: Part 1 is empty');
28
- expect(() => validateToken('part1..part3')).toThrow('Invalid token format: Part 2 is empty');
29
- expect(() => validateToken('part1.part2.')).toThrow('Invalid token format: Part 3 is empty');
30
- });
31
- it('should reject tokens with invalid Base64URL characters', () => {
32
- const invalidCharToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWI!@#$.Vg30C57s3l90JNap_VgMhKZjfc-p7SoBXaSAy8c6BS8';
33
- expect(() => validateToken(invalidCharToken)).toThrow('Invalid token format: Part 2 contains invalid characters');
34
- });
35
- it('should reject tokens that are too short', () => {
36
- const shortToken = 'eyJ0eXAiOiJKV1QifQ.eyJzdWIiOiIxIn0.signature';
37
- expect(() => validateToken(shortToken)).toThrow('Invalid token format: Token is too short to be a valid JWT');
38
- });
39
- it('should reject tokens that are too long', () => {
40
- const header = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9';
41
- const payload = 'a'.repeat(4000);
42
- const signature = 'b'.repeat(1000);
43
- const longToken = `${header}.${payload}.${signature}`;
44
- expect(() => validateToken(longToken)).toThrow('Invalid token format: Token exceeds maximum expected length');
45
- });
46
- it('should reject tokens with invalid JWT header', () => {
47
- const invalidHeaderToken = 'notbase64.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.signature123456789012345';
48
- expect(() => validateToken(invalidHeaderToken)).toThrow('Invalid token format: JWT header is not valid base64-encoded JSON');
49
- });
50
- it('should reject tokens with missing algorithm in header', () => {
51
- // This token has valid JSON header but missing 'alg' field
52
- const noAlgToken = 'eyJ0eXAiOiJKV1QifQ.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjk5OTk5OTk5OTl9.signature123456789012345678901234567890';
53
- expect(() => validateToken(noAlgToken)).toThrow('Invalid token format: Missing algorithm in JWT header');
54
- });
55
- it('should reject tokens with invalid JWT payload', () => {
56
- // This token has enough length but invalid base64 in payload
57
- const invalidPayloadToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.notvalidbase64jsonbutlongenoughtopasslengthchecknotvalidbase64jsonbutlongenough.signature123456789012345678901234567890';
58
- expect(() => validateToken(invalidPayloadToken)).toThrow('Invalid token format: JWT payload is not valid base64-encoded JSON');
59
- });
60
- it('should reject expired tokens', () => {
61
- const expiredToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE1MTYyMzkwMjJ9.4Adcj3UFYzPUVaVF43FmMab6RlaQD8A9V8wFzzht-KQ';
62
- expect(() => validateToken(expiredToken)).toThrow('Token has expired');
63
- });
64
- it('should reject tokens not yet valid (nbf claim)', () => {
65
- const futureToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJuYmYiOjk5OTk5OTk5OTl9.UGLFIRACvGl-MiFpZmAiDuVm7br9tBTxMOqb4sjN-jg';
66
- expect(() => validateToken(futureToken)).toThrow('Token is not yet valid');
67
- });
68
- it('should reject tokens with signature that is too short', () => {
69
- const shortSigToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.short';
70
- expect(() => validateToken(shortSigToken)).toThrow('Invalid token format: JWT signature is too short');
71
- });
72
- it('should trim whitespace from tokens', () => {
73
- const tokenWithWhitespace = ` ${validToken} `;
74
- expect(() => validateToken(tokenWithWhitespace)).not.toThrow();
75
- });
76
- });
77
- describe('validateRequired', () => {
78
- it('should accept valid values', () => {
79
- expect(() => validateRequired('value', 'param')).not.toThrow();
80
- expect(() => validateRequired(0, 'param')).not.toThrow();
81
- expect(() => validateRequired(false, 'param')).not.toThrow();
82
- expect(() => validateRequired('', 'param')).not.toThrow();
83
- });
84
- it('should reject null values', () => {
85
- expect(() => validateRequired(null, 'param')).toThrow('param is required');
86
- });
87
- it('should reject undefined values', () => {
88
- expect(() => validateRequired(undefined, 'param')).toThrow('param is required');
89
- });
90
- });
91
- describe('validateRequiredString', () => {
92
- it('should accept valid strings', () => {
93
- expect(() => validateRequiredString('value', 'param')).not.toThrow();
94
- expect(() => validateRequiredString(' value ', 'param')).not.toThrow();
95
- });
96
- it('should reject null values', () => {
97
- expect(() => validateRequiredString(null, 'param')).toThrow('param is required');
98
- });
99
- it('should reject undefined values', () => {
100
- expect(() => validateRequiredString(undefined, 'param')).toThrow('param is required');
101
- });
102
- it('should reject empty strings', () => {
103
- expect(() => validateRequiredString('', 'param')).toThrow('param is required');
104
- });
105
- it('should reject whitespace-only strings', () => {
106
- expect(() => validateRequiredString(' ', 'param')).toThrow('param is required');
107
- });
108
- });
109
- });
@@ -1,110 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- import { describe, it, expect, beforeAll } from 'vitest';
6
- import { DatalayerSDK } from '..';
7
- import { testConfig } from '../../../__tests__/shared/test-config';
8
- import { DEFAULT_SERVICE_URLS } from '../../../api/constants';
9
- /**
10
- * SDK Health Integration Tests
11
- *
12
- * Tests health check functionality across all Datalayer services
13
- * using the SDK client.
14
- */
15
- describe('SDK Health Integration Tests', () => {
16
- let sdk;
17
- beforeAll(() => {
18
- if (!testConfig.hasToken()) {
19
- return;
20
- }
21
- sdk = new DatalayerSDK({
22
- token: testConfig.getToken(),
23
- iamRunUrl: DEFAULT_SERVICE_URLS.IAM,
24
- runtimesRunUrl: DEFAULT_SERVICE_URLS.RUNTIMES,
25
- spacerRunUrl: DEFAULT_SERVICE_URLS.SPACER,
26
- });
27
- });
28
- describe.skipIf(!testConfig.hasToken())('health check methods', () => {
29
- describe('individual service health checks', () => {
30
- it('should check IAM service health', async () => {
31
- console.log('Testing IAM health check...');
32
- const isHealthy = await sdk.isIAMHealthy();
33
- expect(isHealthy).toBe(true);
34
- console.log(`IAM service is ${isHealthy ? 'healthy' : 'unhealthy'}`);
35
- });
36
- it('should check Runtimes service health', async () => {
37
- console.log('Testing Runtimes health check...');
38
- const isHealthy = await sdk.isRuntimesHealthy();
39
- expect(isHealthy).toBe(true);
40
- console.log(`Runtimes service is ${isHealthy ? 'healthy' : 'unhealthy'}`);
41
- });
42
- it('should check Spacer service health', async () => {
43
- console.log('Testing Spacer health check...');
44
- const isHealthy = await sdk.isSpacerHealthy();
45
- expect(isHealthy).toBe(true);
46
- console.log(`Spacer service is ${isHealthy ? 'healthy' : 'unhealthy'}`);
47
- });
48
- });
49
- describe('combined health checks', () => {
50
- it('should check all services health at once', async () => {
51
- console.log('Testing all services health check...');
52
- const allHealthy = await sdk.areAllServicesHealthy();
53
- expect(allHealthy).toBe(true);
54
- console.log(`All services are ${allHealthy ? 'healthy' : 'not all healthy'}`);
55
- });
56
- it('should get detailed health status for all services', async () => {
57
- console.log('Getting detailed health status...');
58
- const status = await sdk.getHealthStatus();
59
- expect(status).toBeDefined();
60
- expect(status.iam).toBeDefined();
61
- expect(status.runtimes).toBeDefined();
62
- expect(status.spacer).toBeDefined();
63
- expect(status.allHealthy).toBeDefined();
64
- console.log('Health Status:');
65
- console.log(` IAM: ${status.iam.healthy ? '✅' : '❌'}`);
66
- if (status.iam.version) {
67
- console.log(` Version: ${status.iam.version}`);
68
- }
69
- console.log(` Runtimes: ${status.runtimes.healthy ? '✅' : '❌'}`);
70
- if (status.runtimes.version) {
71
- console.log(` Version: ${status.runtimes.version}`);
72
- }
73
- console.log(` Spacer: ${status.spacer.healthy ? '✅' : '❌'}`);
74
- if (status.spacer.version) {
75
- console.log(` Version: ${status.spacer.version}`);
76
- }
77
- console.log(` Overall: ${status.allHealthy ? '✅ All Healthy' : '⚠️ Some Issues'}`);
78
- });
79
- });
80
- describe('error handling', () => {
81
- it('should handle network errors gracefully', async () => {
82
- console.log('Testing health check with invalid URL...');
83
- // Create SDK with invalid URL
84
- const badSdk = new DatalayerSDK({
85
- token: testConfig.getToken(),
86
- iamRunUrl: 'https://invalid.example.com',
87
- runtimesRunUrl: DEFAULT_SERVICE_URLS.RUNTIMES,
88
- spacerRunUrl: DEFAULT_SERVICE_URLS.SPACER,
89
- });
90
- const isHealthy = await badSdk.isIAMHealthy();
91
- expect(isHealthy).toBe(false);
92
- const status = await badSdk.getHealthStatus();
93
- expect(status.iam.healthy).toBe(false);
94
- expect(status.allHealthy).toBe(false);
95
- console.log('Network error handled correctly');
96
- });
97
- });
98
- describe('configuration validation', () => {
99
- it('should use configured service URLs', async () => {
100
- console.log('Verifying SDK uses configured URLs...');
101
- // The SDK should be using the URLs we configured
102
- const config = sdk.getConfig();
103
- expect(config.iamRunUrl).toBe(DEFAULT_SERVICE_URLS.IAM);
104
- expect(config.runtimesRunUrl).toBe(DEFAULT_SERVICE_URLS.RUNTIMES);
105
- expect(config.spacerRunUrl).toBe(DEFAULT_SERVICE_URLS.SPACER);
106
- console.log('SDK configuration verified');
107
- });
108
- });
109
- });
110
- });
@@ -1,179 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- import { describe, it, expect, beforeAll } from 'vitest';
6
- import { DatalayerSDK } from '..';
7
- import { testConfig } from '../../../__tests__/shared/test-config';
8
- import { DEFAULT_SERVICE_URLS } from '../../../api/constants';
9
- /**
10
- * SDK IAM Integration Tests
11
- *
12
- * Tests authentication and identity management functionality
13
- * using the SDK client.
14
- */
15
- describe('SDK IAM Integration Tests', () => {
16
- let sdk;
17
- beforeAll(() => {
18
- if (!testConfig.hasToken()) {
19
- return;
20
- }
21
- sdk = new DatalayerSDK({
22
- token: testConfig.getToken(),
23
- iamRunUrl: DEFAULT_SERVICE_URLS.IAM,
24
- runtimesRunUrl: DEFAULT_SERVICE_URLS.RUNTIMES,
25
- spacerRunUrl: DEFAULT_SERVICE_URLS.SPACER,
26
- });
27
- });
28
- describe.skipIf(!testConfig.hasToken())('IAM authentication methods', () => {
29
- describe('whoami', () => {
30
- it('should get current user profile', async () => {
31
- console.log('Testing whoami...');
32
- const user = await sdk.whoami();
33
- expect(user).toBeDefined();
34
- expect(user.id).toBeDefined();
35
- expect(user.uid).toBeDefined();
36
- expect(user.handle).toBeDefined();
37
- expect(user.roles).toBeDefined();
38
- expect(Array.isArray(user.roles)).toBe(true);
39
- console.log('Current user:');
40
- console.log(` ID: ${user.id}`);
41
- console.log(` UID: ${user.uid}`);
42
- console.log(` Handle: ${user.handle}`);
43
- console.log(` Email: ${user.email || 'Not provided'}`);
44
- console.log(` Name: ${user.first_name} ${user.last_name}`);
45
- console.log(` Roles: ${user.roles.join(', ')}`);
46
- });
47
- it('should include organization info if available', async () => {
48
- console.log('Checking organization info...');
49
- const user = await sdk.whoami();
50
- if (user.organizationIds &&
51
- user.organizationIds.length > 0) {
52
- console.log(`User belongs to ${user.organizationIds.length} organization(s)`);
53
- expect(Array.isArray(user.organizationIds)).toBe(true);
54
- }
55
- else {
56
- console.log('User does not belong to any organizations');
57
- }
58
- });
59
- it('should cache user profile for performance', async () => {
60
- console.log('Testing user profile caching...');
61
- const start1 = Date.now();
62
- const user1 = await sdk.whoami();
63
- const time1 = Date.now() - start1;
64
- const start2 = Date.now();
65
- const user2 = await sdk.whoami();
66
- const time2 = Date.now() - start2;
67
- // Second call should be same or faster (cached)
68
- expect(user2.id).toBe(user1.id);
69
- console.log(`First call: ${time1}ms, Second call: ${time2}ms`);
70
- });
71
- });
72
- describe('login', () => {
73
- it('should handle invalid credentials properly', async () => {
74
- console.log('Testing login with invalid credentials...');
75
- try {
76
- await sdk.login({
77
- handle: 'invalid@example.com',
78
- password: 'wrong-password',
79
- });
80
- // Should not reach here
81
- expect(true).toBe(false);
82
- }
83
- catch (error) {
84
- expect(error).toBeDefined();
85
- console.log('Invalid login rejected correctly');
86
- }
87
- });
88
- it('should validate login request structure', async () => {
89
- console.log('Testing login validation...');
90
- try {
91
- // Missing required fields
92
- await sdk.login({});
93
- expect(true).toBe(false);
94
- }
95
- catch (error) {
96
- expect(error).toBeDefined();
97
- console.log('Invalid login request rejected');
98
- }
99
- });
100
- });
101
- describe('token management', () => {
102
- it('should include token in all API requests', async () => {
103
- console.log('Verifying token is included in requests...');
104
- // Make a request and verify it succeeds (which means token was included)
105
- const user = await sdk.whoami();
106
- expect(user).toBeDefined();
107
- // Verify token is stored in SDK
108
- const token = sdk.getToken();
109
- expect(token).toBe(testConfig.getToken());
110
- console.log('Token management verified');
111
- });
112
- it('should handle expired tokens gracefully', async () => {
113
- console.log('Testing expired token handling...');
114
- const expiredSdk = new DatalayerSDK({
115
- token: 'expired.invalid.token',
116
- iamRunUrl: DEFAULT_SERVICE_URLS.IAM,
117
- runtimesRunUrl: DEFAULT_SERVICE_URLS.RUNTIMES,
118
- spacerRunUrl: DEFAULT_SERVICE_URLS.SPACER,
119
- });
120
- try {
121
- await expiredSdk.whoami();
122
- expect(true).toBe(false);
123
- }
124
- catch (error) {
125
- expect(error).toBeDefined();
126
- console.log('Expired token rejected correctly');
127
- }
128
- });
129
- });
130
- describe('logout', () => {
131
- it('should handle logout operation', async () => {
132
- console.log('Testing logout...');
133
- // Create a separate SDK instance for logout test
134
- const logoutSdk = new DatalayerSDK({
135
- token: testConfig.getToken(),
136
- iamRunUrl: DEFAULT_SERVICE_URLS.IAM,
137
- runtimesRunUrl: DEFAULT_SERVICE_URLS.RUNTIMES,
138
- spacerRunUrl: DEFAULT_SERVICE_URLS.SPACER,
139
- });
140
- // Verify we can make authenticated requests
141
- const userBefore = await logoutSdk.whoami();
142
- expect(userBefore).toBeDefined();
143
- // Note: Actual logout may not invalidate the token server-side
144
- // This tests the logout method exists and can be called
145
- await logoutSdk.logout();
146
- console.log('Logout completed');
147
- // In a real scenario, subsequent requests might fail
148
- // But with API tokens, they typically remain valid until expiry
149
- });
150
- });
151
- describe('error handling', () => {
152
- it('should provide clear error messages for auth failures', async () => {
153
- console.log('Testing auth error messages...');
154
- const invalidSdk = new DatalayerSDK({
155
- token: 'invalid-token',
156
- iamRunUrl: DEFAULT_SERVICE_URLS.IAM,
157
- runtimesRunUrl: DEFAULT_SERVICE_URLS.RUNTIMES,
158
- spacerRunUrl: DEFAULT_SERVICE_URLS.SPACER,
159
- });
160
- try {
161
- await invalidSdk.whoami();
162
- expect(true).toBe(false);
163
- }
164
- catch (error) {
165
- expect(error.message).toBeDefined();
166
- // Error should mention authentication, token, or invalid
167
- const errorLower = error.message.toLowerCase();
168
- expect(errorLower.includes('auth') ||
169
- errorLower.includes('unauth') ||
170
- errorLower.includes('401') ||
171
- errorLower.includes('403') ||
172
- errorLower.includes('invalid') ||
173
- errorLower.includes('token')).toBe(true);
174
- console.log('Auth error message is clear and helpful');
175
- }
176
- });
177
- });
178
- });
179
- });