@datalayer/core 0.0.24 → 0.0.26
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 +11 -11
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.js +1 -1
- package/lib/api/spacer/agentSpaces.d.ts +193 -0
- package/lib/api/spacer/agentSpaces.js +127 -0
- package/lib/api/spacer/index.d.ts +2 -1
- package/lib/api/spacer/index.js +2 -1
- package/lib/api/utils/validation.d.ts +1 -1
- package/lib/api/utils/validation.js +1 -1
- package/lib/client/auth/AuthenticationManager.d.ts +2 -2
- package/lib/client/auth/AuthenticationManager.js +2 -2
- package/lib/client/auth/index.d.ts +1 -1
- package/lib/client/auth/index.js +1 -1
- package/lib/client/auth/types.d.ts +1 -1
- package/lib/client/auth/types.js +1 -1
- package/lib/client/base.d.ts +9 -9
- package/lib/client/base.js +3 -3
- package/lib/client/constants.d.ts +2 -2
- package/lib/client/constants.js +2 -2
- package/lib/client/index.d.ts +2 -2
- package/lib/client/mixins/IAMMixin.js +1 -1
- package/lib/client/utils/spacerUtils.d.ts +1 -1
- package/lib/client/utils/spacerUtils.js +1 -1
- package/lib/components/progress/ConsumptionBar.js +19 -1
- package/lib/hooks/useCache.d.ts +95 -2
- package/lib/hooks/useCache.js +422 -9
- package/lib/hooks/useNavigate.d.ts +1 -1
- package/lib/hooks/useNavigate.js +11 -1
- package/lib/index.d.ts +1 -1
- package/lib/models/CreditsDTO.js +1 -1
- package/lib/models/Datasource.d.ts +2 -2
- package/lib/models/Datasource.js +2 -2
- package/lib/models/EnvironmentDTO.d.ts +3 -3
- package/lib/models/EnvironmentDTO.js +2 -2
- package/lib/models/HealthCheck.d.ts +1 -1
- package/lib/models/HealthCheck.js +1 -1
- package/lib/models/ItemDTO.d.ts +2 -2
- package/lib/models/ItemDTO.js +2 -2
- package/lib/models/LexicalDTO.d.ts +2 -2
- package/lib/models/LexicalDTO.js +2 -2
- package/lib/models/NotebookDTO.d.ts +2 -2
- package/lib/models/NotebookDTO.js +1 -1
- package/lib/models/RuntimeDTO.d.ts +2 -2
- package/lib/models/RuntimeDTO.js +2 -2
- package/lib/models/RuntimeSnapshotDTO.d.ts +3 -3
- package/lib/models/RuntimeSnapshotDTO.js +1 -1
- package/lib/models/Secret.d.ts +3 -3
- package/lib/models/Secret.js +2 -2
- package/lib/models/SpaceDTO.d.ts +2 -2
- package/lib/models/SpaceDTO.js +3 -3
- package/lib/models/UserDTO.d.ts +2 -2
- package/lib/models/UserDTO.js +1 -1
- package/lib/models/index.d.ts +1 -1
- package/lib/models/index.js +1 -1
- package/lib/state/substates/CoreState.js +1 -1
- package/lib/theme/DatalayerTheme.d.ts +17 -2
- package/lib/theme/DatalayerTheme.js +195 -29
- package/lib/theme/DatalayerThemeProvider.d.ts +22 -2
- package/lib/theme/DatalayerThemeProvider.js +48 -5
- package/lib/theme/index.d.ts +1 -0
- package/lib/theme/index.js +1 -0
- package/lib/theme/useSystemColorMode.d.ts +9 -0
- package/lib/theme/useSystemColorMode.js +26 -0
- package/lib/views/iam-tokens/IAMTokenNew.d.ts +5 -1
- package/lib/views/iam-tokens/IAMTokenNew.js +2 -2
- package/lib/views/iam-tokens/IAMTokens.d.ts +7 -1
- package/lib/views/iam-tokens/IAMTokens.js +6 -4
- package/package.json +3 -3
- package/lib/hooks/useCache0.d.ts +0 -312
- package/lib/hooks/useCache0.js +0 -3189
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/sponsors/datalayer)
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# ☰ Datalayer Core
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<strong>Python and Typescript libraries for Datalayer</strong>
|
|
@@ -28,8 +28,8 @@ This package serves as the base foundation used by many other Datalayer packages
|
|
|
28
28
|
- **⚡ Runtime Management**: Create and manage scalable compute runtimes (CPU/GPU) for code execution
|
|
29
29
|
- **📸 Snapshot Management**: Create and manage compute snapshots of your runtimes for reproducible environments
|
|
30
30
|
- **🔒 Secrets Management**: Securely handle sensitive data and credentials in your workflows
|
|
31
|
-
- **🐍 Python
|
|
32
|
-
- **🌐 TypeScript/React
|
|
31
|
+
- **🐍 Python Client**: Programmatic access to Datalayer platform with context managers and clean resource management
|
|
32
|
+
- **🌐 TypeScript/React Client**: React components and services for building Jupyter-based applications
|
|
33
33
|
- **💻 Command Line Interface**: CLI tools for managing runtimes, snapshots, and platform resources
|
|
34
34
|
- **🔧 Base Classes**: Core application classes and configuration inherited by other Datalayer projects
|
|
35
35
|
- **📓 Jupyter Integration**: ServiceManager and collaboration providers for notebook experiences
|
|
@@ -37,7 +37,7 @@ This package serves as the base foundation used by many other Datalayer packages
|
|
|
37
37
|
|
|
38
38
|
## Installation
|
|
39
39
|
|
|
40
|
-
### Python
|
|
40
|
+
### Python Client
|
|
41
41
|
|
|
42
42
|
Install Datalayer Core using pip:
|
|
43
43
|
|
|
@@ -45,7 +45,7 @@ Install Datalayer Core using pip:
|
|
|
45
45
|
pip install datalayer-core
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
### TypeScript/React
|
|
48
|
+
### TypeScript/React Client
|
|
49
49
|
|
|
50
50
|
Install as an npm package:
|
|
51
51
|
|
|
@@ -76,7 +76,7 @@ Set your Datalayer token as an environment variable:
|
|
|
76
76
|
export DATALAYER_API_KEY="your-api-key"
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
Or pass it directly to the
|
|
79
|
+
Or pass it directly to the Client:
|
|
80
80
|
|
|
81
81
|
```python
|
|
82
82
|
from datalayer_core import DatalayerClient
|
|
@@ -182,16 +182,16 @@ Features:
|
|
|
182
182
|
|
|
183
183
|
Datalayer adds AI capabilities and scalable compute runtimes to your development workflows. The platform is designed to seamlessly integrate into your existing processes and supercharge your computations with the processing power you need.
|
|
184
184
|
|
|
185
|
-
Key platform features accessible through this
|
|
185
|
+
Key platform features accessible through this Client and CLI:
|
|
186
186
|
|
|
187
187
|
- **Remote Runtimes**: Execute code on powerful remote machines with CPU, RAM, and GPU resources
|
|
188
|
-
- **Multiple Interfaces**: Access and consume runtimes through Python
|
|
188
|
+
- **Multiple Interfaces**: Access and consume runtimes through Python Client, CLI, or other integrated tools
|
|
189
189
|
- **Scalable Compute**: Dynamically scale your computational resources based on workload requirements
|
|
190
190
|
|
|
191
191
|
## Documentation
|
|
192
192
|
|
|
193
193
|
- **Command Line Interface (CLI)**: [https://docs.datalayer.app/cli/](https://docs.datalayer.app/cli/)
|
|
194
|
-
- **Core Python
|
|
194
|
+
- **Core Python Client**: [core.datalayer.tech/python/](https://core.datalayer.tech/python/)
|
|
195
195
|
- **Platform Documentation**: [docs.datalayer.app](https://docs.datalayer.app/)
|
|
196
196
|
- **API Reference**: [API documentation](https://docs.datalayer.app/api/)
|
|
197
197
|
|
|
@@ -256,7 +256,7 @@ npm run test:coverage # With coverage
|
|
|
256
256
|
|
|
257
257
|
### Contributing
|
|
258
258
|
|
|
259
|
-
This
|
|
259
|
+
This Client is designed to be simple and extensible. We welcome contributions! Please:
|
|
260
260
|
|
|
261
261
|
1. Fork the repository
|
|
262
262
|
2. Create a feature branch
|
|
@@ -278,7 +278,7 @@ Datalayer Core serves as the foundation for the entire Datalayer ecosystem:
|
|
|
278
278
|
|
|
279
279
|
## Use Cases
|
|
280
280
|
|
|
281
|
-
- **AI/ML Development**: Scale your machine learning workflows with cloud compute using
|
|
281
|
+
- **AI/ML Development**: Scale your machine learning workflows with cloud compute using Client or CLI
|
|
282
282
|
- **Data Analysis**: Process large datasets with powerful remote runtimes
|
|
283
283
|
- **Research**: Collaborate on computational research with reproducible environments
|
|
284
284
|
- **Automation**: Integrate Datalayer into CI/CD pipelines and automated workflows using CLI tools
|
package/lib/api/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Minimal API layer for the Datalayer platform providing base HTTP client and functional API methods.
|
|
3
3
|
*
|
|
4
4
|
* This module contains the low-level API functionality. For high-level object-oriented
|
|
5
|
-
*
|
|
5
|
+
* Client classes, use @datalayer/core/sdk instead.
|
|
6
6
|
*
|
|
7
7
|
* @module @datalayer/core/api
|
|
8
8
|
*/
|
package/lib/api/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Minimal API layer for the Datalayer platform providing base HTTP client and functional API methods.
|
|
7
7
|
*
|
|
8
8
|
* This module contains the low-level API functionality. For high-level object-oriented
|
|
9
|
-
*
|
|
9
|
+
* Client classes, use @datalayer/core/sdk instead.
|
|
10
10
|
*
|
|
11
11
|
* @module @datalayer/core/api
|
|
12
12
|
*/
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server tool configuration
|
|
3
|
+
*/
|
|
4
|
+
export interface MCPServerTool {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* MCP Server configuration
|
|
11
|
+
*/
|
|
12
|
+
export interface MCPServer {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
tools: MCPServerTool[];
|
|
18
|
+
command?: string;
|
|
19
|
+
args: string[];
|
|
20
|
+
isAvailable: boolean;
|
|
21
|
+
transport: 'stdio' | 'http';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Agent skill configuration
|
|
25
|
+
*/
|
|
26
|
+
export interface AgentSkill {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
version: string;
|
|
31
|
+
tags: string[];
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Agent specification model
|
|
36
|
+
*/
|
|
37
|
+
export interface AgentSpec {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
description: string;
|
|
41
|
+
tags: string[];
|
|
42
|
+
enabled: boolean;
|
|
43
|
+
mcpServers: MCPServer[];
|
|
44
|
+
skills: AgentSkill[];
|
|
45
|
+
environmentName: string;
|
|
46
|
+
icon?: string;
|
|
47
|
+
color?: string;
|
|
48
|
+
/** Chat suggestions to show users what this agent can do */
|
|
49
|
+
suggestions?: string[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Agent space status
|
|
53
|
+
*/
|
|
54
|
+
export type AgentSpaceStatus = 'starting' | 'running' | 'paused' | 'terminated' | 'archived';
|
|
55
|
+
/**
|
|
56
|
+
* Agent space data
|
|
57
|
+
*/
|
|
58
|
+
export interface AgentSpaceData {
|
|
59
|
+
id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
description: string;
|
|
62
|
+
status: AgentSpaceStatus;
|
|
63
|
+
isPublic: boolean;
|
|
64
|
+
tags: string[];
|
|
65
|
+
messageCount: number;
|
|
66
|
+
createdAt?: string;
|
|
67
|
+
updatedAt?: string;
|
|
68
|
+
thumbnail?: string;
|
|
69
|
+
lastMessage?: string;
|
|
70
|
+
author?: string;
|
|
71
|
+
avatarUrl?: string;
|
|
72
|
+
stars?: number;
|
|
73
|
+
podName?: string;
|
|
74
|
+
runtimeUrl?: string;
|
|
75
|
+
creatorUid?: string;
|
|
76
|
+
creatorHandle?: string;
|
|
77
|
+
agentSpec?: AgentSpec;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Request to create an agent space
|
|
81
|
+
*/
|
|
82
|
+
export interface CreateAgentSpaceRequest {
|
|
83
|
+
/** Name of the agent space */
|
|
84
|
+
name: string;
|
|
85
|
+
/** Parent space ID */
|
|
86
|
+
spaceId: string;
|
|
87
|
+
/** Description */
|
|
88
|
+
description?: string;
|
|
89
|
+
/** Tags for categorization */
|
|
90
|
+
tags?: string[];
|
|
91
|
+
/** Initial status */
|
|
92
|
+
status?: AgentSpaceStatus;
|
|
93
|
+
/** Whether publicly visible */
|
|
94
|
+
isPublic?: boolean;
|
|
95
|
+
/** Agent specification */
|
|
96
|
+
agentSpec?: AgentSpec;
|
|
97
|
+
/** Thumbnail URL */
|
|
98
|
+
thumbnail?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Request to update an agent space
|
|
102
|
+
*/
|
|
103
|
+
export interface UpdateAgentSpaceRequest {
|
|
104
|
+
name?: string;
|
|
105
|
+
description?: string;
|
|
106
|
+
tags?: string[];
|
|
107
|
+
status?: AgentSpaceStatus;
|
|
108
|
+
isPublic?: boolean;
|
|
109
|
+
agentSpec?: AgentSpec;
|
|
110
|
+
podName?: string;
|
|
111
|
+
runtimeUrl?: string;
|
|
112
|
+
messageCount?: number;
|
|
113
|
+
lastMessage?: string;
|
|
114
|
+
thumbnail?: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Response for single agent space operations
|
|
118
|
+
*/
|
|
119
|
+
export interface AgentSpaceResponse {
|
|
120
|
+
success: boolean;
|
|
121
|
+
message: string;
|
|
122
|
+
agentSpace?: AgentSpaceData;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Response for listing agent spaces
|
|
126
|
+
*/
|
|
127
|
+
export interface AgentSpacesResponse {
|
|
128
|
+
success: boolean;
|
|
129
|
+
message: string;
|
|
130
|
+
agentSpaces?: AgentSpaceData[];
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Create a new agent space.
|
|
134
|
+
* @param token - Authentication token
|
|
135
|
+
* @param data - Agent space creation configuration
|
|
136
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
137
|
+
* @returns Promise resolving to the created agent space response
|
|
138
|
+
*/
|
|
139
|
+
export declare const createAgentSpace: (token: string, data: CreateAgentSpaceRequest, baseUrl?: string) => Promise<AgentSpaceResponse>;
|
|
140
|
+
/**
|
|
141
|
+
* List agent spaces for the current user.
|
|
142
|
+
* @param token - Authentication token
|
|
143
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
144
|
+
* @returns Promise resolving to the list of agent spaces
|
|
145
|
+
*/
|
|
146
|
+
export declare const listAgentSpaces: (token: string, baseUrl?: string) => Promise<AgentSpacesResponse>;
|
|
147
|
+
/**
|
|
148
|
+
* List all public agent spaces (Library).
|
|
149
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
150
|
+
* @returns Promise resolving to the list of public agent spaces
|
|
151
|
+
*/
|
|
152
|
+
export declare const listPublicAgentSpaces: (baseUrl?: string) => Promise<AgentSpacesResponse>;
|
|
153
|
+
/**
|
|
154
|
+
* Get an agent space by UID.
|
|
155
|
+
* @param token - Authentication token
|
|
156
|
+
* @param uid - The agent space UID
|
|
157
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
158
|
+
* @returns Promise resolving to the agent space
|
|
159
|
+
*/
|
|
160
|
+
export declare const getAgentSpace: (token: string, uid: string, baseUrl?: string) => Promise<AgentSpaceResponse>;
|
|
161
|
+
/**
|
|
162
|
+
* Update an agent space.
|
|
163
|
+
* @param token - Authentication token
|
|
164
|
+
* @param uid - The agent space UID
|
|
165
|
+
* @param data - Update data
|
|
166
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
167
|
+
* @returns Promise resolving to the updated agent space
|
|
168
|
+
*/
|
|
169
|
+
export declare const updateAgentSpace: (token: string, uid: string, data: UpdateAgentSpaceRequest, baseUrl?: string) => Promise<AgentSpaceResponse>;
|
|
170
|
+
/**
|
|
171
|
+
* Delete an agent space.
|
|
172
|
+
* @param token - Authentication token
|
|
173
|
+
* @param uid - The agent space UID
|
|
174
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
175
|
+
* @returns Promise resolving when deleted
|
|
176
|
+
*/
|
|
177
|
+
export declare const deleteAgentSpace: (token: string, uid: string, baseUrl?: string) => Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Make an agent space public (add to Library).
|
|
180
|
+
* @param token - Authentication token
|
|
181
|
+
* @param uid - The agent space UID
|
|
182
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
183
|
+
* @returns Promise resolving to the updated agent space
|
|
184
|
+
*/
|
|
185
|
+
export declare const makeAgentSpacePublic: (token: string, uid: string, baseUrl?: string) => Promise<AgentSpaceResponse>;
|
|
186
|
+
/**
|
|
187
|
+
* Make an agent space private (remove from Library).
|
|
188
|
+
* @param token - Authentication token
|
|
189
|
+
* @param uid - The agent space UID
|
|
190
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
191
|
+
* @returns Promise resolving to the updated agent space
|
|
192
|
+
*/
|
|
193
|
+
export declare const makeAgentSpacePrivate: (token: string, uid: string, baseUrl?: string) => Promise<AgentSpaceResponse>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Agent Spaces API functions for the Datalayer platform.
|
|
7
|
+
*
|
|
8
|
+
* Provides functions for creating, listing, updating, and deleting agent spaces.
|
|
9
|
+
*
|
|
10
|
+
* @module api/spacer/agent-spaces
|
|
11
|
+
*/
|
|
12
|
+
import { requestDatalayerAPI } from '../DatalayerApi';
|
|
13
|
+
import { API_BASE_PATHS, DEFAULT_SERVICE_URLS } from '../constants';
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// API Functions
|
|
16
|
+
// =============================================================================
|
|
17
|
+
/**
|
|
18
|
+
* Create a new agent space.
|
|
19
|
+
* @param token - Authentication token
|
|
20
|
+
* @param data - Agent space creation configuration
|
|
21
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
22
|
+
* @returns Promise resolving to the created agent space response
|
|
23
|
+
*/
|
|
24
|
+
export const createAgentSpace = async (token, data, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
25
|
+
return requestDatalayerAPI({
|
|
26
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/agent-spaces`,
|
|
27
|
+
method: 'POST',
|
|
28
|
+
token,
|
|
29
|
+
body: data,
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* List agent spaces for the current user.
|
|
34
|
+
* @param token - Authentication token
|
|
35
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
36
|
+
* @returns Promise resolving to the list of agent spaces
|
|
37
|
+
*/
|
|
38
|
+
export const listAgentSpaces = async (token, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
39
|
+
return requestDatalayerAPI({
|
|
40
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/agent-spaces`,
|
|
41
|
+
method: 'GET',
|
|
42
|
+
token,
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* List all public agent spaces (Library).
|
|
47
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
48
|
+
* @returns Promise resolving to the list of public agent spaces
|
|
49
|
+
*/
|
|
50
|
+
export const listPublicAgentSpaces = async (baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
51
|
+
return requestDatalayerAPI({
|
|
52
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/agent-spaces/public`,
|
|
53
|
+
method: 'GET',
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Get an agent space by UID.
|
|
58
|
+
* @param token - Authentication token
|
|
59
|
+
* @param uid - The agent space UID
|
|
60
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
61
|
+
* @returns Promise resolving to the agent space
|
|
62
|
+
*/
|
|
63
|
+
export const getAgentSpace = async (token, uid, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
64
|
+
return requestDatalayerAPI({
|
|
65
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/agent-spaces/${uid}`,
|
|
66
|
+
method: 'GET',
|
|
67
|
+
token,
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Update an agent space.
|
|
72
|
+
* @param token - Authentication token
|
|
73
|
+
* @param uid - The agent space UID
|
|
74
|
+
* @param data - Update data
|
|
75
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
76
|
+
* @returns Promise resolving to the updated agent space
|
|
77
|
+
*/
|
|
78
|
+
export const updateAgentSpace = async (token, uid, data, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
79
|
+
return requestDatalayerAPI({
|
|
80
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/agent-spaces/${uid}`,
|
|
81
|
+
method: 'PUT',
|
|
82
|
+
token,
|
|
83
|
+
body: data,
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Delete an agent space.
|
|
88
|
+
* @param token - Authentication token
|
|
89
|
+
* @param uid - The agent space UID
|
|
90
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
91
|
+
* @returns Promise resolving when deleted
|
|
92
|
+
*/
|
|
93
|
+
export const deleteAgentSpace = async (token, uid, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
94
|
+
await requestDatalayerAPI({
|
|
95
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/agent-spaces/${uid}`,
|
|
96
|
+
method: 'DELETE',
|
|
97
|
+
token,
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Make an agent space public (add to Library).
|
|
102
|
+
* @param token - Authentication token
|
|
103
|
+
* @param uid - The agent space UID
|
|
104
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
105
|
+
* @returns Promise resolving to the updated agent space
|
|
106
|
+
*/
|
|
107
|
+
export const makeAgentSpacePublic = async (token, uid, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
108
|
+
return requestDatalayerAPI({
|
|
109
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/agent-spaces/${uid}/public`,
|
|
110
|
+
method: 'POST',
|
|
111
|
+
token,
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Make an agent space private (remove from Library).
|
|
116
|
+
* @param token - Authentication token
|
|
117
|
+
* @param uid - The agent space UID
|
|
118
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
119
|
+
* @returns Promise resolving to the updated agent space
|
|
120
|
+
*/
|
|
121
|
+
export const makeAgentSpacePrivate = async (token, uid, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
122
|
+
return requestDatalayerAPI({
|
|
123
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/agent-spaces/${uid}/private`,
|
|
124
|
+
method: 'POST',
|
|
125
|
+
token,
|
|
126
|
+
});
|
|
127
|
+
};
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* Spacer API exports.
|
|
3
3
|
*
|
|
4
4
|
* Provides organized access to spacer functionality including
|
|
5
|
-
* spaces, notebooks, cells, and
|
|
5
|
+
* spaces, notebooks, cells, lexical documents, and agent spaces.
|
|
6
6
|
*
|
|
7
7
|
* @module api/spacer
|
|
8
8
|
*/
|
|
9
|
+
export * as agentSpaces from './agentSpaces';
|
|
9
10
|
export * as documents from './documents';
|
|
10
11
|
export * as healthz from './healthz';
|
|
11
12
|
export * as items from './items';
|
package/lib/api/spacer/index.js
CHANGED
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
* Spacer API exports.
|
|
7
7
|
*
|
|
8
8
|
* Provides organized access to spacer functionality including
|
|
9
|
-
* spaces, notebooks, cells, and
|
|
9
|
+
* spaces, notebooks, cells, lexical documents, and agent spaces.
|
|
10
10
|
*
|
|
11
11
|
* @module api/spacer
|
|
12
12
|
*/
|
|
13
|
+
export * as agentSpaces from './agentSpaces';
|
|
13
14
|
export * as documents from './documents';
|
|
14
15
|
export * as healthz from './healthz';
|
|
15
16
|
export * as items from './items';
|
|
@@ -26,7 +26,7 @@ export declare const validateRequiredString: (value: string | undefined | null,
|
|
|
26
26
|
/**
|
|
27
27
|
* Validates that all properties in an object are defined (not undefined).
|
|
28
28
|
* Recursively checks nested objects and arrays to ensure complete data integrity.
|
|
29
|
-
* This is used to validate model toJSON() outputs and ensure
|
|
29
|
+
* This is used to validate model toJSON() outputs and ensure Client contract compliance.
|
|
30
30
|
*
|
|
31
31
|
* @param obj - The object to validate
|
|
32
32
|
* @param modelName - Name of the model class for error messages (e.g., 'Runtime')
|
|
@@ -135,7 +135,7 @@ export const validateRequiredString = (value, paramName) => {
|
|
|
135
135
|
/**
|
|
136
136
|
* Validates that all properties in an object are defined (not undefined).
|
|
137
137
|
* Recursively checks nested objects and arrays to ensure complete data integrity.
|
|
138
|
-
* This is used to validate model toJSON() outputs and ensure
|
|
138
|
+
* This is used to validate model toJSON() outputs and ensure Client contract compliance.
|
|
139
139
|
*
|
|
140
140
|
* @param obj - The object to validate
|
|
141
141
|
* @param modelName - Name of the model class for error messages (e.g., 'Runtime')
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Core authentication manager for the Datalayer
|
|
2
|
+
* Core authentication manager for the Datalayer Client
|
|
3
3
|
*/
|
|
4
4
|
import type { AuthOptions, AuthResult, TokenStorage, TokenValidationResult } from './types';
|
|
5
5
|
import { UserDTO } from '../../models/UserDTO';
|
|
6
6
|
/**
|
|
7
|
-
* Authentication Manager for Datalayer
|
|
7
|
+
* Authentication Manager for Datalayer Client
|
|
8
8
|
* Provides a unified interface for all authentication methods
|
|
9
9
|
*/
|
|
10
10
|
export declare class AuthenticationManager {
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Core authentication manager for the Datalayer
|
|
6
|
+
* Core authentication manager for the Datalayer Client
|
|
7
7
|
*/
|
|
8
8
|
import * as authentication from '../../api/iam/authentication';
|
|
9
9
|
import { TokenAuthStrategy, CredentialsAuthStrategy, StorageAuthStrategy, BrowserOAuthStrategy, } from './strategies';
|
|
10
10
|
import { NodeStorage, BrowserStorage } from './storage';
|
|
11
11
|
/**
|
|
12
|
-
* Authentication Manager for Datalayer
|
|
12
|
+
* Authentication Manager for Datalayer Client
|
|
13
13
|
* Provides a unified interface for all authentication methods
|
|
14
14
|
*/
|
|
15
15
|
export class AuthenticationManager {
|
package/lib/client/auth/index.js
CHANGED
package/lib/client/auth/types.js
CHANGED
package/lib/client/base.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { EnvironmentDTO } from '../models/EnvironmentDTO';
|
|
2
2
|
import { AuthenticationManager } from './auth';
|
|
3
3
|
import type { TokenStorage } from './auth/types';
|
|
4
|
-
/** Handlers for
|
|
5
|
-
export interface
|
|
6
|
-
/** Called before any
|
|
4
|
+
/** Handlers for Client method lifecycle events. */
|
|
5
|
+
export interface ClientHandlers {
|
|
6
|
+
/** Called before any Client method execution */
|
|
7
7
|
beforeCall?: (methodName: string, args: any[]) => void | Promise<void>;
|
|
8
|
-
/** Called after successful
|
|
8
|
+
/** Called after successful Client method execution */
|
|
9
9
|
afterCall?: (methodName: string, result: any) => void | Promise<void>;
|
|
10
|
-
/** Called when an
|
|
10
|
+
/** Called when an Client method throws an error */
|
|
11
11
|
onError?: (methodName: string, error: any) => void | Promise<void>;
|
|
12
12
|
}
|
|
13
13
|
/** Configuration options for the Datalayer Client. */
|
|
@@ -22,8 +22,8 @@ export interface DatalayerClientConfig {
|
|
|
22
22
|
spacerRunUrl?: string;
|
|
23
23
|
/** Custom token storage backend (optional, defaults to auto-detected) */
|
|
24
24
|
storage?: TokenStorage;
|
|
25
|
-
/** Handlers for intercepting
|
|
26
|
-
handlers?:
|
|
25
|
+
/** Handlers for intercepting Client method calls */
|
|
26
|
+
handlers?: ClientHandlers;
|
|
27
27
|
}
|
|
28
28
|
/** Base Client class providing core configuration and token management. */
|
|
29
29
|
export declare class DatalayerClientBase {
|
|
@@ -38,7 +38,7 @@ export declare class DatalayerClientBase {
|
|
|
38
38
|
/** Environments */
|
|
39
39
|
readonly environments: EnvironmentDTO[];
|
|
40
40
|
/** Method lifecycle handlers */
|
|
41
|
-
readonly handlers?:
|
|
41
|
+
readonly handlers?: ClientHandlers;
|
|
42
42
|
/** Authentication manager */
|
|
43
43
|
readonly auth: AuthenticationManager;
|
|
44
44
|
/**
|
|
@@ -65,7 +65,7 @@ export declare class DatalayerClientBase {
|
|
|
65
65
|
*/
|
|
66
66
|
setToken(token: string): Promise<void>;
|
|
67
67
|
/**
|
|
68
|
-
* Wrap all
|
|
68
|
+
* Wrap all Client methods with handlers for cross-cutting concerns.
|
|
69
69
|
* Called automatically by the DatalayerClient constructor.
|
|
70
70
|
*
|
|
71
71
|
* @internal
|
package/lib/client/base.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Base
|
|
6
|
+
* Base Client class providing core configuration and token management.
|
|
7
7
|
* @module client/base
|
|
8
8
|
*/
|
|
9
9
|
import { DEFAULT_SERVICE_URLS } from '../api/constants';
|
|
@@ -78,7 +78,7 @@ export class DatalayerClientBase {
|
|
|
78
78
|
this.token = token;
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
|
-
* Wrap all
|
|
81
|
+
* Wrap all Client methods with handlers for cross-cutting concerns.
|
|
82
82
|
* Called automatically by the DatalayerClient constructor.
|
|
83
83
|
*
|
|
84
84
|
* @internal
|
|
@@ -172,7 +172,7 @@ export class DatalayerClientBase {
|
|
|
172
172
|
Object.getOwnPropertyNames(basePrototype).forEach(name => {
|
|
173
173
|
baseClassMethods.add(name);
|
|
174
174
|
});
|
|
175
|
-
// Also exclude methods from the concrete
|
|
175
|
+
// Also exclude methods from the concrete Client class itself
|
|
176
176
|
const sdkPrototype = Object.getPrototypeOf(this).constructor.prototype;
|
|
177
177
|
Object.getOwnPropertyNames(sdkPrototype).forEach(name => {
|
|
178
178
|
baseClassMethods.add(name);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Constants for the Datalayer
|
|
2
|
+
* Constants for the Datalayer Client.
|
|
3
3
|
*
|
|
4
4
|
* @module client/constants
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
|
-
* Item types used throughout the
|
|
7
|
+
* Item types used throughout the Client and consuming applications.
|
|
8
8
|
* These constants define the type identifiers for different Datalayer items.
|
|
9
9
|
* Values match what the Datalayer API returns.
|
|
10
10
|
*/
|
package/lib/client/constants.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Constants for the Datalayer
|
|
6
|
+
* Constants for the Datalayer Client.
|
|
7
7
|
*
|
|
8
8
|
* @module client/constants
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
|
-
* Item types used throughout the
|
|
11
|
+
* Item types used throughout the Client and consuming applications.
|
|
12
12
|
* These constants define the type identifiers for different Datalayer items.
|
|
13
13
|
* Values match what the Datalayer API returns.
|
|
14
14
|
*/
|
package/lib/client/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* const runtime = await client.createRuntime(config);
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
import { DatalayerClientBase, type DatalayerClientConfig, type
|
|
17
|
+
import { DatalayerClientBase, type DatalayerClientConfig, type ClientHandlers } from './base';
|
|
18
18
|
import type { UserDTO } from './../models/UserDTO';
|
|
19
19
|
import type { CreditsDTO } from '../models/CreditsDTO';
|
|
20
20
|
import type { EnvironmentDTO } from '../models/EnvironmentDTO';
|
|
@@ -54,7 +54,7 @@ export declare class DatalayerClient extends DatalayerClientWithMixins {
|
|
|
54
54
|
*/
|
|
55
55
|
constructor(config: DatalayerClientConfig);
|
|
56
56
|
}
|
|
57
|
-
export type { DatalayerClientConfig,
|
|
57
|
+
export type { DatalayerClientConfig, ClientHandlers };
|
|
58
58
|
export { DatalayerClientBase };
|
|
59
59
|
export { UserDTO as User } from './../models/UserDTO';
|
|
60
60
|
export type { UserJSON, UserData } from './../models/UserDTO';
|
|
@@ -85,7 +85,7 @@ export function IAMMixin(Base) {
|
|
|
85
85
|
const token = this.getToken();
|
|
86
86
|
const iamRunUrl = this.getIamRunUrl();
|
|
87
87
|
await authentication.logout(token, iamRunUrl);
|
|
88
|
-
// Clear the token from the
|
|
88
|
+
// Clear the token from the Client and cached user
|
|
89
89
|
this.setToken('');
|
|
90
90
|
this.currentUserCache = undefined;
|
|
91
91
|
}
|