@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/core",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "type": "module",
5
5
  "workspaces": [
6
6
  ".",
@@ -45,12 +45,14 @@
45
45
  },
46
46
  "scripts": {
47
47
  "dev": "vite",
48
- "build": "gulp resources-to-lib && tsc -b && vite build",
49
- "build:lib": "gulp resources-to-lib && tsc -b",
50
- "build:types": "tsc -b",
48
+ "clean": "rimraf lib dist build tsconfig.tsbuildinfo",
49
+ "clean:lib": "rimraf lib tsconfig.tsbuildinfo",
50
+ "clean:dist": "rimraf dist",
51
+ "build": "npm run clean && gulp resources-to-lib && tsc -b && vite build",
52
+ "build:lib": "npm run clean:lib && gulp resources-to-lib && tsc -b",
53
+ "build:types": "npm run clean:lib && tsc -b",
51
54
  "build:nextjs": "npm run build --workspace=nextjs-notebook-example",
52
- "build:electron": "npm run build --workspace=@datalayer/desktop",
53
- "build:examples": "npm run build:nextjs && npm run build:electron",
55
+ "build:examples": "npm run build:nextjs",
54
56
  "build:all": "npm run build && npm run build:examples",
55
57
  "lint": "eslint . --quiet",
56
58
  "lint:fix": "eslint . --fix",
@@ -68,7 +70,6 @@
68
70
  "check:fix": "npm run format:all && npm run lint:fix && npm run type-check:all",
69
71
  "preview": "vite preview",
70
72
  "start": "vite",
71
- "clean": "rimraf lib tsconfig.tsbuildinfo",
72
73
  "test": "vitest run --project=unit --project=general",
73
74
  "test:watch": "vitest --project=unit --project=general",
74
75
  "test:ui": "vitest --ui --project=unit --project=general",
@@ -81,11 +82,10 @@
81
82
  "typedoc": "typedoc --options typedoc.json --out docs/docs/typescript_api",
82
83
  "watch:lib": "run-p 'watch:lib:*'",
83
84
  "watch:lib:res": "gulp resources-to-lib-watch",
84
- "watch:lib:src": "echo 'Type checking moved to separate command. Use npm run type-check:watch'",
85
+ "watch:lib:src": "tsc -b -w",
85
86
  "type-check:watch": "tsc -b -w --noEmit",
86
87
  "example": "vite --config vite.examples.config.ts",
87
88
  "example:nextjs": "npm run dev --workspace=nextjs-notebook-example",
88
- "example:electron": "cd examples/electron && npm run dev",
89
89
  "prepare": "husky"
90
90
  },
