@datalayer/core 0.0.9 → 0.0.11
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/lib/__tests__/shared/cleanup-shared.d.ts +4 -0
- package/lib/__tests__/shared/cleanup-shared.js +228 -0
- package/lib/__tests__/shared/test-config.d.ts +51 -0
- package/lib/__tests__/shared/test-config.js +110 -0
- package/lib/__tests__/shared/test-constants.d.ts +66 -0
- package/lib/__tests__/shared/test-constants.js +79 -0
- package/lib/api/DatalayerApi.d.ts +1 -1
- package/lib/api/DatalayerApi.js +73 -42
- package/lib/api/__tests__/iam.authentication.integration.test.d.ts +1 -0
- package/lib/api/__tests__/iam.authentication.integration.test.js +247 -0
- package/lib/api/__tests__/iam.healthz.integration.test.d.ts +1 -0
- package/lib/api/__tests__/iam.healthz.integration.test.js +63 -0
- package/lib/api/__tests__/iam.profile.integration.test.d.ts +1 -0
- package/lib/api/__tests__/iam.profile.integration.test.js +252 -0
- package/lib/api/__tests__/runtimes.environments.integration.test.d.ts +1 -0
- package/lib/api/__tests__/runtimes.environments.integration.test.js +122 -0
- package/lib/api/__tests__/runtimes.healthz.integration.test.d.ts +1 -0
- package/lib/api/__tests__/runtimes.healthz.integration.test.js +50 -0
- package/lib/api/__tests__/runtimes.integration.test.d.ts +1 -0
- package/lib/api/__tests__/runtimes.integration.test.js +369 -0
- package/lib/api/__tests__/spacer.healthz.integration.test.d.ts +1 -0
- package/lib/api/__tests__/spacer.healthz.integration.test.js +50 -0
- package/lib/api/__tests__/spacer.integration.test.d.ts +1 -0
- package/lib/api/__tests__/spacer.integration.test.js +519 -0
- package/lib/api/constants.d.ts +19 -0
- package/lib/api/constants.js +23 -0
- package/lib/api/iam/__tests__/authentication.unit.test.d.ts +1 -0
- package/lib/api/iam/__tests__/authentication.unit.test.js +63 -0
- package/lib/api/iam/__tests__/healthz.unit.test.d.ts +1 -0
- package/lib/api/iam/__tests__/healthz.unit.test.js +60 -0
- package/lib/api/iam/__tests__/profile.unit.test.d.ts +1 -0
- package/lib/api/iam/__tests__/profile.unit.test.js +57 -0
- package/lib/api/iam/authentication.d.ts +40 -0
- package/lib/api/iam/authentication.js +128 -0
- package/lib/api/iam/healthz.d.ts +15 -0
- package/lib/api/iam/healthz.js +43 -0
- package/lib/api/iam/index.d.ts +12 -0
- package/lib/api/iam/index.js +17 -0
- package/lib/api/iam/profile.d.ts +15 -0
- package/lib/api/iam/profile.js +41 -0
- package/lib/api/index.d.ts +20 -3
- package/lib/api/index.js +22 -3
- package/lib/api/runtimes/__tests__/environments.unit.test.d.ts +1 -0
- package/lib/api/runtimes/__tests__/environments.unit.test.js +77 -0
- package/lib/api/runtimes/__tests__/healthz.unit.test.d.ts +1 -0
- package/lib/api/runtimes/__tests__/healthz.unit.test.js +57 -0
- package/lib/api/runtimes/__tests__/runtimes.unit.test.d.ts +1 -0
- package/lib/api/runtimes/__tests__/runtimes.unit.test.js +139 -0
- package/lib/api/runtimes/__tests__/snapshots.unit.test.d.ts +1 -0
- package/lib/api/runtimes/__tests__/snapshots.unit.test.js +96 -0
- package/lib/api/runtimes/environments.d.ts +9 -0
- package/lib/api/runtimes/environments.js +28 -0
- package/lib/api/runtimes/healthz.d.ts +25 -0
- package/lib/api/runtimes/healthz.js +43 -0
- package/lib/api/runtimes/index.d.ts +10 -5
- package/lib/api/runtimes/index.js +10 -5
- package/lib/api/runtimes/runtimes.d.ts +54 -0
- package/lib/api/runtimes/runtimes.js +169 -0
- package/lib/api/runtimes/snapshots.d.ts +34 -21
- package/lib/api/runtimes/snapshots.js +69 -138
- package/lib/api/spacer/__tests__/healthz.unit.test.d.ts +1 -0
- package/lib/api/spacer/__tests__/healthz.unit.test.js +57 -0
- package/lib/api/spacer/__tests__/items.unit.test.d.ts +1 -0
- package/lib/api/spacer/__tests__/items.unit.test.js +165 -0
- package/lib/api/spacer/__tests__/lexicals.unit.test.d.ts +1 -0
- package/lib/api/spacer/__tests__/lexicals.unit.test.js +323 -0
- package/lib/api/spacer/__tests__/notebooks.unit.test.d.ts +1 -0
- package/lib/api/spacer/__tests__/notebooks.unit.test.js +224 -0
- package/lib/api/spacer/__tests__/users.unit.test.d.ts +1 -0
- package/lib/api/spacer/__tests__/users.unit.test.js +132 -0
- package/lib/api/spacer/healthz.d.ts +25 -0
- package/lib/api/spacer/healthz.js +43 -0
- package/lib/api/spacer/index.d.ts +13 -0
- package/lib/api/spacer/index.js +17 -0
- package/lib/api/spacer/items.d.ts +17 -0
- package/lib/api/spacer/items.js +40 -0
- package/lib/api/spacer/lexicals.d.ts +26 -0
- package/lib/api/spacer/lexicals.js +74 -0
- package/lib/api/spacer/notebooks.d.ts +26 -0
- package/lib/api/spacer/notebooks.js +74 -0
- package/lib/api/spacer/spaces.d.ts +9 -0
- package/lib/api/spacer/spaces.js +29 -0
- package/lib/api/spacer/users.d.ts +9 -0
- package/lib/api/spacer/users.js +28 -0
- package/lib/api/types/iam.d.ts +180 -0
- package/lib/api/types/index.d.ts +32 -0
- package/lib/api/types/index.js +36 -0
- package/lib/api/types/runtimes.d.ts +235 -0
- package/lib/api/types/runtimes.js +5 -0
- package/lib/api/types/spacer.d.ts +271 -0
- package/lib/api/types/spacer.js +5 -0
- package/lib/api/utils/__tests__/validation.test.d.ts +1 -0
- package/lib/api/utils/__tests__/validation.test.js +109 -0
- package/lib/api/utils/validation.d.ts +24 -0
- package/lib/api/utils/validation.js +133 -0
- package/lib/components/display/JupyterDialog.js +4 -8
- package/lib/components/progress/CreditsIndicator.d.ts +1 -1
- package/lib/components/runtimes/RuntimeCellVariablesDialog.js +2 -2
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +1 -1
- package/lib/components/runtimes/RuntimeLauncherDialog.js +5 -2
- package/lib/components/runtimes/RuntimePickerBase.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerBase.js +1 -1
- package/lib/components/runtimes/RuntimePickerCell.js +2 -1
- package/lib/components/runtimes/RuntimePickerNotebook.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerNotebook.js +1 -1
- package/lib/components/runtimes/RuntimeSimplePicker.js +2 -1
- package/lib/components/runtimes/RuntimeTransfer.d.ts +1 -1
- package/lib/components/runtimes/RuntimeUtils.d.ts +1 -1
- package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -1
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +2 -2
- package/lib/components/snippets/SnippetDialog.js +1 -1
- package/lib/components/storage/ContentsBrowser.js +2 -2
- package/lib/components/tables/DataTable.js +2 -1
- package/lib/hooks/useDatalayer.d.ts +1 -1
- package/lib/hooks/useDatalayer.js +1 -1
- package/lib/hooks/useIAM.js +1 -1
- package/lib/hooks/useRuntimes.js +1 -1
- package/lib/index.d.ts +9 -0
- package/lib/index.js +10 -0
- package/lib/sdk/client/__tests__/sdk.health.integration.test.d.ts +1 -0
- package/lib/sdk/client/__tests__/sdk.health.integration.test.js +110 -0
- package/lib/sdk/client/__tests__/sdk.iam.integration.test.d.ts +1 -0
- package/lib/sdk/client/__tests__/sdk.iam.integration.test.js +179 -0
- package/lib/sdk/client/__tests__/sdk.models.integration.test.d.ts +1 -0
- package/lib/sdk/client/__tests__/sdk.models.integration.test.js +376 -0
- package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.d.ts +1 -0
- package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.js +276 -0
- package/lib/sdk/client/__tests__/sdk.spacer.integration.test.d.ts +1 -0
- package/lib/sdk/client/__tests__/sdk.spacer.integration.test.js +361 -0
- package/lib/sdk/client/base.d.ts +88 -0
- package/lib/sdk/client/base.js +112 -0
- package/lib/sdk/client/index.d.ts +192 -0
- package/lib/sdk/client/index.js +128 -0
- package/lib/sdk/client/mixins/HealthMixin.d.ts +100 -0
- package/lib/sdk/client/mixins/HealthMixin.js +133 -0
- package/lib/sdk/client/mixins/IAMMixin.d.ts +59 -0
- package/lib/sdk/client/mixins/IAMMixin.js +83 -0
- package/lib/sdk/client/mixins/RuntimesMixin.d.ts +134 -0
- package/lib/sdk/client/mixins/RuntimesMixin.js +221 -0
- package/lib/sdk/client/mixins/SpacerMixin.d.ts +184 -0
- package/lib/sdk/client/mixins/SpacerMixin.js +278 -0
- package/lib/sdk/client/models/Lexical.d.ts +156 -0
- package/lib/sdk/client/models/Lexical.js +275 -0
- package/lib/sdk/client/models/Notebook.d.ts +174 -0
- package/lib/sdk/client/models/Notebook.js +311 -0
- package/lib/sdk/client/models/Runtime.d.ts +221 -0
- package/lib/sdk/client/models/Runtime.js +341 -0
- package/lib/sdk/client/models/Snapshot.d.ts +156 -0
- package/lib/sdk/client/models/Snapshot.js +244 -0
- package/lib/sdk/client/models/Space.d.ts +182 -0
- package/lib/sdk/client/models/Space.js +276 -0
- package/lib/sdk/client/models/__tests__/Lexical.test.d.ts +1 -0
- package/lib/sdk/client/models/__tests__/Lexical.test.js +288 -0
- package/lib/sdk/client/models/__tests__/Notebook.test.d.ts +1 -0
- package/lib/sdk/client/models/__tests__/Notebook.test.js +206 -0
- package/lib/sdk/client/models/__tests__/Runtime.test.d.ts +1 -0
- package/lib/sdk/client/models/__tests__/Runtime.test.js +133 -0
- package/lib/sdk/client/models/__tests__/Snapshot.test.d.ts +1 -0
- package/lib/sdk/client/models/__tests__/Snapshot.test.js +244 -0
- package/lib/sdk/client/models/__tests__/Space.test.d.ts +1 -0
- package/lib/sdk/client/models/__tests__/Space.test.js +334 -0
- package/lib/sdk/client/models/index.d.ts +30 -0
- package/lib/sdk/client/models/index.js +30 -0
- package/lib/sdk/client/utils/mixins.d.ts +42 -0
- package/lib/sdk/client/utils/mixins.js +47 -0
- package/lib/sdk/index.d.ts +26 -0
- package/lib/sdk/index.js +32 -0
- package/lib/sdk/stateful/index.d.ts +3 -0
- package/lib/sdk/stateful/index.js +7 -0
- package/lib/{api → sdk/stateful}/runtimes/actions.d.ts +1 -1
- package/lib/{api → sdk/stateful}/runtimes/actions.js +3 -3
- package/lib/{api → sdk/stateful}/runtimes/apis.d.ts +1 -1
- package/lib/sdk/stateful/runtimes/apis.js +5 -0
- package/lib/sdk/stateful/runtimes/index.d.ts +5 -0
- package/lib/sdk/stateful/runtimes/index.js +9 -0
- package/lib/sdk/stateful/runtimes/snapshots.d.ts +25 -0
- package/lib/sdk/stateful/runtimes/snapshots.js +150 -0
- package/lib/services/DatalayerServiceManager.js +1 -1
- package/lib/state/substates/IAMState.js +1 -1
- package/lib/state/substates/RuntimesState.d.ts +1 -1
- package/lib/state/substates/RuntimesState.js +1 -1
- package/lib/state/substates/SurveysState.js +1 -1
- package/lib/test-setup.js +1 -0
- package/package.json +19 -9
- /package/lib/api/{runtimes/apis.js → types/iam.js} +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/Python.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/Python.js +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/Snippets.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/Snippets.js +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/index.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/index.js +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/index.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/index.js +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/kernelsHandler.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/kernelsHandler.js +0 -0
- /package/lib/{api → sdk/stateful}/runtimes/settings.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/runtimes/settings.js +0 -0
- /package/lib/{api → sdk/stateful}/runtimes/utils.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/runtimes/utils.js +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { Environment, CreateRuntimeRequest, CreateRuntimeSnapshotRequest } from '../../../api/types/runtimes';
|
|
2
|
+
import type { Constructor } from '../utils/mixins';
|
|
3
|
+
import { Runtime } from '../models/Runtime';
|
|
4
|
+
import { Snapshot } from '../models/Snapshot';
|
|
5
|
+
/**
|
|
6
|
+
* Runtimes mixin that provides computational environment and runtime management.
|
|
7
|
+
*
|
|
8
|
+
* This mixin is applied to the DatalayerSDK class to provide clean, intuitive
|
|
9
|
+
* methods for managing environments and runtimes.
|
|
10
|
+
*/
|
|
11
|
+
export declare function RuntimesMixin<TBase extends Constructor>(Base: TBase): {
|
|
12
|
+
new (...args: any[]): {
|
|
13
|
+
_extractRuntimePodName(runtimePodNameOrInstance: string | Runtime): string;
|
|
14
|
+
_extractSnapshotId(snapshotIdOrInstance: string | Snapshot): string;
|
|
15
|
+
/**
|
|
16
|
+
* List all available computational environments.
|
|
17
|
+
*
|
|
18
|
+
* @returns Promise resolving to array of environments
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const environments = await sdk.listEnvironments();
|
|
23
|
+
* console.log('Available environments:', environments.length);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
listEnvironments(): Promise<Environment[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Create a new computational runtime.
|
|
29
|
+
*
|
|
30
|
+
* @param data - Runtime creation parameters
|
|
31
|
+
* @returns Promise resolving to created runtime
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const runtime = await sdk.createRuntime({
|
|
36
|
+
* environment_name: 'python-cpu-env',
|
|
37
|
+
* credits_limit: 100
|
|
38
|
+
* });
|
|
39
|
+
* console.log('Runtime created:', runtime.podName);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
createRuntime(data: CreateRuntimeRequest): Promise<Runtime>;
|
|
43
|
+
/**
|
|
44
|
+
* List all runtimes.
|
|
45
|
+
*
|
|
46
|
+
* @returns Promise resolving to array of runtimes
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const allRuntimes = await sdk.listRuntimes();
|
|
51
|
+
* console.log('Total runtimes:', allRuntimes.length);
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
listRuntimes(): Promise<Runtime[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Get details for a specific runtime by pod name or Runtime instance.
|
|
57
|
+
*
|
|
58
|
+
* @param podNameOrRuntime - Runtime pod name (string) or Runtime instance
|
|
59
|
+
* @returns Promise resolving to runtime details
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const runtime = await sdk.getRuntime('runtime-abc123');
|
|
64
|
+
* const refreshed = await sdk.getRuntime(runtime);
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
getRuntime(podNameOrRuntime: string | Runtime): Promise<Runtime>;
|
|
68
|
+
/**
|
|
69
|
+
* Delete a runtime permanently.
|
|
70
|
+
*
|
|
71
|
+
* @param podNameOrRuntime - Runtime pod name (string) or Runtime instance
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* await sdk.deleteRuntime('runtime-abc123');
|
|
76
|
+
* await sdk.deleteRuntime(runtime);
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
deleteRuntime(podNameOrRuntime: string | Runtime): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Create a snapshot of a runtime.
|
|
82
|
+
*
|
|
83
|
+
* @param data - Snapshot creation parameters
|
|
84
|
+
* @returns Promise resolving to created snapshot
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const snapshot = await sdk.createSnapshot({
|
|
89
|
+
* pod_name: 'runtime-abc123',
|
|
90
|
+
* name: 'my-checkpoint',
|
|
91
|
+
* description: 'Before major changes'
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
createSnapshot(data: CreateRuntimeSnapshotRequest): Promise<Snapshot>;
|
|
96
|
+
/**
|
|
97
|
+
* List all runtime snapshots.
|
|
98
|
+
*
|
|
99
|
+
* @returns Promise resolving to array of snapshots
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const allSnapshots = await sdk.listSnapshots();
|
|
104
|
+
* console.log('Total snapshots:', allSnapshots.length);
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
listSnapshots(): Promise<Snapshot[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Get details for a specific snapshot by ID or Snapshot instance.
|
|
110
|
+
*
|
|
111
|
+
* @param idOrSnapshot - Snapshot ID (string) or Snapshot instance
|
|
112
|
+
* @returns Promise resolving to snapshot details
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const snapshot = await sdk.getSnapshot('snapshot-abc123');
|
|
117
|
+
* const refreshed = await sdk.getSnapshot(snapshot);
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
getSnapshot(idOrSnapshot: string | Snapshot): Promise<Snapshot>;
|
|
121
|
+
/**
|
|
122
|
+
* Delete a snapshot permanently.
|
|
123
|
+
*
|
|
124
|
+
* @param idOrSnapshot - Snapshot ID (string) or Snapshot instance
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* await sdk.deleteSnapshot('snapshot-abc123');
|
|
129
|
+
* await sdk.deleteSnapshot(snapshot);
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
deleteSnapshot(idOrSnapshot: string | Snapshot): Promise<void>;
|
|
133
|
+
};
|
|
134
|
+
} & TBase;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module sdk/client/mixins/RuntimesMixin
|
|
7
|
+
* @description Runtimes mixin for the Datalayer SDK.
|
|
8
|
+
*
|
|
9
|
+
* This mixin provides intuitive methods for managing computational environments,
|
|
10
|
+
* runtimes, and snapshots that are mixed into the main DatalayerSDK class.
|
|
11
|
+
*/
|
|
12
|
+
import { environments, runtimes, snapshots } from '../../../api/runtimes';
|
|
13
|
+
import { Runtime } from '../models/Runtime';
|
|
14
|
+
import { Snapshot } from '../models/Snapshot';
|
|
15
|
+
/**
|
|
16
|
+
* Runtimes mixin that provides computational environment and runtime management.
|
|
17
|
+
*
|
|
18
|
+
* This mixin is applied to the DatalayerSDK class to provide clean, intuitive
|
|
19
|
+
* methods for managing environments and runtimes.
|
|
20
|
+
*/
|
|
21
|
+
export function RuntimesMixin(Base) {
|
|
22
|
+
return class extends Base {
|
|
23
|
+
// ========================================================================
|
|
24
|
+
// Helper Functions
|
|
25
|
+
// ========================================================================
|
|
26
|
+
_extractRuntimePodName(runtimePodNameOrInstance) {
|
|
27
|
+
return typeof runtimePodNameOrInstance === 'string'
|
|
28
|
+
? runtimePodNameOrInstance
|
|
29
|
+
: runtimePodNameOrInstance.podName;
|
|
30
|
+
}
|
|
31
|
+
_extractSnapshotId(snapshotIdOrInstance) {
|
|
32
|
+
return typeof snapshotIdOrInstance === 'string'
|
|
33
|
+
? snapshotIdOrInstance
|
|
34
|
+
: snapshotIdOrInstance.uid;
|
|
35
|
+
}
|
|
36
|
+
// ========================================================================
|
|
37
|
+
// Environments
|
|
38
|
+
// ========================================================================
|
|
39
|
+
/**
|
|
40
|
+
* List all available computational environments.
|
|
41
|
+
*
|
|
42
|
+
* @returns Promise resolving to array of environments
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const environments = await sdk.listEnvironments();
|
|
47
|
+
* console.log('Available environments:', environments.length);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
async listEnvironments() {
|
|
51
|
+
const token = this.getToken();
|
|
52
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
53
|
+
const response = await environments.listEnvironments(token, runtimesRunUrl);
|
|
54
|
+
return response.environments;
|
|
55
|
+
}
|
|
56
|
+
// ========================================================================
|
|
57
|
+
// Runtimes
|
|
58
|
+
// ========================================================================
|
|
59
|
+
/**
|
|
60
|
+
* Create a new computational runtime.
|
|
61
|
+
*
|
|
62
|
+
* @param data - Runtime creation parameters
|
|
63
|
+
* @returns Promise resolving to created runtime
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const runtime = await sdk.createRuntime({
|
|
68
|
+
* environment_name: 'python-cpu-env',
|
|
69
|
+
* credits_limit: 100
|
|
70
|
+
* });
|
|
71
|
+
* console.log('Runtime created:', runtime.podName);
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
async createRuntime(data) {
|
|
75
|
+
const token = this.getToken();
|
|
76
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
77
|
+
const response = await runtimes.createRuntime(token, data, runtimesRunUrl);
|
|
78
|
+
return new Runtime(response.runtime, this);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* List all runtimes.
|
|
82
|
+
*
|
|
83
|
+
* @returns Promise resolving to array of runtimes
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const allRuntimes = await sdk.listRuntimes();
|
|
88
|
+
* console.log('Total runtimes:', allRuntimes.length);
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
async listRuntimes() {
|
|
92
|
+
const token = this.getToken();
|
|
93
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
94
|
+
const response = await runtimes.listRuntimes(token, runtimesRunUrl);
|
|
95
|
+
return response.runtimes.map(r => new Runtime(r, this));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get details for a specific runtime by pod name or Runtime instance.
|
|
99
|
+
*
|
|
100
|
+
* @param podNameOrRuntime - Runtime pod name (string) or Runtime instance
|
|
101
|
+
* @returns Promise resolving to runtime details
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const runtime = await sdk.getRuntime('runtime-abc123');
|
|
106
|
+
* const refreshed = await sdk.getRuntime(runtime);
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
async getRuntime(podNameOrRuntime) {
|
|
110
|
+
const podName = this._extractRuntimePodName(podNameOrRuntime);
|
|
111
|
+
const token = this.getToken();
|
|
112
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
113
|
+
const runtimeData = await runtimes.getRuntime(token, podName, runtimesRunUrl);
|
|
114
|
+
return new Runtime(runtimeData, this);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Delete a runtime permanently.
|
|
118
|
+
*
|
|
119
|
+
* @param podNameOrRuntime - Runtime pod name (string) or Runtime instance
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* await sdk.deleteRuntime('runtime-abc123');
|
|
124
|
+
* await sdk.deleteRuntime(runtime);
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
async deleteRuntime(podNameOrRuntime) {
|
|
128
|
+
const podName = this._extractRuntimePodName(podNameOrRuntime);
|
|
129
|
+
const token = this.getToken();
|
|
130
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
131
|
+
await runtimes.deleteRuntime(token, podName, runtimesRunUrl);
|
|
132
|
+
// If a Runtime instance was passed, mark it as deleted
|
|
133
|
+
if (typeof podNameOrRuntime !== 'string' &&
|
|
134
|
+
podNameOrRuntime instanceof Runtime) {
|
|
135
|
+
podNameOrRuntime._deleted = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// ========================================================================
|
|
139
|
+
// Snapshots
|
|
140
|
+
// ========================================================================
|
|
141
|
+
/**
|
|
142
|
+
* Create a snapshot of a runtime.
|
|
143
|
+
*
|
|
144
|
+
* @param data - Snapshot creation parameters
|
|
145
|
+
* @returns Promise resolving to created snapshot
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* const snapshot = await sdk.createSnapshot({
|
|
150
|
+
* pod_name: 'runtime-abc123',
|
|
151
|
+
* name: 'my-checkpoint',
|
|
152
|
+
* description: 'Before major changes'
|
|
153
|
+
* });
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
async createSnapshot(data) {
|
|
157
|
+
const token = this.getToken();
|
|
158
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
159
|
+
const response = await snapshots.createSnapshot(token, data, runtimesRunUrl);
|
|
160
|
+
return new Snapshot(response.snapshot, this);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* List all runtime snapshots.
|
|
164
|
+
*
|
|
165
|
+
* @returns Promise resolving to array of snapshots
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const allSnapshots = await sdk.listSnapshots();
|
|
170
|
+
* console.log('Total snapshots:', allSnapshots.length);
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
async listSnapshots() {
|
|
174
|
+
const token = this.getToken();
|
|
175
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
176
|
+
const response = await snapshots.listSnapshots(token, runtimesRunUrl);
|
|
177
|
+
return response.snapshots.map(s => new Snapshot(s, this));
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Get details for a specific snapshot by ID or Snapshot instance.
|
|
181
|
+
*
|
|
182
|
+
* @param idOrSnapshot - Snapshot ID (string) or Snapshot instance
|
|
183
|
+
* @returns Promise resolving to snapshot details
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* const snapshot = await sdk.getSnapshot('snapshot-abc123');
|
|
188
|
+
* const refreshed = await sdk.getSnapshot(snapshot);
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
async getSnapshot(idOrSnapshot) {
|
|
192
|
+
const snapshotId = this._extractSnapshotId(idOrSnapshot);
|
|
193
|
+
const token = this.getToken();
|
|
194
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
195
|
+
const response = await snapshots.getSnapshot(token, snapshotId, runtimesRunUrl);
|
|
196
|
+
return new Snapshot(response.snapshot, this);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Delete a snapshot permanently.
|
|
200
|
+
*
|
|
201
|
+
* @param idOrSnapshot - Snapshot ID (string) or Snapshot instance
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* await sdk.deleteSnapshot('snapshot-abc123');
|
|
206
|
+
* await sdk.deleteSnapshot(snapshot);
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
async deleteSnapshot(idOrSnapshot) {
|
|
210
|
+
const snapshotId = this._extractSnapshotId(idOrSnapshot);
|
|
211
|
+
const token = this.getToken();
|
|
212
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
213
|
+
await snapshots.deleteSnapshot(token, snapshotId, runtimesRunUrl);
|
|
214
|
+
// If a Snapshot instance was passed, mark it as deleted
|
|
215
|
+
if (typeof idOrSnapshot !== 'string' &&
|
|
216
|
+
idOrSnapshot instanceof Snapshot) {
|
|
217
|
+
idOrSnapshot._deleted = true;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { CreateSpaceRequest, CreateNotebookRequest, UpdateNotebookRequest, CreateLexicalRequest, UpdateLexicalRequest, GetSpaceItemsResponse, DeleteSpaceItemResponse } from '../../../api/types/spacer';
|
|
2
|
+
import type { Constructor } from '../utils/mixins';
|
|
3
|
+
import { Notebook } from '../models/Notebook';
|
|
4
|
+
import { Lexical } from '../models/Lexical';
|
|
5
|
+
import { Space } from '../models/Space';
|
|
6
|
+
/**
|
|
7
|
+
* Spacer mixin that provides workspace and content management.
|
|
8
|
+
*
|
|
9
|
+
* This mixin is applied to the DatalayerSDK class to provide clean, intuitive
|
|
10
|
+
* methods for managing spaces, notebooks, and cells.
|
|
11
|
+
*/
|
|
12
|
+
export declare function SpacerMixin<TBase extends Constructor>(Base: TBase): {
|
|
13
|
+
new (...args: any[]): {
|
|
14
|
+
/**
|
|
15
|
+
* Get all workspaces for the authenticated user.
|
|
16
|
+
*
|
|
17
|
+
* @returns Promise resolving to array of Space instances
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const mySpaces = await sdk.getMySpaces();
|
|
22
|
+
* console.log('My spaces:', mySpaces.length);
|
|
23
|
+
* for (const space of mySpaces) {
|
|
24
|
+
* const name = await space.getName();
|
|
25
|
+
* console.log(`- ${name} (${space.visibility})`);
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
getMySpaces(): Promise<Space[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Create a new workspace.
|
|
32
|
+
*
|
|
33
|
+
* @param data - Space creation parameters
|
|
34
|
+
* @returns Promise resolving to created Space instance
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const space = await sdk.createSpace({
|
|
39
|
+
* name: 'My Research Project',
|
|
40
|
+
* description: 'Data analysis workspace',
|
|
41
|
+
* variant: 'default',
|
|
42
|
+
* spaceHandle: 'research-project',
|
|
43
|
+
* organizationId: 'org-123',
|
|
44
|
+
* seedSpaceId: 'seed-456',
|
|
45
|
+
* public: false
|
|
46
|
+
* });
|
|
47
|
+
* const name = await space.getName();
|
|
48
|
+
* console.log('Space created:', name);
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
createSpace(data: CreateSpaceRequest): Promise<Space>;
|
|
52
|
+
_extractNotebookId(notebookIdOrInstance: string | Notebook): string;
|
|
53
|
+
_extractLexicalId(lexicalIdOrInstance: string | Lexical): string;
|
|
54
|
+
/**
|
|
55
|
+
* Create a new notebook.
|
|
56
|
+
*
|
|
57
|
+
* @param data - Notebook creation parameters
|
|
58
|
+
* @returns Promise resolving to created Notebook instance
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const notebook = await sdk.createNotebook({
|
|
63
|
+
* spaceId: 'space-123',
|
|
64
|
+
* name: 'Data Analysis',
|
|
65
|
+
* description: 'Analysis notebook',
|
|
66
|
+
* notebookType: 'jupyter',
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
createNotebook(data: CreateNotebookRequest): Promise<Notebook>;
|
|
71
|
+
/**
|
|
72
|
+
* Get a notebook by ID or Notebook instance.
|
|
73
|
+
*
|
|
74
|
+
* @param idOrNotebook - Notebook ID (string) or Notebook instance
|
|
75
|
+
* @returns Promise resolving to Notebook instance
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const notebook = await sdk.getNotebook('notebook-123');
|
|
80
|
+
* const refreshed = await sdk.getNotebook(notebook);
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
getNotebook(idOrNotebook: string | Notebook): Promise<Notebook>;
|
|
84
|
+
/**
|
|
85
|
+
* Update a notebook.
|
|
86
|
+
*
|
|
87
|
+
* @param idOrNotebook - Notebook ID (string) or Notebook instance
|
|
88
|
+
* @param data - Update data with optional name and/or description
|
|
89
|
+
* @returns Promise resolving to updated Notebook instance
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const updated = await sdk.updateNotebook('notebook-123', {
|
|
94
|
+
* name: 'Updated Analysis',
|
|
95
|
+
* description: 'Updated description'
|
|
96
|
+
* });
|
|
97
|
+
* const updated2 = await sdk.updateNotebook(notebook, {
|
|
98
|
+
* name: 'Updated Analysis',
|
|
99
|
+
* description: 'Updated description'
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
updateNotebook(idOrNotebook: string | Notebook, data: UpdateNotebookRequest): Promise<Notebook>;
|
|
104
|
+
/**
|
|
105
|
+
* Create a new lexical document.
|
|
106
|
+
*
|
|
107
|
+
* @param data - Document creation parameters
|
|
108
|
+
* @returns Promise resolving to created Lexical instance
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const lexical = await sdk.createLexical({
|
|
113
|
+
* spaceId: 'space-123',
|
|
114
|
+
* name: 'Project Documentation',
|
|
115
|
+
* description: 'Main project docs',
|
|
116
|
+
* documentType: 'document',
|
|
117
|
+
* });
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
createLexical(data: CreateLexicalRequest): Promise<Lexical>;
|
|
121
|
+
/**
|
|
122
|
+
* Get a lexical document by ID or Lexical instance.
|
|
123
|
+
*
|
|
124
|
+
* @param idOrLexical - Document ID (string) or Lexical instance
|
|
125
|
+
* @returns Promise resolving to Lexical instance
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const lexical = await sdk.getLexical('lexical-123');
|
|
130
|
+
* const refreshed = await sdk.getLexical(lexical);
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
getLexical(idOrLexical: string | Lexical): Promise<Lexical>;
|
|
134
|
+
/**
|
|
135
|
+
* Update a lexical document.
|
|
136
|
+
*
|
|
137
|
+
* @param idOrLexical - Document ID (string) or Lexical instance
|
|
138
|
+
* @param data - Update data with optional name and/or description
|
|
139
|
+
* @returns Promise resolving to updated Lexical instance
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const updated = await sdk.updateLexical('lexical-123', {
|
|
144
|
+
* name: 'Updated Documentation',
|
|
145
|
+
* description: 'Updated description'
|
|
146
|
+
* });
|
|
147
|
+
* const updated2 = await sdk.updateLexical(lexical, {
|
|
148
|
+
* name: 'Updated Documentation',
|
|
149
|
+
* description: 'Updated description'
|
|
150
|
+
* });
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
updateLexical(idOrLexical: string | Lexical, data: UpdateLexicalRequest): Promise<Lexical>;
|
|
154
|
+
/**
|
|
155
|
+
* Get the items of a space.
|
|
156
|
+
*
|
|
157
|
+
* @param spaceId - Space ID
|
|
158
|
+
* @returns Promise resolving to space items
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```typescript
|
|
162
|
+
* const response = await sdk.getSpaceItems('space-123');
|
|
163
|
+
* console.log('Space items:', response.items.length);
|
|
164
|
+
* response.items.forEach(item => {
|
|
165
|
+
* console.log(`- ${item.name} (${item.type})`);
|
|
166
|
+
* });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
getSpaceItems(spaceId: string): Promise<GetSpaceItemsResponse>;
|
|
170
|
+
/**
|
|
171
|
+
* Delete an item from a space.
|
|
172
|
+
*
|
|
173
|
+
* @param itemId - Item ID to delete
|
|
174
|
+
* @returns Promise resolving when deletion is complete
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* const response = await sdk.deleteSpaceItem('item-123');
|
|
179
|
+
* console.log('Item deleted:', response.message);
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
deleteSpaceItem(itemId: string): Promise<DeleteSpaceItemResponse>;
|
|
183
|
+
};
|
|
184
|
+
} & TBase;
|