@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.
- package/README.md +2 -2
- package/lib/api/DatalayerApi.d.ts +38 -26
- package/lib/api/DatalayerApi.js +52 -13
- package/lib/api/iam/authentication.d.ts +9 -8
- package/lib/api/iam/authentication.js +14 -15
- package/lib/api/iam/healthz.d.ts +3 -2
- package/lib/api/iam/healthz.js +5 -3
- package/lib/api/iam/index.d.ts +9 -4
- package/lib/api/iam/index.js +9 -4
- package/lib/api/iam/oauth2.d.ts +115 -0
- package/lib/api/iam/oauth2.js +309 -0
- package/lib/api/iam/profile.d.ts +8 -1
- package/lib/api/iam/profile.js +17 -2
- package/lib/api/iam/usage.d.ts +18 -0
- package/lib/api/iam/usage.js +39 -0
- package/lib/api/index.d.ts +6 -6
- package/lib/api/index.js +6 -7
- package/lib/api/runtimes/environments.d.ts +2 -2
- package/lib/api/runtimes/environments.js +3 -2
- package/lib/api/runtimes/healthz.d.ts +3 -13
- package/lib/api/runtimes/healthz.js +4 -3
- package/lib/api/runtimes/index.d.ts +3 -2
- package/lib/api/runtimes/index.js +3 -2
- package/lib/api/runtimes/runtimes.d.ts +4 -4
- package/lib/api/runtimes/runtimes.js +17 -6
- package/lib/api/runtimes/snapshots.d.ts +4 -4
- package/lib/api/runtimes/snapshots.js +3 -2
- package/lib/api/spacer/documents.d.ts +12 -0
- package/lib/api/spacer/documents.js +43 -0
- package/lib/api/spacer/healthz.d.ts +3 -13
- package/lib/api/spacer/healthz.js +4 -3
- package/lib/api/spacer/index.d.ts +4 -2
- package/lib/api/spacer/index.js +4 -2
- package/lib/api/spacer/items.d.ts +9 -1
- package/lib/api/spacer/items.js +17 -2
- package/lib/api/spacer/lexicals.d.ts +1 -1
- package/lib/api/spacer/lexicals.js +3 -2
- package/lib/api/spacer/notebooks.d.ts +1 -1
- package/lib/api/spacer/notebooks.js +3 -2
- package/lib/api/spacer/spaces.d.ts +1 -1
- package/lib/api/spacer/spaces.js +3 -2
- package/lib/api/spacer/users.d.ts +1 -1
- package/lib/api/spacer/users.js +3 -2
- package/lib/api/utils/validation.d.ts +24 -1
- package/lib/api/utils/validation.js +62 -1
- package/lib/client/base.d.ts +75 -0
- package/lib/client/base.js +199 -0
- package/lib/client/constants.d.ts +22 -0
- package/lib/client/constants.js +22 -0
- package/lib/client/index.d.ts +108 -0
- package/lib/client/index.js +79 -0
- package/lib/client/mixins/IAMMixin.d.ts +54 -0
- package/lib/client/mixins/IAMMixin.js +181 -0
- package/lib/client/mixins/RuntimesMixin.d.ts +93 -0
- package/lib/client/mixins/RuntimesMixin.js +229 -0
- package/lib/client/mixins/SpacerMixin.d.ts +111 -0
- package/lib/client/mixins/SpacerMixin.js +340 -0
- package/lib/client/utils/mixins.d.ts +12 -0
- package/lib/{sdk/client → client}/utils/mixins.js +0 -28
- package/lib/client/utils/spacerUtils.d.ts +18 -0
- package/lib/client/utils/spacerUtils.js +32 -0
- package/lib/collaboration/DatalayerCollaboration.d.ts +6 -1
- package/lib/collaboration/DatalayerCollaboration.js +2 -2
- package/lib/collaboration/DatalayerCollaborationProvider.d.ts +5 -0
- package/lib/collaboration/DatalayerCollaborationProvider.js +10 -9
- package/lib/components/progress/CreditsIndicator.d.ts +1 -1
- package/lib/components/runtimes/RuntimeCellVariablesDialog.js +1 -1
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +1 -1
- package/lib/components/runtimes/RuntimeLauncherDialog.js +2 -2
- package/lib/components/runtimes/RuntimePickerBase.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerBase.js +1 -1
- package/lib/components/runtimes/RuntimePickerCell.js +3 -3
- package/lib/components/runtimes/RuntimePickerNotebook.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerNotebook.js +2 -2
- package/lib/components/runtimes/RuntimeTransfer.d.ts +2 -2
- package/lib/components/runtimes/RuntimeUtils.d.ts +1 -1
- package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -1
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +27 -20
- package/lib/config/Configuration.d.ts +8 -0
- package/lib/hooks/useDatalayer.js +1 -1
- package/lib/hooks/useRuntimes.js +1 -1
- package/lib/hooks/useToast.js +1 -1
- package/lib/index.d.ts +2 -3
- package/lib/index.js +4 -3
- package/lib/models/Common.d.ts +64 -0
- package/lib/models/CreditsDTO.d.ts +124 -0
- package/lib/models/CreditsDTO.js +135 -0
- package/lib/models/Environment.d.ts +1 -1
- package/lib/models/EnvironmentDTO.d.ts +125 -0
- package/lib/models/EnvironmentDTO.js +88 -0
- package/lib/models/HealthCheck.d.ts +72 -0
- package/lib/models/HealthCheck.js +107 -0
- package/lib/{api/types/iam.d.ts → models/IAM.d.ts} +15 -78
- package/lib/models/ItemDTO.d.ts +74 -0
- package/lib/models/ItemDTO.js +186 -0
- package/lib/models/LexicalDTO.d.ts +155 -0
- package/lib/models/LexicalDTO.js +157 -0
- package/lib/models/NotebookDTO.d.ts +96 -0
- package/lib/models/NotebookDTO.js +153 -0
- package/lib/models/Profile.d.ts +65 -0
- package/lib/models/RuntimeDTO.d.ts +191 -0
- package/lib/models/RuntimeDTO.js +204 -0
- package/lib/models/RuntimeSnapshotDTO.d.ts +173 -0
- package/lib/models/RuntimeSnapshotDTO.js +139 -0
- package/lib/models/SpaceDTO.d.ts +280 -0
- package/lib/models/SpaceDTO.js +239 -0
- package/lib/models/UserDTO.d.ts +86 -0
- package/lib/models/UserDTO.js +84 -0
- package/lib/models/index.d.ts +45 -4
- package/lib/models/index.js +45 -4
- package/lib/sdk/index.d.ts +5 -4
- package/lib/sdk/index.js +6 -5
- package/lib/services/DatalayerServiceManager.js +1 -1
- package/lib/state/substates/CoreState.js +2 -0
- package/lib/state/substates/RuntimesState.d.ts +1 -1
- package/lib/state/substates/RuntimesState.js +1 -1
- package/lib/{sdk/stateful → stateful}/index.d.ts +1 -1
- package/lib/{sdk/stateful → stateful}/index.js +1 -1
- package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.d.ts +1 -41
- package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.js +1 -20
- package/lib/{sdk/stateful → stateful}/runtimes/actions.d.ts +3 -3
- package/lib/{sdk/stateful → stateful}/runtimes/actions.js +8 -8
- package/lib/{sdk/stateful → stateful}/runtimes/apis.d.ts +8 -8
- package/package.json +13 -10
- package/lib/__tests__/hooks.test.d.ts +0 -1
- package/lib/__tests__/hooks.test.js +0 -19
- package/lib/__tests__/index.test.d.ts +0 -1
- package/lib/__tests__/index.test.js +0 -27
- package/lib/__tests__/integration.test.d.ts +0 -1
- package/lib/__tests__/integration.test.js +0 -57
- package/lib/__tests__/shared/cleanup-shared.d.ts +0 -4
- package/lib/__tests__/shared/cleanup-shared.js +0 -228
- package/lib/__tests__/shared/test-config.d.ts +0 -51
- package/lib/__tests__/shared/test-config.js +0 -110
- package/lib/__tests__/shared/test-constants.d.ts +0 -66
- package/lib/__tests__/shared/test-constants.js +0 -79
- package/lib/__tests__/utils.test.d.ts +0 -1
- package/lib/__tests__/utils.test.js +0 -59
- package/lib/api/__tests__/iam.authentication.integration.test.d.ts +0 -1
- package/lib/api/__tests__/iam.authentication.integration.test.js +0 -247
- package/lib/api/__tests__/iam.healthz.integration.test.d.ts +0 -1
- package/lib/api/__tests__/iam.healthz.integration.test.js +0 -63
- package/lib/api/__tests__/iam.profile.integration.test.d.ts +0 -1
- package/lib/api/__tests__/iam.profile.integration.test.js +0 -252
- package/lib/api/__tests__/runtimes.environments.integration.test.d.ts +0 -1
- package/lib/api/__tests__/runtimes.environments.integration.test.js +0 -122
- package/lib/api/__tests__/runtimes.healthz.integration.test.d.ts +0 -1
- package/lib/api/__tests__/runtimes.healthz.integration.test.js +0 -50
- package/lib/api/__tests__/runtimes.integration.test.d.ts +0 -1
- package/lib/api/__tests__/runtimes.integration.test.js +0 -369
- package/lib/api/__tests__/spacer.healthz.integration.test.d.ts +0 -1
- package/lib/api/__tests__/spacer.healthz.integration.test.js +0 -50
- package/lib/api/__tests__/spacer.integration.test.d.ts +0 -1
- package/lib/api/__tests__/spacer.integration.test.js +0 -519
- package/lib/api/iam/__tests__/authentication.unit.test.d.ts +0 -1
- package/lib/api/iam/__tests__/authentication.unit.test.js +0 -63
- package/lib/api/iam/__tests__/healthz.unit.test.d.ts +0 -1
- package/lib/api/iam/__tests__/healthz.unit.test.js +0 -60
- package/lib/api/iam/__tests__/profile.unit.test.d.ts +0 -1
- package/lib/api/iam/__tests__/profile.unit.test.js +0 -57
- package/lib/api/runtimes/__tests__/environments.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/environments.unit.test.js +0 -77
- package/lib/api/runtimes/__tests__/healthz.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/healthz.unit.test.js +0 -57
- package/lib/api/runtimes/__tests__/runtimes.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/runtimes.unit.test.js +0 -139
- package/lib/api/runtimes/__tests__/snapshots.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/snapshots.unit.test.js +0 -96
- package/lib/api/spacer/__tests__/healthz.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/healthz.unit.test.js +0 -57
- package/lib/api/spacer/__tests__/items.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/items.unit.test.js +0 -165
- package/lib/api/spacer/__tests__/lexicals.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/lexicals.unit.test.js +0 -323
- package/lib/api/spacer/__tests__/notebooks.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/notebooks.unit.test.js +0 -224
- package/lib/api/spacer/__tests__/users.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/users.unit.test.js +0 -132
- package/lib/api/types/index.d.ts +0 -32
- package/lib/api/types/index.js +0 -36
- package/lib/api/types/runtimes.d.ts +0 -235
- package/lib/api/types/spacer.d.ts +0 -271
- package/lib/api/types/spacer.js +0 -5
- package/lib/api/utils/__tests__/validation.test.d.ts +0 -1
- package/lib/api/utils/__tests__/validation.test.js +0 -109
- package/lib/sdk/client/__tests__/sdk.health.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.health.integration.test.js +0 -110
- package/lib/sdk/client/__tests__/sdk.iam.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.iam.integration.test.js +0 -179
- package/lib/sdk/client/__tests__/sdk.models.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.models.integration.test.js +0 -376
- package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.js +0 -276
- package/lib/sdk/client/__tests__/sdk.spacer.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.spacer.integration.test.js +0 -361
- package/lib/sdk/client/base.d.ts +0 -88
- package/lib/sdk/client/base.js +0 -112
- package/lib/sdk/client/index.d.ts +0 -192
- package/lib/sdk/client/index.js +0 -128
- package/lib/sdk/client/mixins/HealthMixin.d.ts +0 -100
- package/lib/sdk/client/mixins/HealthMixin.js +0 -133
- package/lib/sdk/client/mixins/IAMMixin.d.ts +0 -59
- package/lib/sdk/client/mixins/IAMMixin.js +0 -83
- package/lib/sdk/client/mixins/RuntimesMixin.d.ts +0 -134
- package/lib/sdk/client/mixins/RuntimesMixin.js +0 -221
- package/lib/sdk/client/mixins/SpacerMixin.d.ts +0 -184
- package/lib/sdk/client/mixins/SpacerMixin.js +0 -278
- package/lib/sdk/client/models/Lexical.d.ts +0 -156
- package/lib/sdk/client/models/Lexical.js +0 -275
- package/lib/sdk/client/models/Notebook.d.ts +0 -174
- package/lib/sdk/client/models/Notebook.js +0 -311
- package/lib/sdk/client/models/Runtime.d.ts +0 -221
- package/lib/sdk/client/models/Runtime.js +0 -341
- package/lib/sdk/client/models/Snapshot.d.ts +0 -156
- package/lib/sdk/client/models/Snapshot.js +0 -244
- package/lib/sdk/client/models/Space.d.ts +0 -182
- package/lib/sdk/client/models/Space.js +0 -276
- package/lib/sdk/client/models/__tests__/Lexical.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Lexical.test.js +0 -288
- package/lib/sdk/client/models/__tests__/Notebook.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Notebook.test.js +0 -206
- package/lib/sdk/client/models/__tests__/Runtime.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Runtime.test.js +0 -133
- package/lib/sdk/client/models/__tests__/Snapshot.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Snapshot.test.js +0 -244
- package/lib/sdk/client/models/__tests__/Space.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Space.test.js +0 -334
- package/lib/sdk/client/models/index.d.ts +0 -30
- package/lib/sdk/client/models/index.js +0 -30
- package/lib/sdk/client/utils/mixins.d.ts +0 -42
- /package/lib/{api/types/iam.js → models/Common.js} +0 -0
- /package/lib/{api/types/runtimes.js → models/IAM.js} +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.js +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.js +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/index.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/index.js +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/apis.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/index.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/index.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/settings.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/settings.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/utils.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/utils.js +0 -0
|
@@ -1,361 +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, afterAll } from 'vitest';
|
|
6
|
-
import { DatalayerSDK } from '..';
|
|
7
|
-
import { Space } from '../models/Space';
|
|
8
|
-
import { Notebook } from '../models/Notebook';
|
|
9
|
-
import { Lexical } from '../models/Lexical';
|
|
10
|
-
import { testConfig } from '../../../__tests__/shared/test-config';
|
|
11
|
-
import { DEFAULT_SERVICE_URLS } from '../../../api/constants';
|
|
12
|
-
import { performCleanup } from '../../../__tests__/shared/cleanup-shared';
|
|
13
|
-
/**
|
|
14
|
-
* SDK Spacer Integration Tests
|
|
15
|
-
*
|
|
16
|
-
* Tests workspace, notebook, and lexical document lifecycle
|
|
17
|
-
* using the SDK client and model classes.
|
|
18
|
-
*/
|
|
19
|
-
describe('SDK Spacer Integration Tests', () => {
|
|
20
|
-
let sdk;
|
|
21
|
-
let testSpace = null;
|
|
22
|
-
let createdNotebook = null;
|
|
23
|
-
let createdLexical = null;
|
|
24
|
-
beforeAll(async () => {
|
|
25
|
-
if (!testConfig.hasToken()) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
await performCleanup('setup');
|
|
29
|
-
sdk = new DatalayerSDK({
|
|
30
|
-
token: testConfig.getToken(),
|
|
31
|
-
iamRunUrl: DEFAULT_SERVICE_URLS.IAM,
|
|
32
|
-
runtimesRunUrl: DEFAULT_SERVICE_URLS.RUNTIMES,
|
|
33
|
-
spacerRunUrl: DEFAULT_SERVICE_URLS.SPACER,
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
afterAll(async () => {
|
|
37
|
-
if (!testConfig.hasToken()) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
await performCleanup('teardown');
|
|
41
|
-
}, 30000);
|
|
42
|
-
describe.skipIf(!testConfig.hasToken())('Space management', () => {
|
|
43
|
-
it('should get user spaces', async () => {
|
|
44
|
-
console.log('Getting user spaces...');
|
|
45
|
-
const spaces = await sdk.getMySpaces();
|
|
46
|
-
expect(spaces).toBeDefined();
|
|
47
|
-
expect(Array.isArray(spaces)).toBe(true);
|
|
48
|
-
expect(spaces.length).toBeGreaterThan(0);
|
|
49
|
-
const firstSpace = spaces[0];
|
|
50
|
-
expect(firstSpace).toBeInstanceOf(Space);
|
|
51
|
-
expect(firstSpace.id || firstSpace.uid).toBeDefined();
|
|
52
|
-
testSpace = firstSpace;
|
|
53
|
-
console.log(`Found ${spaces.length} space(s)`);
|
|
54
|
-
const spaceName = await firstSpace.getName();
|
|
55
|
-
console.log(`Using space: ${spaceName || firstSpace.id || firstSpace.uid}`);
|
|
56
|
-
});
|
|
57
|
-
it('should test space model methods', async () => {
|
|
58
|
-
if (!testSpace) {
|
|
59
|
-
throw new Error('Test dependency failed: testSpace should be available from previous test');
|
|
60
|
-
}
|
|
61
|
-
console.log('Testing space model methods...');
|
|
62
|
-
// Test getName method (lazy loading)
|
|
63
|
-
const name = await testSpace.getName();
|
|
64
|
-
expect(name).toBeDefined();
|
|
65
|
-
console.log(`Space name: ${name}`);
|
|
66
|
-
// Test getDescription method
|
|
67
|
-
const description = await testSpace.getDescription();
|
|
68
|
-
console.log(`Space description: ${description || 'None'}`);
|
|
69
|
-
// Test getUpdatedAt method
|
|
70
|
-
const updatedAt = await testSpace.getUpdatedAt();
|
|
71
|
-
if (updatedAt) {
|
|
72
|
-
expect(updatedAt).toBeInstanceOf(Date);
|
|
73
|
-
console.log(`Space updated at: ${updatedAt.toISOString()}`);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
console.log('Space has no update timestamp');
|
|
77
|
-
}
|
|
78
|
-
// Test getItems method
|
|
79
|
-
const items = await testSpace.getItems();
|
|
80
|
-
expect(Array.isArray(items)).toBe(true);
|
|
81
|
-
console.log(`Space has ${items.length} item(s)`);
|
|
82
|
-
// Test toJSON method
|
|
83
|
-
const json = await testSpace.toJSON();
|
|
84
|
-
expect(json).toBeDefined();
|
|
85
|
-
expect(json.id || json.uid).toBeDefined();
|
|
86
|
-
// Test toString
|
|
87
|
-
const str = testSpace.toString();
|
|
88
|
-
expect(str).toContain('Space');
|
|
89
|
-
console.log(`Space string: ${str}`);
|
|
90
|
-
});
|
|
91
|
-
// Space creation is not implemented - removed this test
|
|
92
|
-
});
|
|
93
|
-
describe.skipIf(!testConfig.hasToken())('Notebook lifecycle', () => {
|
|
94
|
-
it('should create a notebook', async () => {
|
|
95
|
-
if (!testSpace) {
|
|
96
|
-
throw new Error('Test dependency failed: testSpace should be available from previous test');
|
|
97
|
-
}
|
|
98
|
-
console.log('Creating notebook...');
|
|
99
|
-
const notebook = await sdk.createNotebook({
|
|
100
|
-
spaceId: testSpace.uid,
|
|
101
|
-
notebookType: 'jupyter',
|
|
102
|
-
name: 'sdk-test-notebook-' + Date.now(),
|
|
103
|
-
description: 'Test notebook from SDK',
|
|
104
|
-
});
|
|
105
|
-
expect(notebook).toBeInstanceOf(Notebook);
|
|
106
|
-
expect(notebook.id).toBeDefined();
|
|
107
|
-
expect(notebook.spaceId).toBe(testSpace.uid);
|
|
108
|
-
createdNotebook = notebook;
|
|
109
|
-
console.log(`Created notebook: ${notebook.id}`);
|
|
110
|
-
console.log(` Name: ${await notebook.getName()}`);
|
|
111
|
-
console.log(` Space: ${notebook.spaceId}`);
|
|
112
|
-
});
|
|
113
|
-
it('should get notebook details', async () => {
|
|
114
|
-
if (!createdNotebook) {
|
|
115
|
-
throw new Error('Test dependency failed: notebook should be created in previous test');
|
|
116
|
-
}
|
|
117
|
-
console.log('Getting notebook details...');
|
|
118
|
-
const notebook = await sdk.getNotebook(createdNotebook.uid);
|
|
119
|
-
expect(notebook).toBeInstanceOf(Notebook);
|
|
120
|
-
expect(notebook.id).toBe(createdNotebook.id);
|
|
121
|
-
expect(notebook.spaceId).toBe(createdNotebook.spaceId);
|
|
122
|
-
console.log(`Retrieved notebook: ${notebook.id}`);
|
|
123
|
-
const notebookName = await notebook.getName();
|
|
124
|
-
console.log(` Name: ${notebookName}`);
|
|
125
|
-
});
|
|
126
|
-
it('should update notebook', async () => {
|
|
127
|
-
if (!createdNotebook) {
|
|
128
|
-
throw new Error('Test dependency failed: notebook should be created in previous test');
|
|
129
|
-
}
|
|
130
|
-
console.log('Updating notebook...');
|
|
131
|
-
const updatedNotebook = await sdk.updateNotebook(createdNotebook, {
|
|
132
|
-
name: 'sdk-test-notebook-updated',
|
|
133
|
-
description: 'Updated description from SDK test',
|
|
134
|
-
});
|
|
135
|
-
expect(updatedNotebook).toBeInstanceOf(Notebook);
|
|
136
|
-
expect(updatedNotebook.id).toBe(createdNotebook.id);
|
|
137
|
-
console.log(`Updated notebook: ${updatedNotebook.id}`);
|
|
138
|
-
const updatedNotebookName = await updatedNotebook.getName();
|
|
139
|
-
console.log(` New name: ${updatedNotebookName}`);
|
|
140
|
-
});
|
|
141
|
-
it('should test notebook model methods', async () => {
|
|
142
|
-
if (!createdNotebook) {
|
|
143
|
-
throw new Error('Test dependency failed: notebook should be created in previous test');
|
|
144
|
-
}
|
|
145
|
-
console.log('Testing notebook model methods...');
|
|
146
|
-
// Check the raw data structure (debugging removed)
|
|
147
|
-
const rawData = await createdNotebook.toJSON();
|
|
148
|
-
expect(rawData).toBeDefined();
|
|
149
|
-
// Test getName method (lazy loading)
|
|
150
|
-
const name = await createdNotebook.getName();
|
|
151
|
-
expect(name).toBeDefined();
|
|
152
|
-
console.log(`Notebook name: ${name}`);
|
|
153
|
-
// Test getContent method
|
|
154
|
-
const content = await createdNotebook.getContent();
|
|
155
|
-
console.log(`Notebook has content: ${content !== null}`);
|
|
156
|
-
// Test getKernelSpec method
|
|
157
|
-
const kernelSpec = await createdNotebook.getKernelSpec();
|
|
158
|
-
console.log(`Kernel spec: ${kernelSpec ? JSON.stringify(kernelSpec).substring(0, 50) : 'None'}`);
|
|
159
|
-
// Test getUpdatedAt method
|
|
160
|
-
const updatedAt = await createdNotebook.getUpdatedAt();
|
|
161
|
-
expect(updatedAt).toBeInstanceOf(Date);
|
|
162
|
-
console.log(`Notebook updated at: ${updatedAt.toISOString()}`);
|
|
163
|
-
// Skip the update test as the notebook was already updated in the previous test
|
|
164
|
-
// The API doesn't like rapid successive updates
|
|
165
|
-
console.log('Skipping model update test (notebook already updated)');
|
|
166
|
-
// Test toJSON method
|
|
167
|
-
const json = await createdNotebook.toJSON();
|
|
168
|
-
expect(json).toBeDefined();
|
|
169
|
-
expect(json.id).toBe(createdNotebook.id);
|
|
170
|
-
// Test toString
|
|
171
|
-
const str = createdNotebook.toString();
|
|
172
|
-
expect(str).toContain('Notebook');
|
|
173
|
-
expect(str).toContain(createdNotebook.id);
|
|
174
|
-
console.log(`Notebook string: ${str}`);
|
|
175
|
-
});
|
|
176
|
-
it('should delete notebook', async () => {
|
|
177
|
-
if (!createdNotebook) {
|
|
178
|
-
throw new Error('Test dependency failed: notebook should be created in previous test');
|
|
179
|
-
}
|
|
180
|
-
console.log('Deleting notebook...');
|
|
181
|
-
await createdNotebook.delete();
|
|
182
|
-
console.log(`Notebook deleted successfully`);
|
|
183
|
-
// Verify deletion
|
|
184
|
-
expect(createdNotebook.isDeleted).toBe(true);
|
|
185
|
-
try {
|
|
186
|
-
await createdNotebook.getName();
|
|
187
|
-
expect(true).toBe(false); // Should not reach here
|
|
188
|
-
}
|
|
189
|
-
catch (error) {
|
|
190
|
-
expect(error.message).toContain('deleted');
|
|
191
|
-
console.log('Notebook correctly marked as deleted');
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
describe.skipIf(!testConfig.hasToken())('Lexical document lifecycle', () => {
|
|
196
|
-
it('should create a lexical document', async () => {
|
|
197
|
-
if (!testSpace) {
|
|
198
|
-
throw new Error('Test dependency failed: testSpace should be available from previous test');
|
|
199
|
-
}
|
|
200
|
-
console.log('Creating lexical document...');
|
|
201
|
-
const lexical = await sdk.createLexical({
|
|
202
|
-
spaceId: testSpace.uid,
|
|
203
|
-
name: 'sdk-test-lexical-' + Date.now(),
|
|
204
|
-
description: 'Test lexical from SDK',
|
|
205
|
-
documentType: 'document',
|
|
206
|
-
});
|
|
207
|
-
expect(lexical).toBeInstanceOf(Lexical);
|
|
208
|
-
expect(lexical.id).toBeDefined();
|
|
209
|
-
expect(lexical.spaceId).toBe(testSpace.uid);
|
|
210
|
-
createdLexical = lexical;
|
|
211
|
-
console.log(`Created lexical: ${lexical.id}`);
|
|
212
|
-
const lexicalName = await lexical.getName();
|
|
213
|
-
console.log(` Name: ${lexicalName}`);
|
|
214
|
-
});
|
|
215
|
-
it('should get lexical details', async () => {
|
|
216
|
-
if (!createdLexical) {
|
|
217
|
-
throw new Error('Test dependency failed: lexical should be created in previous test');
|
|
218
|
-
}
|
|
219
|
-
console.log('Getting lexical details...');
|
|
220
|
-
const lexical = await sdk.getLexical(createdLexical.uid);
|
|
221
|
-
expect(lexical).toBeInstanceOf(Lexical);
|
|
222
|
-
expect(lexical.id).toBe(createdLexical.id);
|
|
223
|
-
expect(lexical.spaceId).toBe(createdLexical.spaceId);
|
|
224
|
-
console.log(`Retrieved lexical: ${lexical.id}`);
|
|
225
|
-
const retrievedLexicalName = await lexical.getName();
|
|
226
|
-
console.log(` Name: ${retrievedLexicalName}`);
|
|
227
|
-
});
|
|
228
|
-
it('should update lexical', async () => {
|
|
229
|
-
if (!createdLexical) {
|
|
230
|
-
throw new Error('Test dependency failed: lexical should be created in previous test');
|
|
231
|
-
}
|
|
232
|
-
console.log('Updating lexical...');
|
|
233
|
-
const updatedLexical = await sdk.updateLexical(createdLexical, {
|
|
234
|
-
name: 'sdk-test-lexical-updated',
|
|
235
|
-
description: 'Updated description from SDK test',
|
|
236
|
-
});
|
|
237
|
-
expect(updatedLexical).toBeInstanceOf(Lexical);
|
|
238
|
-
expect(updatedLexical.id).toBe(createdLexical.id);
|
|
239
|
-
console.log(`Updated lexical: ${updatedLexical.id}`);
|
|
240
|
-
const updatedLexicalName = await updatedLexical.getName();
|
|
241
|
-
console.log(` New name: ${updatedLexicalName}`);
|
|
242
|
-
});
|
|
243
|
-
it('should test lexical model methods', async () => {
|
|
244
|
-
if (!createdLexical) {
|
|
245
|
-
throw new Error('Test dependency failed: lexical should be created in previous test');
|
|
246
|
-
}
|
|
247
|
-
console.log('Testing lexical model methods...');
|
|
248
|
-
// Check the raw data structure (debugging removed)
|
|
249
|
-
const rawData = await createdLexical.toJSON();
|
|
250
|
-
expect(rawData).toBeDefined();
|
|
251
|
-
// Test getName method (lazy loading)
|
|
252
|
-
const name = await createdLexical.getName();
|
|
253
|
-
expect(name).toBeDefined();
|
|
254
|
-
console.log(`Lexical name: ${name}`);
|
|
255
|
-
// Test getContent method
|
|
256
|
-
const content = await createdLexical.getContent();
|
|
257
|
-
console.log(`Lexical has content: ${content !== null}`);
|
|
258
|
-
// Test getUpdatedAt method
|
|
259
|
-
const updatedAt = await createdLexical.getUpdatedAt();
|
|
260
|
-
expect(updatedAt).toBeInstanceOf(Date);
|
|
261
|
-
console.log(`Lexical updated at: ${updatedAt.toISOString()}`);
|
|
262
|
-
// Skip the update test as the lexical was already updated in the previous test
|
|
263
|
-
// The API doesn't like rapid successive updates
|
|
264
|
-
console.log('Skipping model update test (lexical already updated)');
|
|
265
|
-
// Test toJSON method
|
|
266
|
-
const json = await createdLexical.toJSON();
|
|
267
|
-
expect(json).toBeDefined();
|
|
268
|
-
expect(json.id).toBe(createdLexical.id);
|
|
269
|
-
// Test toString
|
|
270
|
-
const str = createdLexical.toString();
|
|
271
|
-
expect(str).toContain('Lexical');
|
|
272
|
-
expect(str).toContain(createdLexical.id);
|
|
273
|
-
console.log(`Lexical string: ${str}`);
|
|
274
|
-
});
|
|
275
|
-
it('should delete lexical document', async () => {
|
|
276
|
-
if (!createdLexical) {
|
|
277
|
-
throw new Error('Test dependency failed: lexical should be created in previous test');
|
|
278
|
-
}
|
|
279
|
-
console.log('Deleting lexical...');
|
|
280
|
-
await createdLexical.delete();
|
|
281
|
-
console.log(`Lexical deleted successfully`);
|
|
282
|
-
// Verify deletion
|
|
283
|
-
expect(createdLexical.isDeleted).toBe(true);
|
|
284
|
-
try {
|
|
285
|
-
await createdLexical.getName();
|
|
286
|
-
expect(true).toBe(false); // Should not reach here
|
|
287
|
-
}
|
|
288
|
-
catch (error) {
|
|
289
|
-
expect(error.message).toContain('deleted');
|
|
290
|
-
console.log('Lexical correctly marked as deleted');
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
});
|
|
294
|
-
describe.skipIf(!testConfig.hasToken())('Space items management', () => {
|
|
295
|
-
it('should get space items', async () => {
|
|
296
|
-
if (!testSpace) {
|
|
297
|
-
throw new Error('Test dependency failed: testSpace should be available from previous test');
|
|
298
|
-
}
|
|
299
|
-
console.log('Getting space items...');
|
|
300
|
-
const response = await sdk.getSpaceItems(testSpace.uid);
|
|
301
|
-
expect(response).toBeDefined();
|
|
302
|
-
expect(response.items).toBeDefined();
|
|
303
|
-
expect(Array.isArray(response.items)).toBe(true);
|
|
304
|
-
console.log(`Space has ${response.items.length} item(s)`);
|
|
305
|
-
if (response.items.length > 0) {
|
|
306
|
-
const firstItem = response.items[0];
|
|
307
|
-
console.log(`First item: ${firstItem.name} (${firstItem.type})`);
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
it('should delete space item', async () => {
|
|
311
|
-
// Note: We don't actually delete items here as they might be important
|
|
312
|
-
// This just tests the method exists and can be called
|
|
313
|
-
console.log('Testing space item deletion (dry run)...');
|
|
314
|
-
// We would normally create a test item and delete it
|
|
315
|
-
// For now, just verify the method exists
|
|
316
|
-
expect(sdk.deleteSpaceItem).toBeDefined();
|
|
317
|
-
console.log('Space item deletion method verified');
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
describe.skipIf(!testConfig.hasToken())('Error handling', () => {
|
|
321
|
-
it('should handle non-existent notebook gracefully', async () => {
|
|
322
|
-
console.log('Testing non-existent notebook...');
|
|
323
|
-
try {
|
|
324
|
-
await sdk.getNotebook('non-existent-notebook-id');
|
|
325
|
-
expect(true).toBe(false); // Should not reach here
|
|
326
|
-
}
|
|
327
|
-
catch (error) {
|
|
328
|
-
expect(error).toBeDefined();
|
|
329
|
-
console.log('Non-existent notebook error handled correctly');
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
it('should handle non-existent lexical gracefully', async () => {
|
|
333
|
-
console.log('Testing non-existent lexical...');
|
|
334
|
-
try {
|
|
335
|
-
await sdk.getLexical('non-existent-lexical-id');
|
|
336
|
-
expect(true).toBe(false); // Should not reach here
|
|
337
|
-
}
|
|
338
|
-
catch (error) {
|
|
339
|
-
expect(error).toBeDefined();
|
|
340
|
-
console.log('Non-existent lexical error handled correctly');
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
it('should validate notebook creation parameters', async () => {
|
|
344
|
-
console.log('Testing invalid notebook creation...');
|
|
345
|
-
try {
|
|
346
|
-
// Missing required fields
|
|
347
|
-
await sdk.createNotebook({
|
|
348
|
-
spaceId: '', // Invalid empty spaceId
|
|
349
|
-
notebookType: 'jupyter',
|
|
350
|
-
name: 'test',
|
|
351
|
-
description: 'test description',
|
|
352
|
-
});
|
|
353
|
-
expect(true).toBe(false); // Should not reach here
|
|
354
|
-
}
|
|
355
|
-
catch (error) {
|
|
356
|
-
expect(error).toBeDefined();
|
|
357
|
-
console.log('Invalid notebook parameters rejected');
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
});
|
package/lib/sdk/client/base.d.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration options for the Datalayer SDK.
|
|
3
|
-
*/
|
|
4
|
-
export interface DatalayerSDKConfig {
|
|
5
|
-
/** Authentication token for API requests. */
|
|
6
|
-
token?: string;
|
|
7
|
-
/** URL for the IAM (Identity and Access Management) service. */
|
|
8
|
-
iamRunUrl?: string;
|
|
9
|
-
/** URL for the Runtimes service. */
|
|
10
|
-
runtimesRunUrl?: string;
|
|
11
|
-
/** URL for the Spacer (workspaces and collaboration) service. */
|
|
12
|
-
spacerRunUrl?: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Base SDK class that provides core configuration and token management.
|
|
16
|
-
*
|
|
17
|
-
* This class serves as the foundation for the DatalayerSDK, handling
|
|
18
|
-
* authentication tokens, service URL configuration, and other common
|
|
19
|
-
* SDK functionality that all mixins can access.
|
|
20
|
-
*/
|
|
21
|
-
export declare class DatalayerSDKBase {
|
|
22
|
-
/** URL for IAM service */
|
|
23
|
-
readonly iamRunUrl: string;
|
|
24
|
-
/** URL for Runtimes service */
|
|
25
|
-
readonly runtimesRunUrl: string;
|
|
26
|
-
/** URL for Spacer service */
|
|
27
|
-
readonly spacerRunUrl: string;
|
|
28
|
-
/** Authentication token */
|
|
29
|
-
token?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Create a DatalayerSDK base instance.
|
|
32
|
-
*
|
|
33
|
-
* @param config - SDK configuration options
|
|
34
|
-
*/
|
|
35
|
-
constructor(config: DatalayerSDKConfig);
|
|
36
|
-
/**
|
|
37
|
-
* Update the authentication token for all API requests.
|
|
38
|
-
*
|
|
39
|
-
* This method updates the token that will be used for all subsequent
|
|
40
|
-
* API calls made through the SDK.
|
|
41
|
-
*
|
|
42
|
-
* @param token - New authentication token
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* // After login, update the SDK with the new token
|
|
47
|
-
* const loginResponse = await sdk.login(credentials);
|
|
48
|
-
* sdk.updateToken(loginResponse.access_token);
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
updateToken(token: string): void;
|
|
52
|
-
/**
|
|
53
|
-
* Get the current configuration including service URLs and token.
|
|
54
|
-
*
|
|
55
|
-
* @returns The current configuration
|
|
56
|
-
*/
|
|
57
|
-
getConfig(): DatalayerSDKConfig;
|
|
58
|
-
/**
|
|
59
|
-
* Update the configuration for API requests.
|
|
60
|
-
*
|
|
61
|
-
* @param config - Configuration updates
|
|
62
|
-
*/
|
|
63
|
-
updateConfig(config: Partial<DatalayerSDKConfig>): void;
|
|
64
|
-
/**
|
|
65
|
-
* Get the IAM service URL for API requests.
|
|
66
|
-
*
|
|
67
|
-
* @returns The IAM service URL
|
|
68
|
-
*/
|
|
69
|
-
getIamRunUrl(): string;
|
|
70
|
-
/**
|
|
71
|
-
* Get the Runtimes service URL for API requests.
|
|
72
|
-
*
|
|
73
|
-
* @returns The Runtimes service URL
|
|
74
|
-
*/
|
|
75
|
-
getRuntimesRunUrl(): string;
|
|
76
|
-
/**
|
|
77
|
-
* Get the Spacer service URL for API requests.
|
|
78
|
-
*
|
|
79
|
-
* @returns The Spacer service URL
|
|
80
|
-
*/
|
|
81
|
-
getSpacerRunUrl(): string;
|
|
82
|
-
/**
|
|
83
|
-
* Get the current authentication token.
|
|
84
|
-
*
|
|
85
|
-
* @returns The authentication token
|
|
86
|
-
*/
|
|
87
|
-
getToken(): string | undefined;
|
|
88
|
-
}
|
package/lib/sdk/client/base.js
DELETED
|
@@ -1,112 +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/base
|
|
7
|
-
* @description Base SDK class providing core configuration and token management.
|
|
8
|
-
*/
|
|
9
|
-
import { DEFAULT_SERVICE_URLS } from '../../api/constants';
|
|
10
|
-
/**
|
|
11
|
-
* Base SDK class that provides core configuration and token management.
|
|
12
|
-
*
|
|
13
|
-
* This class serves as the foundation for the DatalayerSDK, handling
|
|
14
|
-
* authentication tokens, service URL configuration, and other common
|
|
15
|
-
* SDK functionality that all mixins can access.
|
|
16
|
-
*/
|
|
17
|
-
export class DatalayerSDKBase {
|
|
18
|
-
/** URL for IAM service */
|
|
19
|
-
iamRunUrl;
|
|
20
|
-
/** URL for Runtimes service */
|
|
21
|
-
runtimesRunUrl;
|
|
22
|
-
/** URL for Spacer service */
|
|
23
|
-
spacerRunUrl;
|
|
24
|
-
/** Authentication token */
|
|
25
|
-
token;
|
|
26
|
-
/**
|
|
27
|
-
* Create a DatalayerSDK base instance.
|
|
28
|
-
*
|
|
29
|
-
* @param config - SDK configuration options
|
|
30
|
-
*/
|
|
31
|
-
constructor(config) {
|
|
32
|
-
this.iamRunUrl = config.iamRunUrl || DEFAULT_SERVICE_URLS.IAM;
|
|
33
|
-
this.runtimesRunUrl =
|
|
34
|
-
config.runtimesRunUrl || DEFAULT_SERVICE_URLS.RUNTIMES;
|
|
35
|
-
this.spacerRunUrl = config.spacerRunUrl || DEFAULT_SERVICE_URLS.SPACER;
|
|
36
|
-
this.token = config.token;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Update the authentication token for all API requests.
|
|
40
|
-
*
|
|
41
|
-
* This method updates the token that will be used for all subsequent
|
|
42
|
-
* API calls made through the SDK.
|
|
43
|
-
*
|
|
44
|
-
* @param token - New authentication token
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* // After login, update the SDK with the new token
|
|
49
|
-
* const loginResponse = await sdk.login(credentials);
|
|
50
|
-
* sdk.updateToken(loginResponse.access_token);
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
updateToken(token) {
|
|
54
|
-
this.token = token;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Get the current configuration including service URLs and token.
|
|
58
|
-
*
|
|
59
|
-
* @returns The current configuration
|
|
60
|
-
*/
|
|
61
|
-
getConfig() {
|
|
62
|
-
return {
|
|
63
|
-
iamRunUrl: this.iamRunUrl,
|
|
64
|
-
runtimesRunUrl: this.runtimesRunUrl,
|
|
65
|
-
spacerRunUrl: this.spacerRunUrl,
|
|
66
|
-
token: this.token,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Update the configuration for API requests.
|
|
71
|
-
*
|
|
72
|
-
* @param config - Configuration updates
|
|
73
|
-
*/
|
|
74
|
-
updateConfig(config) {
|
|
75
|
-
if (config.token !== undefined) {
|
|
76
|
-
this.updateToken(config.token);
|
|
77
|
-
}
|
|
78
|
-
// Note: service URLs cannot be changed after initialization
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Get the IAM service URL for API requests.
|
|
82
|
-
*
|
|
83
|
-
* @returns The IAM service URL
|
|
84
|
-
*/
|
|
85
|
-
getIamRunUrl() {
|
|
86
|
-
return this.iamRunUrl;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Get the Runtimes service URL for API requests.
|
|
90
|
-
*
|
|
91
|
-
* @returns The Runtimes service URL
|
|
92
|
-
*/
|
|
93
|
-
getRuntimesRunUrl() {
|
|
94
|
-
return this.runtimesRunUrl;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Get the Spacer service URL for API requests.
|
|
98
|
-
*
|
|
99
|
-
* @returns The Spacer service URL
|
|
100
|
-
*/
|
|
101
|
-
getSpacerRunUrl() {
|
|
102
|
-
return this.spacerRunUrl;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Get the current authentication token.
|
|
106
|
-
*
|
|
107
|
-
* @returns The authentication token
|
|
108
|
-
*/
|
|
109
|
-
getToken() {
|
|
110
|
-
return this.token;
|
|
111
|
-
}
|
|
112
|
-
}
|