91
91
  "dependencies": {
@@ -101,7 +101,7 @@
101
101
  "@primer/octicons-react": "^19.15.1",
102
102
  "@primer/primitives": "^10.5.0",
103
103
  "@primer/react": "^37.19.0",
104
- "@primer/react-brand": "^0.51.0",
104
+ "@primer/react-brand": "^0.58.0",
105
105
  "@stripe/react-stripe-js": "^2.7.1",
106
106
  "axios": "^1.7.7",
107
107
  "boring-avatars": "^2.0.1",
@@ -118,10 +118,12 @@
118
118
  "react": "18.3.1",
119
119
  "react-confetti": "^6.4.0",
120
120
  "react-dom": "18.3.1",
121
+ "react-toastify": "^11.0.5",
121
122
  "tus-js-client": "^4.2.3",
122
123
  "ulid": "^2.3.0",
123
124
  "unique-names-generator": "^4.7.1",
124
125
  "usehooks-ts": "^2.9.1",
126
+ "uuid": "^13.0.0",
125
127
  "validator": "^13.7.0",
126
128
  "zustand": "^4.4.1"
127
129
  },
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +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 { useCache } from '../hooks';
7
- describe('hooks', () => {
8
- it('should export qfds constant', () => {
9
- expect(useCache).toBeDefined();
10
- });
11
- /*
12
- it('useCache should have correct value', () => {
13
- expect(useCache).toBe('');
14
- });
15
- it('useCache should be a string', () => {
16
- expect(typeof useCache).toBe('string');
17
- });
18
- */
19
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,27 +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 * as coreIndex from '../index';
7
- describe('@datalayer/core - index', () => {
8
- it('should export BackdropContext from hooks', () => {
9
- expect(coreIndex.BackdropContext).toBeDefined();
10
- expect(coreIndex.BackdropContext).toHaveProperty('$$typeof');
11
- expect(typeof coreIndex.BackdropContext).toBe('object');
12
- });
13
- it('should export utils functions', () => {
14
- expect(coreIndex.convertToLargestUnit).toBeDefined();
15
- expect(coreIndex.asArray).toBeDefined();
16
- });
17
- it('should export DatalayerServiceManager from services', () => {
18
- expect(coreIndex.createDatalayerServiceManager).toBeDefined();
19
- expect(typeof coreIndex.createDatalayerServiceManager).toBe('function');
20
- });
21
- it('should have all expected exports', () => {
22
- const exports = Object.keys(coreIndex);
23
- expect(exports).toContain('convertToLargestUnit');
24
- expect(exports).toContain('asArray');
25
- expect(exports).toContain('createDatalayerServiceManager');
26
- });
27
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,57 +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
- describe('@datalayer/core - Integration Tests', () => {
7
- it('should have proper TypeScript compilation', () => {
8
- // This test ensures TypeScript compilation is working
9
- const testNumber = 42;
10
- const testString = 'hello';
11
- const testBoolean = true;
12
- expect(typeof testNumber).toBe('number');
13
- expect(typeof testString).toBe('string');
14
- expect(typeof testBoolean).toBe('boolean');
15
- });
16
- it('should support modern JavaScript features', () => {
17
- // Test arrow functions
18
- const add = (a, b) => a + b;
19
- expect(add(2, 3)).toBe(5);
20
- // Test template literals
21
- const name = 'Datalayer';
22
- const greeting = `Hello, ${name}!`;
23
- expect(greeting).toBe('Hello, Datalayer!');
24
- // Test destructuring
25
- const obj = { x: 1, y: 2 };
26
- const { x, y } = obj;
27
- expect(x).toBe(1);
28
- expect(y).toBe(2);
29
- // Test spread operator
30
- const arr1 = [1, 2, 3];
31
- const arr2 = [...arr1, 4, 5];
32
- expect(arr2).toEqual([1, 2, 3, 4, 5]);
33
- });
34
- it('should support async/await', async () => {
35
- const asyncFunction = async () => {
36
- return new Promise(resolve => {
37
- setTimeout(() => resolve('async result'), 10);
38
- });
39
- };
40
- const result = await asyncFunction();
41
- expect(result).toBe('async result');
42
- });
43
- it('should support generics', () => {
44
- function identity(arg) {
45
- return arg;
46
- }
47
- expect(identity('test')).toBe('test');
48
- expect(identity(123)).toBe(123);
49
- expect(identity(true)).toBe(true);
50
- });
51
- it('should handle error cases', () => {
52
- const throwError = () => {
53
- throw new Error('Test error');
54
- };
55
- expect(throwError).toThrow('Test error');
56
- });
57
- });
@@ -1,4 +0,0 @@
1
- /**
2
- * Shared cleanup logic for both setup and teardown
3
- */
4
- export declare function performCleanup(phase: 'setup' | 'teardown'): Promise<void>;
@@ -1,228 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- import { snapshots, runtimes } from '../../api/runtimes';
6
- import { users, items } from '../../api/spacer';
7
- import { testConfig } from './test-config';
8
- /**
9
- * Shared cleanup logic for both setup and teardown
10
- */
11
- export async function performCleanup(phase) {
12
- const phaseLabel = phase === 'setup' ? 'PRE-TEST' : 'POST-TEST';
13
- console.log('='.repeat(60));
14
- console.log(`${phaseLabel} CLEANUP: Starting ${phase === 'setup' ? 'pre' : 'post'}-test cleanup...`);
15
- console.log('='.repeat(60));
16
- // Check if we have a token
17
- if (!testConfig.hasToken()) {
18
- console.log('WARNING: No Datalayer API token configured - skipping cleanup');
19
- return;
20
- }
21
- const DATALAYER_TOKEN = testConfig.getToken();
22
- const RUNTIMES_BASE_URL = testConfig.getBaseUrl('RUNTIMES');
23
- const SPACER_BASE_URL = testConfig.getBaseUrl('SPACER');
24
- // Clean up runtimes
25
- await cleanupRuntimes(DATALAYER_TOKEN, RUNTIMES_BASE_URL, phaseLabel);
26
- // Clean up test snapshots
27
- await cleanupTestSnapshots(DATALAYER_TOKEN, RUNTIMES_BASE_URL, phaseLabel);
28
- // Clean up ALL spacer items (notebooks, lexicals, etc.)
29
- await cleanupSpacerItems(DATALAYER_TOKEN, SPACER_BASE_URL, phaseLabel);
30
- // Final verification (only for teardown)
31
- if (phase === 'teardown') {
32
- await verifyFinalState(DATALAYER_TOKEN, RUNTIMES_BASE_URL, SPACER_BASE_URL);
33
- }
34
- console.log('='.repeat(60));
35
- console.log(`${phaseLabel} CLEANUP: ${phase === 'setup' ? 'Pre' : 'Post'}-test cleanup completed`);
36
- console.log('='.repeat(60));
37
- }
38
- async function cleanupRuntimes(token, baseUrl, phaseLabel) {
39
- try {
40
- console.log(`Cleaning up ${phaseLabel === 'PRE-TEST' ? 'existing' : 'test'} runtimes...`);
41
- const runtimesResponse = await runtimes.listRuntimes(token, baseUrl);
42
- if (!runtimesResponse.runtimes || runtimesResponse.runtimes.length === 0) {
43
- console.log('✓ No runtimes to clean up');
44
- return;
45
- }
46
- console.log(`Found ${runtimesResponse.runtimes.length} runtime(s) to clean up`);
47
- let removedCount = 0;
48
- let failedCount = 0;
49
- for (const runtime of runtimesResponse.runtimes) {
50
- try {
51
- await runtimes.deleteRuntime(token, runtime.pod_name, baseUrl);
52
- console.log(` ✓ Removed runtime: ${runtime.pod_name}`);
53
- removedCount++;
54
- }
55
- catch (error) {
56
- console.log(` ✗ Failed to remove runtime ${runtime.pod_name}: ${error.message}`);
57
- failedCount++;
58
- }
59
- }
60
- if (removedCount > 0 || failedCount > 0) {
61
- console.log(`Runtime cleanup summary: ${removedCount} removed, ${failedCount} failed`);
62
- }
63
- }
64
- catch (error) {
65
- console.error('Error cleaning up runtimes:', error.message);
66
- }
67
- }
68
- async function cleanupTestSnapshots(token, baseUrl, phaseLabel) {
69
- try {
70
- console.log(`Cleaning up ALL snapshots${phaseLabel === 'POST-TEST' ? ' created during tests' : ''}...`);
71
- const snapshotsResponse = await snapshots.listSnapshots(token, baseUrl);
72
- if (!snapshotsResponse.snapshots ||
73
- snapshotsResponse.snapshots.length === 0) {
74
- console.log('✓ No snapshots found');
75
- return;
76
- }
77
- // Filter out already deleted snapshots
78
- const allSnapshots = snapshotsResponse.snapshots.filter(s => s.status !== 'deleted');
79
- if (allSnapshots.length === 0) {
80
- const deletedCount = snapshotsResponse.snapshots.filter(s => s.status === 'deleted').length;
81
- if (deletedCount > 0) {
82
- console.log(`Found ${deletedCount} already deleted snapshot(s), skipping`);
83
- }
84
- console.log('✓ No active snapshots to clean up');
85
- return;
86
- }
87
- console.log(`Found ${allSnapshots.length} active snapshot(s) to clean up`);
88
- let removedCount = 0;
89
- let skippedCount = 0;
90
- let failedCount = 0;
91
- for (const snapshot of allSnapshots) {
92
- try {
93
- console.log(` Attempting to delete: ${snapshot.name} (uid: ${snapshot.uid}, status: ${snapshot.status})`);
94
- await snapshots.deleteSnapshot(token, snapshot.uid, baseUrl);
95
- console.log(` ✓ Removed snapshot: ${snapshot.name}`);
96
- removedCount++;
97
- }
98
- catch (error) {
99
- if (error.message?.includes('404') ||
100
- error.message?.includes('not found')) {
101
- console.log(` - Already removed: ${snapshot.name}`);
102
- skippedCount++;
103
- }
104
- else {
105
- console.log(` ✗ Failed to remove snapshot ${snapshot.name}: ${error.message}`);
106
- failedCount++;
107
- }
108
- }
109
- }
110
- if (removedCount > 0 || skippedCount > 0 || failedCount > 0) {
111
- console.log(`Snapshot cleanup summary: ${removedCount} removed, ${skippedCount} skipped, ${failedCount} failed`);
112
- // Verify snapshots are actually deleted
113
- console.log('Verifying snapshot deletion...');
114
- const verifyResponse = await snapshots.listSnapshots(token, baseUrl);
115
- const remainingCount = verifyResponse.snapshots?.length || 0;
116
- console.log(` Remaining snapshots after cleanup: ${remainingCount}`);
117
- if (remainingCount > 0 && verifyResponse.snapshots) {
118
- console.log(' Still present:');
119
- for (const snap of verifyResponse.snapshots.slice(0, 5)) {
120
- console.log(` - ${snap.name} (uid: ${snap.uid}, status: ${snap.status})`);
121
- }
122
- if (verifyResponse.snapshots.length > 5) {
123
- console.log(` ... and ${verifyResponse.snapshots.length - 5} more`);
124
- }
125
- }
126
- }
127
- }
128
- catch (error) {
129
- console.error('Error cleaning up snapshots:', error.message);
130
- }
131
- }
132
- async function cleanupSpacerItems(token, baseUrl, phaseLabel) {
133
- try {
134
- console.log(`Cleaning up ALL spacer items${phaseLabel === 'POST-TEST' ? ' (complete cleanup)' : ''}...`);
135
- // Get user spaces
136
- const spacesResponse = await users.getMySpaces(token, baseUrl);
137
- if (!spacesResponse.spaces || spacesResponse.spaces.length === 0) {
138
- console.log('✓ No spaces found');
139
- return;
140
- }
141
- console.log(`Found ${spacesResponse.spaces.length} space(s)`);
142
- let totalRemovedCount = 0;
143
- let totalFailedCount = 0;
144
- // Go through each space and clean up test items
145
- for (const space of spacesResponse.spaces) {
146
- try {
147
- const itemsResponse = await items.getSpaceItems(token, space.uid, baseUrl);
148
- if (!itemsResponse.items || itemsResponse.items.length === 0) {
149
- continue;
150
- }
151
- const spaceName = space.name || space.name_t || 'Unknown Space';
152
- console.log(` Space "${spaceName}": Found ${itemsResponse.items.length} item(s) to clean up`);
153
- for (const item of itemsResponse.items) {
154
- try {
155
- // API returns uid field but TypeScript interface doesn't include it
156
- await items.deleteItem(token, item.uid, baseUrl);
157
- console.log(` ✓ Removed item: ${item.name || item.name_t}`);
158
- totalRemovedCount++;
159
- }
160
- catch (error) {
161
- console.log(` ✗ Failed to remove item ${item.name || item.name_t}: ${error.message}`);
162
- totalFailedCount++;
163
- }
164
- }
165
- }
166
- catch (error) {
167
- const spaceName = space.name || space.name_t || 'Unknown Space';
168
- console.log(` Error processing space ${spaceName}: ${error.message}`);
169
- }
170
- }
171
- if (totalRemovedCount > 0 || totalFailedCount > 0) {
172
- console.log(`Spacer items cleanup summary: ${totalRemovedCount} removed, ${totalFailedCount} failed`);
173
- }
174
- else {
175
- console.log('✓ No spacer items to clean up');
176
- }
177
- }
178
- catch (error) {
179
- console.error('Error cleaning up spacer items:', error.message);
180
- }
181
- }
182
- async function verifyFinalState(token, runtimesBaseUrl, spacerBaseUrl) {
183
- try {
184
- const finalRuntimes = await runtimes.listRuntimes(token, runtimesBaseUrl);
185
- const finalSnapshots = await snapshots.listSnapshots(token, runtimesBaseUrl);
186
- const remainingRuntimes = finalRuntimes.runtimes?.length || 0;
187
- const remainingSnapshots = (finalSnapshots.snapshots || []).filter(s => s.status !== 'deleted').length;
188
- // Count spacer test items
189
- let remainingTestItems = 0;
190
- try {
191
- const spacesResponse = await users.getMySpaces(token, spacerBaseUrl);
192
- if (spacesResponse.spaces) {
193
- for (const space of spacesResponse.spaces) {
194
- try {
195
- const itemsResponse = await items.getSpaceItems(token, space.uid, spacerBaseUrl);
196
- if (itemsResponse.items) {
197
- remainingTestItems += itemsResponse.items.length;
198
- }
199
- }
200
- catch (error) {
201
- // Ignore errors for individual spaces
202
- }
203
- }
204
- }
205
- }
206
- catch (error) {
207
- // Ignore errors
208
- }
209
- console.log('-'.repeat(60));
210
- console.log('Final state after all tests:');
211
- console.log(` - Remaining runtimes: ${remainingRuntimes}`);
212
- console.log(` - Remaining active snapshots: ${remainingSnapshots}`);
213
- console.log(` - Total snapshots: ${finalSnapshots.snapshots?.length || 0}`);
214
- console.log(` - Remaining spacer items: ${remainingTestItems}`);
215
- if (remainingRuntimes > 0) {
216
- console.log(`\nNOTE: ${remainingRuntimes} runtime(s) still active. These may require manual cleanup.`);
217
- }
218
- if (remainingSnapshots > 0) {
219
- console.log(`\nNOTE: ${remainingSnapshots} snapshot(s) still active. These may require manual cleanup.`);
220
- }
221
- if (remainingTestItems > 0) {
222
- console.log(`\nNOTE: ${remainingTestItems} spacer item(s) still active. These may require manual cleanup.`);
223
- }
224
- }
225
- catch (error) {
226
- console.error('Error during final verification:', error.message);
227
- }
228
- }
@@ -1,51 +0,0 @@
1
- /**
2
- * Test configuration object with proper fallbacks
3
- */
4
- export declare const testConfig: {
5
- /**
6
- * Check if we have a token available
7
- */
8
- hasToken(): boolean;
9
- /**
10
- * Get the Datalayer API token for testing
11
- * Priority order:
12
- * 1. DATALAYER_TEST_TOKEN environment variable
13
- * 2. DATALAYER_API_TOKEN environment variable
14
- * 3. VITE_DATALAYER_API_TOKEN environment variable
15
- * 4. Throw error if not found
16
- */
17
- getToken(): string;
18
- /**
19
- * Get the base URL for testing
20
- * Uses DEFAULT_SERVICE_URLS or can be overridden via environment
21
- */
22
- getBaseUrl(service?: "IAM" | "RUNTIMES" | "SPACER"): string;
23
- /**
24
- * Check if expensive tests should be skipped
25
- * Default is false (run expensive tests) unless explicitly set to 'true'
26
- */
27
- shouldSkipExpensive(): boolean;
28
- /**
29
- * Get test environment names for runtime creation
30
- */
31
- getTestEnvironments(): {
32
- python: string;
33
- ai: string;
34
- };
35
- /**
36
- * Check if debug output is enabled
37
- */
38
- isDebugEnabled(): boolean;
39
- /**
40
- * Get custom timeout for API calls (in milliseconds)
41
- */
42
- getTimeout(): number;
43
- };
44
- /**
45
- * Helper function to skip tests if no token is available
46
- */
47
- export declare const skipIfNoToken: () => boolean;
48
- /**
49
- * Log debug information if debug is enabled
50
- */
51
- export declare const debugLog: (...args: any[]) => void;
@@ -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 * as dotenv from 'dotenv';
6
- import * as path from 'path';
7
- import { DEFAULT_SERVICE_URLS } from '../../api/constants';
8
- /**
9
- * Load test environment configuration
10
- * Loads from .env.test file and falls back to environment variables
11
- */
12
- const loadTestConfig = () => {
13
- // Load .env.test file from project root
14
- const testEnvPath = path.resolve(process.cwd(), '.env.test');
15
- dotenv.config({ path: testEnvPath });
16
- // Also load regular .env as fallback
17
- dotenv.config();
18
- };
19
- // Load config immediately when module is imported
20
- loadTestConfig();
21
- /**
22
- * Test configuration object with proper fallbacks
23
- */
24
- export const testConfig = {
25
- /**
26
- * Check if we have a token available
27
- */
28
- hasToken() {
29
- return !!(process.env.DATALAYER_TEST_TOKEN ||
30
- process.env.DATALAYER_API_TOKEN ||
31
- process.env.VITE_DATALAYER_API_TOKEN);
32
- },
33
- /**
34
- * Get the Datalayer API token for testing
35
- * Priority order:
36
- * 1. DATALAYER_TEST_TOKEN environment variable
37
- * 2. DATALAYER_API_TOKEN environment variable
38
- * 3. VITE_DATALAYER_API_TOKEN environment variable
39
- * 4. Throw error if not found
40
- */
41
- getToken() {
42
- const token = process.env.DATALAYER_TEST_TOKEN ||
43
- process.env.DATALAYER_API_TOKEN ||
44
- process.env.VITE_DATALAYER_API_TOKEN;
45
- if (!token) {
46
- throw new Error('No Datalayer API token found. Please set DATALAYER_TEST_TOKEN, DATALAYER_API_TOKEN, or VITE_DATALAYER_API_TOKEN environment variable');
47
- }
48
- return token;
49
- },
50
- /**
51
- * Get the base URL for testing
52
- * Uses DEFAULT_SERVICE_URLS or can be overridden via environment
53
- */
54
- getBaseUrl(service = 'IAM') {
55
- const envBaseUrl = process.env.DATALAYER_TEST_BASE_URL;
56
- if (envBaseUrl) {
57
- return envBaseUrl;
58
- }
59
- return DEFAULT_SERVICE_URLS[service];
60
- },
61
- /**
62
- * Check if expensive tests should be skipped
63
- * Default is false (run expensive tests) unless explicitly set to 'true'
64
- */
65
- shouldSkipExpensive() {
66
- return process.env.DATALAYER_TEST_SKIP_EXPENSIVE === 'true';
67
- },
68
- /**
69
- * Get test environment names for runtime creation
70
- */
71
- getTestEnvironments() {
72
- return {
73
- python: process.env.DATALAYER_TEST_PYTHON_ENV || 'python-cpu-env',
74
- ai: process.env.DATALAYER_TEST_AI_ENV || 'ai-env',
75
- };
76
- },
77
- /**
78
- * Check if debug output is enabled
79
- */
80
- isDebugEnabled() {
81
- return process.env.DATALAYER_TEST_DEBUG === 'true';
82
- },
83
- /**
84
- * Get custom timeout for API calls (in milliseconds)
85
- */
86
- getTimeout() {
87
- const timeout = process.env.DATALAYER_TEST_TIMEOUT;
88
- return timeout ? parseInt(timeout, 10) : 60000; // Default 60 seconds
89
- },
90
- };
91
- /**
92
- * Helper function to skip tests if no token is available
93
- */
94
- export const skipIfNoToken = () => {
95
- try {
96
- testConfig.getToken();
97
- return false;
98
- }
99
- catch {
100
- return true;
101
- }
102
- };
103
- /**
104
- * Log debug information if debug is enabled
105
- */
106
- export const debugLog = (...args) => {
107
- if (testConfig.isDebugEnabled()) {
108
- console.log('[DEBUG]', ...args);
109
- }
110
- };
@@ -1,66 +0,0 @@
1
- /**
2
- * Test constants for API unit tests
3
- */
4
- /**
5
- * A valid mock JWT token for testing
6
- * This token has the correct JWT structure (header.payload.signature) but is not cryptographically valid
7
- *
8
- * Decoded header: {"alg":"HS256","typ":"JWT"}
9
- * Decoded payload: {"sub":"test-user","iss":"test-issuer","iat":1700000000,"exp":9999999999,"aud":"test-audience"}
10
- *
11
- * The token is constructed to:
12
- * - Have three parts separated by dots
13
- * - Have valid base64url encoded parts
14
- * - Have proper JWT header with alg and typ
15
- * - Have common JWT claims in payload
16
- * - Have an expiration far in the future to avoid expiration errors
17
- * - Be long enough to pass length validation (>100 chars)
18
- */
19
- export declare const MOCK_JWT_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0LXVzZXIiLCJpc3MiOiJ0ZXN0LWlzc3VlciIsImlhdCI6MTcwMDAwMDAwMCwiZXhwIjo5OTk5OTk5OTk5LCJhdWQiOiJ0ZXN0LWF1ZGllbmNlIn0.abcdefghijklmnopqrstuvwxyz012345678901234567890";
20
- /**
21
- * An invalid token (not JWT format) for negative testing
22
- */
23
- export declare const INVALID_TOKEN = "invalid-token";
24
- /**
25
- * A malformed JWT token (only two parts instead of three)
26
- */
27
- export declare const MALFORMED_JWT_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0LXVzZXIifQ";
28
- /**
29
- * A JWT token with an expired timestamp
30
- * Decoded payload: {"sub":"test-user","exp":1000000000}
31
- */
32
- export declare const EXPIRED_JWT_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0LXVzZXIiLCJleHAiOjEwMDAwMDAwMDB9.abcdefghijklmnopqrstuvwxyz012345678901234567890";
33
- /**
34
- * Mock API responses
35
- */
36
- export declare const MOCK_ENVIRONMENTS_RESPONSE: {
37
- success: boolean;
38
- message: string;
39
- environments: {
40
- title: string;
41
- description: string;
42
- dockerImage: string;
43
- language: string;
44
- burning_rate: number;
45
- }[];
46
- };
47
- export declare const MOCK_RUNTIME_RESPONSE: {
48
- success: boolean;
49
- message: string;
50
- runtime: {
51
- pod_name: string;
52
- status: string;
53
- environment: string;
54
- created_at: string;
55
- };
56
- };
57
- export declare const MOCK_SNAPSHOT_RESPONSE: {
58
- success: boolean;
59
- message: string;
60
- snapshot: {
61
- id: string;
62
- name: string;
63
- created_at: string;
64
- size: number;
65
- };
66
- };