@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
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { Constructor } from '../utils/mixins';
|
|
2
|
+
import { EnvironmentDTO } from '../../models/EnvironmentDTO';
|
|
3
|
+
import { RuntimeDTO } from '../../models/RuntimeDTO';
|
|
4
|
+
import { RuntimeSnapshotDTO } from '../../models/RuntimeSnapshotDTO';
|
|
5
|
+
import { HealthCheck } from '../../models/HealthCheck';
|
|
6
|
+
/** Options for ensuring a runtime is available. */
|
|
7
|
+
export interface EnsureRuntimeOptions {
|
|
8
|
+
/** Name of the environment to use */
|
|
9
|
+
environmentName?: string;
|
|
10
|
+
/** Maximum credits to allocate */
|
|
11
|
+
creditsLimit?: number;
|
|
12
|
+
/** Whether to wait for runtime to be ready */
|
|
13
|
+
waitForReady?: boolean;
|
|
14
|
+
/** Maximum time to wait for ready state (ms) */
|
|
15
|
+
maxWaitTime?: number;
|
|
16
|
+
/** Whether to reuse existing suitable runtime */
|
|
17
|
+
reuseExisting?: boolean;
|
|
18
|
+
/** Snapshot ID to create runtime from */
|
|
19
|
+
snapshotId?: string;
|
|
20
|
+
}
|
|
21
|
+
/** Runtimes mixin providing computational environment and runtime management. */
|
|
22
|
+
export declare function RuntimesMixin<TBase extends Constructor>(Base: TBase): {
|
|
23
|
+
new (...args: any[]): {
|
|
24
|
+
_extractRuntimePodName(runtimePodNameOrInstance: string | RuntimeDTO): string;
|
|
25
|
+
_extractSnapshotId(snapshotIdOrInstance: string | RuntimeSnapshotDTO): string;
|
|
26
|
+
/**
|
|
27
|
+
* List all available computational environments.
|
|
28
|
+
* @returns Array of Environment model instances
|
|
29
|
+
*/
|
|
30
|
+
listEnvironments(): Promise<EnvironmentDTO[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Create a new computational runtime.
|
|
33
|
+
* @param environmentName - Name of the environment to use
|
|
34
|
+
* @param type - Type of runtime
|
|
35
|
+
* @param givenName - User-friendly name for the runtime
|
|
36
|
+
* @param creditsLimit - Credits limit
|
|
37
|
+
* @returns Created runtime
|
|
38
|
+
*/
|
|
39
|
+
createRuntime(environmentName: string, type: "notebook" | "terminal" | "job", givenName: string, minutesLimit: number, fromSnapshotId?: string): Promise<RuntimeDTO>;
|
|
40
|
+
/**
|
|
41
|
+
* List all runtimes.
|
|
42
|
+
* @returns Array of runtimes
|
|
43
|
+
*/
|
|
44
|
+
listRuntimes(): Promise<RuntimeDTO[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Get details for a specific runtime by pod name.
|
|
47
|
+
* @param podName - Runtime pod name
|
|
48
|
+
* @returns Runtime details
|
|
49
|
+
*/
|
|
50
|
+
getRuntime(podName: string): Promise<RuntimeDTO>;
|
|
51
|
+
/**
|
|
52
|
+
* Delete a runtime permanently.
|
|
53
|
+
* @param podName - Runtime pod name
|
|
54
|
+
*/
|
|
55
|
+
deleteRuntime(podName: string): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Terminate all runtimes.
|
|
58
|
+
* Lists all runtimes and deletes them in parallel.
|
|
59
|
+
* @returns Array of results for each deletion (fulfilled or rejected)
|
|
60
|
+
*/
|
|
61
|
+
terminateAllRuntimes(): Promise<PromiseSettledResult<void>[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Create a snapshot of a runtime.
|
|
64
|
+
* @param podName - Pod name of the runtime to snapshot
|
|
65
|
+
* @param name - Name for the snapshot
|
|
66
|
+
* @param description - Description of the snapshot
|
|
67
|
+
* @param stop - Whether to stop the runtime after creating snapshot (defaults to false)
|
|
68
|
+
* @returns Created snapshot
|
|
69
|
+
*/
|
|
70
|
+
createSnapshot(podName: string, name: string, description: string, stop?: boolean): Promise<RuntimeSnapshotDTO>;
|
|
71
|
+
/**
|
|
72
|
+
* List all runtime snapshots.
|
|
73
|
+
* @returns Array of snapshots
|
|
74
|
+
*/
|
|
75
|
+
listSnapshots(): Promise<RuntimeSnapshotDTO[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Get details for a specific snapshot by ID.
|
|
78
|
+
* @param id - Snapshot ID
|
|
79
|
+
* @returns Snapshot details
|
|
80
|
+
*/
|
|
81
|
+
getSnapshot(id: string): Promise<RuntimeSnapshotDTO>;
|
|
82
|
+
/**
|
|
83
|
+
* Delete a snapshot permanently.
|
|
84
|
+
* @param id - Snapshot ID
|
|
85
|
+
*/
|
|
86
|
+
deleteSnapshot(id: string): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Check the health status of the Runtimes service.
|
|
89
|
+
* @returns Health check result with status and response time
|
|
90
|
+
*/
|
|
91
|
+
checkRuntimesHealth(): Promise<HealthCheck>;
|
|
92
|
+
};
|
|
93
|
+
} & TBase;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Runtimes mixin for managing computational environments and runtime instances.
|
|
7
|
+
* @module client/mixins/RuntimesMixin
|
|
8
|
+
*/
|
|
9
|
+
import * as environments from '../../api/runtimes/environments';
|
|
10
|
+
import * as runtimes from '../../api/runtimes/runtimes';
|
|
11
|
+
import * as snapshots from '../../api/runtimes/snapshots';
|
|
12
|
+
import { EnvironmentDTO } from '../../models/EnvironmentDTO';
|
|
13
|
+
import { RuntimeDTO } from '../../models/RuntimeDTO';
|
|
14
|
+
import { RuntimeSnapshotDTO } from '../../models/RuntimeSnapshotDTO';
|
|
15
|
+
import { HealthCheck } from '../../models/HealthCheck';
|
|
16
|
+
/** Runtimes mixin providing computational environment and runtime management. */
|
|
17
|
+
export function RuntimesMixin(Base) {
|
|
18
|
+
return class extends Base {
|
|
19
|
+
// ========================================================================
|
|
20
|
+
// Helper Functions
|
|
21
|
+
// ========================================================================
|
|
22
|
+
_extractRuntimePodName(runtimePodNameOrInstance) {
|
|
23
|
+
return typeof runtimePodNameOrInstance === 'string'
|
|
24
|
+
? runtimePodNameOrInstance
|
|
25
|
+
: runtimePodNameOrInstance.podName;
|
|
26
|
+
}
|
|
27
|
+
_extractSnapshotId(snapshotIdOrInstance) {
|
|
28
|
+
return typeof snapshotIdOrInstance === 'string'
|
|
29
|
+
? snapshotIdOrInstance
|
|
30
|
+
: snapshotIdOrInstance.uid;
|
|
31
|
+
}
|
|
32
|
+
// ========================================================================
|
|
33
|
+
// Environments
|
|
34
|
+
// ========================================================================
|
|
35
|
+
/**
|
|
36
|
+
* List all available computational environments.
|
|
37
|
+
* @returns Array of Environment model instances
|
|
38
|
+
*/
|
|
39
|
+
async listEnvironments() {
|
|
40
|
+
const token = this.getToken();
|
|
41
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
42
|
+
const response = await environments.listEnvironments(token, runtimesRunUrl);
|
|
43
|
+
// Save for later use after first call
|
|
44
|
+
this.environments = response.environments.map(env => new EnvironmentDTO(env, this));
|
|
45
|
+
return this.environments;
|
|
46
|
+
}
|
|
47
|
+
// ========================================================================
|
|
48
|
+
// Runtimes
|
|
49
|
+
// ========================================================================
|
|
50
|
+
/**
|
|
51
|
+
* Create a new computational runtime.
|
|
52
|
+
* @param environmentName - Name of the environment to use
|
|
53
|
+
* @param type - Type of runtime
|
|
54
|
+
* @param givenName - User-friendly name for the runtime
|
|
55
|
+
* @param creditsLimit - Credits limit
|
|
56
|
+
* @returns Created runtime
|
|
57
|
+
*/
|
|
58
|
+
async createRuntime(environmentName, type, givenName, minutesLimit, fromSnapshotId) {
|
|
59
|
+
if (!this.environments) {
|
|
60
|
+
await this.listEnvironments();
|
|
61
|
+
}
|
|
62
|
+
if (this.environments) {
|
|
63
|
+
const env = this.environments.find((e) => e.name === environmentName);
|
|
64
|
+
if (!env) {
|
|
65
|
+
throw new Error(`Environment "${environmentName}" not found. Available environments: ${this.environments.map((e) => e.name).join(', ')}`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const token = this.getToken();
|
|
69
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
70
|
+
const creditsLimit = this.calculateCreditsFromMinutes(minutesLimit, env.burningRate);
|
|
71
|
+
const data = {
|
|
72
|
+
environment_name: environmentName,
|
|
73
|
+
type,
|
|
74
|
+
given_name: givenName,
|
|
75
|
+
credits_limit: creditsLimit,
|
|
76
|
+
from: fromSnapshotId,
|
|
77
|
+
};
|
|
78
|
+
const response = await runtimes.createRuntime(token, data, runtimesRunUrl);
|
|
79
|
+
return new RuntimeDTO(response.runtime, this);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
throw new Error('Environments not loaded');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* List all runtimes.
|
|
88
|
+
* @returns Array of runtimes
|
|
89
|
+
*/
|
|
90
|
+
async listRuntimes() {
|
|
91
|
+
const token = this.getToken();
|
|
92
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
93
|
+
const response = await runtimes.listRuntimes(token, runtimesRunUrl);
|
|
94
|
+
return response.runtimes.map(r => new RuntimeDTO(r, this));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get details for a specific runtime by pod name.
|
|
98
|
+
* @param podName - Runtime pod name
|
|
99
|
+
* @returns Runtime details
|
|
100
|
+
*/
|
|
101
|
+
async getRuntime(podName) {
|
|
102
|
+
const token = this.getToken();
|
|
103
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
104
|
+
const runtimeData = await runtimes.getRuntime(token, podName, runtimesRunUrl);
|
|
105
|
+
return new RuntimeDTO(runtimeData, this);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Delete a runtime permanently.
|
|
109
|
+
* @param podName - Runtime pod name
|
|
110
|
+
*/
|
|
111
|
+
async deleteRuntime(podName) {
|
|
112
|
+
const token = this.getToken();
|
|
113
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
114
|
+
await runtimes.deleteRuntime(token, podName, runtimesRunUrl);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Terminate all runtimes.
|
|
118
|
+
* Lists all runtimes and deletes them in parallel.
|
|
119
|
+
* @returns Array of results for each deletion (fulfilled or rejected)
|
|
120
|
+
*/
|
|
121
|
+
async terminateAllRuntimes() {
|
|
122
|
+
const token = this.getToken();
|
|
123
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
124
|
+
// List all runtimes
|
|
125
|
+
const response = await runtimes.listRuntimes(token, runtimesRunUrl);
|
|
126
|
+
// Delete all runtimes in parallel
|
|
127
|
+
const deletePromises = response.runtimes.map(runtime => runtimes.deleteRuntime(token, runtime.pod_name, runtimesRunUrl));
|
|
128
|
+
return Promise.allSettled(deletePromises);
|
|
129
|
+
}
|
|
130
|
+
// ========================================================================
|
|
131
|
+
// Snapshots
|
|
132
|
+
// ========================================================================
|
|
133
|
+
/**
|
|
134
|
+
* Create a snapshot of a runtime.
|
|
135
|
+
* @param podName - Pod name of the runtime to snapshot
|
|
136
|
+
* @param name - Name for the snapshot
|
|
137
|
+
* @param description - Description of the snapshot
|
|
138
|
+
* @param stop - Whether to stop the runtime after creating snapshot (defaults to false)
|
|
139
|
+
* @returns Created snapshot
|
|
140
|
+
*/
|
|
141
|
+
async createSnapshot(podName, name, description, stop = false) {
|
|
142
|
+
const token = this.getToken();
|
|
143
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
144
|
+
const data = {
|
|
145
|
+
pod_name: podName,
|
|
146
|
+
name,
|
|
147
|
+
description,
|
|
148
|
+
stop,
|
|
149
|
+
};
|
|
150
|
+
const response = await snapshots.createSnapshot(token, data, runtimesRunUrl);
|
|
151
|
+
return new RuntimeSnapshotDTO(response.snapshot, this);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* List all runtime snapshots.
|
|
155
|
+
* @returns Array of snapshots
|
|
156
|
+
*/
|
|
157
|
+
async listSnapshots() {
|
|
158
|
+
const token = this.getToken();
|
|
159
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
160
|
+
const response = await snapshots.listSnapshots(token, runtimesRunUrl);
|
|
161
|
+
return response.snapshots.map(s => new RuntimeSnapshotDTO(s, this));
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get details for a specific snapshot by ID.
|
|
165
|
+
* @param id - Snapshot ID
|
|
166
|
+
* @returns Snapshot details
|
|
167
|
+
*/
|
|
168
|
+
async getSnapshot(id) {
|
|
169
|
+
const token = this.getToken();
|
|
170
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
171
|
+
const response = await snapshots.getSnapshot(token, id, runtimesRunUrl);
|
|
172
|
+
return new RuntimeSnapshotDTO(response.snapshot, this);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Delete a snapshot permanently.
|
|
176
|
+
* @param id - Snapshot ID
|
|
177
|
+
*/
|
|
178
|
+
async deleteSnapshot(id) {
|
|
179
|
+
const token = this.getToken();
|
|
180
|
+
const runtimesRunUrl = this.getRuntimesRunUrl();
|
|
181
|
+
await snapshots.deleteSnapshot(token, id, runtimesRunUrl);
|
|
182
|
+
}
|
|
183
|
+
// ========================================================================
|
|
184
|
+
// Service Health Checks
|
|
185
|
+
// ========================================================================
|
|
186
|
+
/**
|
|
187
|
+
* Check the health status of the Runtimes service.
|
|
188
|
+
* @returns Health check result with status and response time
|
|
189
|
+
*/
|
|
190
|
+
async checkRuntimesHealth() {
|
|
191
|
+
const startTime = Date.now();
|
|
192
|
+
const errors = [];
|
|
193
|
+
let status = 'unknown';
|
|
194
|
+
let healthy = false;
|
|
195
|
+
try {
|
|
196
|
+
// Test basic connectivity by listing environments (lightweight operation)
|
|
197
|
+
const environments = await this.listEnvironments();
|
|
198
|
+
const responseTime = Date.now() - startTime;
|
|
199
|
+
if (Array.isArray(environments)) {
|
|
200
|
+
healthy = true;
|
|
201
|
+
status = 'operational';
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
status = 'degraded';
|
|
205
|
+
errors.push('Unexpected response format from environments endpoint');
|
|
206
|
+
}
|
|
207
|
+
return new HealthCheck({
|
|
208
|
+
healthy,
|
|
209
|
+
status,
|
|
210
|
+
responseTime,
|
|
211
|
+
errors,
|
|
212
|
+
timestamp: new Date(),
|
|
213
|
+
}, this);
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
const responseTime = Date.now() - startTime;
|
|
217
|
+
status = 'down';
|
|
218
|
+
errors.push(`Service unreachable: ${error}`);
|
|
219
|
+
return new HealthCheck({
|
|
220
|
+
healthy: false,
|
|
221
|
+
status,
|
|
222
|
+
responseTime,
|
|
223
|
+
errors,
|
|
224
|
+
timestamp: new Date(),
|
|
225
|
+
}, this);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Constructor } from '../utils/mixins';
|
|
2
|
+
import { NotebookDTO } from '../../models/NotebookDTO';
|
|
3
|
+
import { LexicalDTO } from '../../models/LexicalDTO';
|
|
4
|
+
import { SpaceDTO } from '../../models/SpaceDTO';
|
|
5
|
+
import { HealthCheck } from '../../models/HealthCheck';
|
|
6
|
+
/** Options for content loading with CDN support. */
|
|
7
|
+
export interface ContentLoadingOptions {
|
|
8
|
+
/** Whether to try CDN first before API (default: true) */
|
|
9
|
+
preferCDN?: boolean;
|
|
10
|
+
/** CDN base URL (default: https://cdn.datalayer.run) */
|
|
11
|
+
cdnBaseUrl?: string;
|
|
12
|
+
}
|
|
13
|
+
/** Spacer mixin providing workspace and content management. */
|
|
14
|
+
export declare function SpacerMixin<TBase extends Constructor>(Base: TBase): {
|
|
15
|
+
new (...args: any[]): {
|
|
16
|
+
/**
|
|
17
|
+
* Get all workspaces for the authenticated user.
|
|
18
|
+
* @returns Array of Space instances
|
|
19
|
+
*/
|
|
20
|
+
getMySpaces(): Promise<SpaceDTO[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Create a new workspace.
|
|
23
|
+
* @param name - Space name
|
|
24
|
+
* @param description - Space description
|
|
25
|
+
* @param variant - Space variant type
|
|
26
|
+
* @param spaceHandle - Unique handle for the space
|
|
27
|
+
* @param organizationId - Organization ID
|
|
28
|
+
* @param seedSpaceId - Seed space ID for initialization
|
|
29
|
+
* @param isPublic - Whether the space is public
|
|
30
|
+
* @returns Created Space instance
|
|
31
|
+
*/
|
|
32
|
+
createSpace(name: string, description: string, variant: string, spaceHandle: string, organizationId: string, seedSpaceId: string, isPublic: boolean): Promise<SpaceDTO>;
|
|
33
|
+
/**
|
|
34
|
+
* Create a new notebook.
|
|
35
|
+
* @param spaceId - ID of the space to create the notebook in
|
|
36
|
+
* @param name - Name of the notebook
|
|
37
|
+
* @param description - Description of the notebook
|
|
38
|
+
* @param file - Optional file for notebook content
|
|
39
|
+
* @returns Created Notebook instance
|
|
40
|
+
*/
|
|
41
|
+
createNotebook(spaceId: string, name: string, description: string, file?: File | Blob): Promise<NotebookDTO>;
|
|
42
|
+
/**
|
|
43
|
+
* Get a notebook by ID.
|
|
44
|
+
* @param id - Notebook ID
|
|
45
|
+
* @returns Notebook instance
|
|
46
|
+
*/
|
|
47
|
+
getNotebook(id: string): Promise<NotebookDTO>;
|
|
48
|
+
/**
|
|
49
|
+
* Update a notebook.
|
|
50
|
+
* @param id - Notebook ID
|
|
51
|
+
* @param name - Optional new name for the notebook
|
|
52
|
+
* @param description - Optional new description for the notebook
|
|
53
|
+
* @returns Updated Notebook instance
|
|
54
|
+
*/
|
|
55
|
+
updateNotebook(id: string, name?: string, description?: string): Promise<NotebookDTO>;
|
|
56
|
+
/**
|
|
57
|
+
* Create a new lexical document.
|
|
58
|
+
* @param spaceId - ID of the space to create the lexical document in
|
|
59
|
+
* @param name - Name of the lexical document
|
|
60
|
+
* @param description - Description of the lexical document
|
|
61
|
+
* @param file - Optional file for document content
|
|
62
|
+
* @returns Created Lexical instance
|
|
63
|
+
*/
|
|
64
|
+
createLexical(spaceId: string, name: string, description: string, file?: File | Blob): Promise<LexicalDTO>;
|
|
65
|
+
/**
|
|
66
|
+
* Get a lexical document by ID.
|
|
67
|
+
* @param id - Document ID
|
|
68
|
+
* @returns Lexical instance
|
|
69
|
+
*/
|
|
70
|
+
getLexical(id: string): Promise<LexicalDTO>;
|
|
71
|
+
/**
|
|
72
|
+
* Update a lexical document.
|
|
73
|
+
* @param id - Document ID
|
|
74
|
+
* @param name - Optional new name for the lexical document
|
|
75
|
+
* @param description - Optional new description for the lexical document
|
|
76
|
+
* @returns Updated Lexical instance
|
|
77
|
+
*/
|
|
78
|
+
updateLexical(id: string, name?: string, description?: string): Promise<LexicalDTO>;
|
|
79
|
+
/**
|
|
80
|
+
* Get the items of a space as model instances.
|
|
81
|
+
* @param spaceId - Space ID
|
|
82
|
+
* @returns Array of Notebook and Lexical model instances
|
|
83
|
+
*/
|
|
84
|
+
getSpaceItems(spaceId: string): Promise<(NotebookDTO | LexicalDTO)[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Get a single item from a space.
|
|
87
|
+
* @param itemId - Item ID to retrieve
|
|
88
|
+
* @returns Notebook or Lexical model instance
|
|
89
|
+
* @throws Error if item not found
|
|
90
|
+
*/
|
|
91
|
+
getSpaceItem(itemId: string): Promise<NotebookDTO | LexicalDTO>;
|
|
92
|
+
/**
|
|
93
|
+
* Delete an item from a space.
|
|
94
|
+
* @param itemId - Item ID to delete
|
|
95
|
+
* @throws Error if deletion fails
|
|
96
|
+
*/
|
|
97
|
+
deleteSpaceItem(itemId: string): Promise<void>;
|
|
98
|
+
getContent(itemId: string): Promise<any>;
|
|
99
|
+
/**
|
|
100
|
+
* Check the health status of the Spacer service.
|
|
101
|
+
* Performs a lightweight check to verify service accessibility.
|
|
102
|
+
*
|
|
103
|
+
* @returns Health check result with status and response time
|
|
104
|
+
*/
|
|
105
|
+
checkSpacerHealth(): Promise<HealthCheck>;
|
|
106
|
+
/**
|
|
107
|
+
* Get collaboration session ID for a document
|
|
108
|
+
*/
|
|
109
|
+
getCollaborationSessionId(documentId: string): Promise<string>;
|
|
110
|
+
};
|
|
111
|
+
} & TBase;
|