@datalayer/core 1.0.14 → 1.0.15
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/api/DatalayerApi.js +5 -0
- package/lib/api/constants.d.ts +1 -1
- package/lib/api/constants.js +1 -1
- package/lib/api/spacer/lexicals.d.ts +8 -0
- package/lib/api/spacer/lexicals.js +14 -0
- package/lib/api/spacer/notebooks.d.ts +8 -0
- package/lib/api/spacer/notebooks.js +14 -0
- package/lib/api/spacer/spaces.d.ts +76 -1
- package/lib/api/spacer/spaces.js +140 -0
- package/lib/client/auth/storage.d.ts +3 -1
- package/lib/client/auth/storage.js +34 -13
- package/lib/client/index.d.ts +22 -2
- package/lib/client/index.js +2 -1
- package/lib/client/mixins/SpacerMixin.d.ts +99 -0
- package/lib/client/mixins/SpacerMixin.js +254 -0
- package/lib/client/utils/slugify.d.ts +8 -0
- package/lib/client/utils/slugify.js +18 -0
- package/lib/components/sparklines/dataProcessing.d.ts +2 -4
- package/lib/components/sparklines/dataProcessing.js +0 -4
- package/lib/components/sparklines/index.d.ts +1 -0
- package/lib/config/Configuration.d.ts +1 -1
- package/lib/config/Configuration.js +1 -1
- package/lib/hooks/useCache.js +1 -1
- package/lib/hooks/useProjects.d.ts +2 -8
- package/lib/hooks/useProjects.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/models/EnvironmentDTO.d.ts +1 -1
- package/lib/models/EnvironmentDTO.js +1 -1
- package/lib/models/ProjectDTO.d.ts +89 -0
- package/lib/models/ProjectDTO.js +131 -0
- package/lib/models/Space.d.ts +1 -1
- package/lib/models/SpaceDTO.d.ts +61 -0
- package/lib/otel/types.d.ts +1 -1
- package/lib/otel/views/OtelMetricsList.d.ts +2 -5
- package/lib/otel/views/index.d.ts +1 -0
- package/lib/services/DatalayerServiceManager.d.ts +1 -1
- package/lib/services/DatalayerServiceManager.js +1 -1
- package/lib/state/storage/IAMStorage.js +29 -4
- package/lib/state/substates/CoreState.js +1 -1
- package/lib/views/otel/simpleAuthStore.js +1 -1
- package/package.json +1 -1
package/lib/api/DatalayerApi.js
CHANGED
|
@@ -121,6 +121,11 @@ export async function requestDatalayerAPI({ url, method, body, token, signal, he
|
|
|
121
121
|
// CORS mode is handled automatically by axios
|
|
122
122
|
// Cache control headers
|
|
123
123
|
};
|
|
124
|
+
// In Vitest+jsdom, axios may pick the XHR adapter and fail with browser-like
|
|
125
|
+
// network restrictions. Force the fetch adapter for integration reliability.
|
|
126
|
+
if (typeof process !== 'undefined' && process.env.VITEST) {
|
|
127
|
+
axiosConfig.adapter = 'fetch';
|
|
128
|
+
}
|
|
124
129
|
// Add cache control headers only for GET requests (equivalent to cache: 'no-store')
|
|
125
130
|
if (method === 'GET' || !method) {
|
|
126
131
|
if (!axiosConfig.headers['Cache-Control']) {
|
package/lib/api/constants.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare const DEFAULT_SERVICE_URLS: {
|
|
|
19
19
|
/** Default URL for OTEL (OpenTelemetry observability) service */
|
|
20
20
|
readonly OTEL: "https://prod1.datalayer.run";
|
|
21
21
|
/** Default URL for Runtimes service */
|
|
22
|
-
readonly RUNTIMES: "https://
|
|
22
|
+
readonly RUNTIMES: "https://r1.datalayer.run";
|
|
23
23
|
/** Default URL for Spacer (workspaces and collaboration) service */
|
|
24
24
|
readonly SPACER: "https://prod1.datalayer.run";
|
|
25
25
|
};
|
package/lib/api/constants.js
CHANGED
|
@@ -23,7 +23,7 @@ export const DEFAULT_SERVICE_URLS = {
|
|
|
23
23
|
/** Default URL for OTEL (OpenTelemetry observability) service */
|
|
24
24
|
OTEL: 'https://prod1.datalayer.run',
|
|
25
25
|
/** Default URL for Runtimes service */
|
|
26
|
-
RUNTIMES: 'https://
|
|
26
|
+
RUNTIMES: 'https://r1.datalayer.run',
|
|
27
27
|
/** Default URL for Spacer (workspaces and collaboration) service */
|
|
28
28
|
SPACER: 'https://prod1.datalayer.run',
|
|
29
29
|
};
|
|
@@ -24,3 +24,11 @@ export declare const getLexical: (token: string, id: string, baseUrl?: string) =
|
|
|
24
24
|
* @returns Promise resolving to the updated document response
|
|
25
25
|
*/
|
|
26
26
|
export declare const updateLexical: (token: string, id: string, data: UpdateLexicalRequest, baseUrl?: string) => Promise<UpdateLexicalResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* Clone a lexical document.
|
|
29
|
+
* @param token - Authentication token
|
|
30
|
+
* @param id - The document ID to clone
|
|
31
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
32
|
+
* @returns Promise resolving to the cloned document response
|
|
33
|
+
*/
|
|
34
|
+
export declare const cloneLexical: (token: string, id: string, baseUrl?: string) => Promise<CreateLexicalResponse>;
|
|
@@ -73,3 +73,17 @@ export const updateLexical = async (token, id, data, baseUrl = DEFAULT_SERVICE_U
|
|
|
73
73
|
body: data,
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* Clone a lexical document.
|
|
78
|
+
* @param token - Authentication token
|
|
79
|
+
* @param id - The document ID to clone
|
|
80
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
81
|
+
* @returns Promise resolving to the cloned document response
|
|
82
|
+
*/
|
|
83
|
+
export const cloneLexical = async (token, id, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
84
|
+
return requestDatalayerAPI({
|
|
85
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/lexicals/${id}/clone`,
|
|
86
|
+
method: 'POST',
|
|
87
|
+
token,
|
|
88
|
+
});
|
|
89
|
+
};
|
|
@@ -24,3 +24,11 @@ export declare const getNotebook: (token: string, id: string, baseUrl?: string)
|
|
|
24
24
|
* @returns Promise resolving to the updated notebook response
|
|
25
25
|
*/
|
|
26
26
|
export declare const updateNotebook: (token: string, id: string, data: UpdateNotebookRequest, baseUrl?: string) => Promise<UpdateNotebookResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* Clone a notebook.
|
|
29
|
+
* @param token - Authentication token
|
|
30
|
+
* @param id - The notebook ID to clone
|
|
31
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
32
|
+
* @returns Promise resolving to the cloned notebook response
|
|
33
|
+
*/
|
|
34
|
+
export declare const cloneNotebook: (token: string, id: string, baseUrl?: string) => Promise<CreateNotebookResponse>;
|
|
@@ -73,3 +73,17 @@ export const updateNotebook = async (token, id, data, baseUrl = DEFAULT_SERVICE_
|
|
|
73
73
|
body: data,
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* Clone a notebook.
|
|
78
|
+
* @param token - Authentication token
|
|
79
|
+
* @param id - The notebook ID to clone
|
|
80
|
+
* @param baseUrl - Base URL for the API (defaults to production)
|
|
81
|
+
* @returns Promise resolving to the cloned notebook response
|
|
82
|
+
*/
|
|
83
|
+
export const cloneNotebook = async (token, id, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
84
|
+
return requestDatalayerAPI({
|
|
85
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/notebooks/${id}/clone`,
|
|
86
|
+
method: 'POST',
|
|
87
|
+
token,
|
|
88
|
+
});
|
|
89
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateSpaceRequest, CreateSpaceResponse } from '../../models/SpaceDTO';
|
|
1
|
+
import { CreateSpaceRequest, CreateSpaceResponse, GetSpaceResponse, UpdateSpaceRequest, UpdateSpaceResponse, DeleteSpaceResponse, GetSpaceDefaultItemsResponse, GetSpacesByTypeResponse } from '../../models/SpaceDTO';
|
|
2
2
|
/**
|
|
3
3
|
* Create a new workspace space.
|
|
4
4
|
* @param token - Authentication token
|
|
@@ -7,3 +7,78 @@ import { CreateSpaceRequest, CreateSpaceResponse } from '../../models/SpaceDTO';
|
|
|
7
7
|
* @returns Promise resolving to the created space response
|
|
8
8
|
*/
|
|
9
9
|
export declare const createSpace: (token: string, data: CreateSpaceRequest, baseUrl?: string) => Promise<CreateSpaceResponse>;
|
|
10
|
+
/**
|
|
11
|
+
* Get a space by UID.
|
|
12
|
+
* @param token - Authentication token
|
|
13
|
+
* @param uid - Space UID
|
|
14
|
+
* @param baseUrl - Base URL for the API
|
|
15
|
+
* @returns Promise resolving to the space response
|
|
16
|
+
*/
|
|
17
|
+
export declare const getSpace: (token: string, uid: string, baseUrl?: string) => Promise<GetSpaceResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Update a space (owner updating their own space).
|
|
20
|
+
* @param token - Authentication token
|
|
21
|
+
* @param uid - Space UID
|
|
22
|
+
* @param data - Update data (supports arbitrary Solr fields)
|
|
23
|
+
* @param baseUrl - Base URL for the API
|
|
24
|
+
* @returns Promise resolving to the updated space response
|
|
25
|
+
*/
|
|
26
|
+
export declare const updateSpace: (token: string, uid: string, data: UpdateSpaceRequest, baseUrl?: string) => Promise<UpdateSpaceResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* Update a user-specific space (e.g., org admin managing another user's space).
|
|
29
|
+
* @param token - Authentication token
|
|
30
|
+
* @param uid - Space UID
|
|
31
|
+
* @param userId - User ID
|
|
32
|
+
* @param data - Update data (supports arbitrary Solr fields)
|
|
33
|
+
* @param baseUrl - Base URL for the API
|
|
34
|
+
* @returns Promise resolving to the updated space response
|
|
35
|
+
*/
|
|
36
|
+
export declare const updateUserSpace: (token: string, uid: string, userId: string, data: UpdateSpaceRequest, baseUrl?: string) => Promise<UpdateSpaceResponse>;
|
|
37
|
+
/**
|
|
38
|
+
* Delete a space and all its contents.
|
|
39
|
+
* @param token - Authentication token
|
|
40
|
+
* @param uid - Space UID
|
|
41
|
+
* @param baseUrl - Base URL for the API
|
|
42
|
+
* @returns Promise resolving to the delete response
|
|
43
|
+
*/
|
|
44
|
+
export declare const deleteSpace: (token: string, uid: string, baseUrl?: string) => Promise<DeleteSpaceResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* Get default items (notebook UID and document UID) for a space.
|
|
47
|
+
* @param token - Authentication token
|
|
48
|
+
* @param uid - Space UID
|
|
49
|
+
* @param baseUrl - Base URL for the API
|
|
50
|
+
* @returns Promise resolving to the default items response
|
|
51
|
+
*/
|
|
52
|
+
export declare const getSpaceDefaultItems: (token: string, uid: string, baseUrl?: string) => Promise<GetSpaceDefaultItemsResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* Get spaces by type (e.g., 'project', 'workspace', 'course').
|
|
55
|
+
* @param token - Authentication token
|
|
56
|
+
* @param type - Space type to filter by
|
|
57
|
+
* @param baseUrl - Base URL for the API
|
|
58
|
+
* @returns Promise resolving to the spaces response
|
|
59
|
+
*/
|
|
60
|
+
export declare const getSpacesByType: (token: string, type: string, baseUrl?: string) => Promise<GetSpacesByTypeResponse>;
|
|
61
|
+
/**
|
|
62
|
+
* Make a space public.
|
|
63
|
+
* @param token - Authentication token
|
|
64
|
+
* @param uid - Space UID
|
|
65
|
+
* @param baseUrl - Base URL for the API
|
|
66
|
+
* @returns Promise resolving to the updated space response
|
|
67
|
+
*/
|
|
68
|
+
export declare const makeSpacePublic: (token: string, uid: string, baseUrl?: string) => Promise<UpdateSpaceResponse>;
|
|
69
|
+
/**
|
|
70
|
+
* Make a space private.
|
|
71
|
+
* @param token - Authentication token
|
|
72
|
+
* @param uid - Space UID
|
|
73
|
+
* @param baseUrl - Base URL for the API
|
|
74
|
+
* @returns Promise resolving to the updated space response
|
|
75
|
+
*/
|
|
76
|
+
export declare const makeSpacePrivate: (token: string, uid: string, baseUrl?: string) => Promise<UpdateSpaceResponse>;
|
|
77
|
+
/**
|
|
78
|
+
* Export a space and its contents.
|
|
79
|
+
* @param token - Authentication token
|
|
80
|
+
* @param uid - Space UID
|
|
81
|
+
* @param baseUrl - Base URL for the API
|
|
82
|
+
* @returns Promise resolving to the export data
|
|
83
|
+
*/
|
|
84
|
+
export declare const exportSpace: (token: string, uid: string, baseUrl?: string) => Promise<any>;
|
package/lib/api/spacer/spaces.js
CHANGED
|
@@ -28,3 +28,143 @@ export const createSpace = async (token, data, baseUrl = DEFAULT_SERVICE_URLS.SP
|
|
|
28
28
|
body: data,
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Get a space by UID.
|
|
33
|
+
* @param token - Authentication token
|
|
34
|
+
* @param uid - Space UID
|
|
35
|
+
* @param baseUrl - Base URL for the API
|
|
36
|
+
* @returns Promise resolving to the space response
|
|
37
|
+
*/
|
|
38
|
+
export const getSpace = async (token, uid, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
39
|
+
validateToken(token);
|
|
40
|
+
return requestDatalayerAPI({
|
|
41
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/spaces/${uid}`,
|
|
42
|
+
method: 'GET',
|
|
43
|
+
token,
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Update a space (owner updating their own space).
|
|
48
|
+
* @param token - Authentication token
|
|
49
|
+
* @param uid - Space UID
|
|
50
|
+
* @param data - Update data (supports arbitrary Solr fields)
|
|
51
|
+
* @param baseUrl - Base URL for the API
|
|
52
|
+
* @returns Promise resolving to the updated space response
|
|
53
|
+
*/
|
|
54
|
+
export const updateSpace = async (token, uid, data, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
55
|
+
validateToken(token);
|
|
56
|
+
return requestDatalayerAPI({
|
|
57
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/spaces/${uid}`,
|
|
58
|
+
method: 'PUT',
|
|
59
|
+
token,
|
|
60
|
+
body: data,
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Update a user-specific space (e.g., org admin managing another user's space).
|
|
65
|
+
* @param token - Authentication token
|
|
66
|
+
* @param uid - Space UID
|
|
67
|
+
* @param userId - User ID
|
|
68
|
+
* @param data - Update data (supports arbitrary Solr fields)
|
|
69
|
+
* @param baseUrl - Base URL for the API
|
|
70
|
+
* @returns Promise resolving to the updated space response
|
|
71
|
+
*/
|
|
72
|
+
export const updateUserSpace = async (token, uid, userId, data, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
73
|
+
validateToken(token);
|
|
74
|
+
return requestDatalayerAPI({
|
|
75
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/spaces/${uid}/users/${userId}`,
|
|
76
|
+
method: 'PUT',
|
|
77
|
+
token,
|
|
78
|
+
body: data,
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Delete a space and all its contents.
|
|
83
|
+
* @param token - Authentication token
|
|
84
|
+
* @param uid - Space UID
|
|
85
|
+
* @param baseUrl - Base URL for the API
|
|
86
|
+
* @returns Promise resolving to the delete response
|
|
87
|
+
*/
|
|
88
|
+
export const deleteSpace = async (token, uid, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
89
|
+
validateToken(token);
|
|
90
|
+
return requestDatalayerAPI({
|
|
91
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/spaces/${uid}`,
|
|
92
|
+
method: 'DELETE',
|
|
93
|
+
token,
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Get default items (notebook UID and document UID) for a space.
|
|
98
|
+
* @param token - Authentication token
|
|
99
|
+
* @param uid - Space UID
|
|
100
|
+
* @param baseUrl - Base URL for the API
|
|
101
|
+
* @returns Promise resolving to the default items response
|
|
102
|
+
*/
|
|
103
|
+
export const getSpaceDefaultItems = async (token, uid, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
104
|
+
validateToken(token);
|
|
105
|
+
return requestDatalayerAPI({
|
|
106
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/spaces/${uid}/default-items`,
|
|
107
|
+
method: 'GET',
|
|
108
|
+
token,
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Get spaces by type (e.g., 'project', 'workspace', 'course').
|
|
113
|
+
* @param token - Authentication token
|
|
114
|
+
* @param type - Space type to filter by
|
|
115
|
+
* @param baseUrl - Base URL for the API
|
|
116
|
+
* @returns Promise resolving to the spaces response
|
|
117
|
+
*/
|
|
118
|
+
export const getSpacesByType = async (token, type, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
119
|
+
validateToken(token);
|
|
120
|
+
return requestDatalayerAPI({
|
|
121
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/spaces/types/${type}`,
|
|
122
|
+
method: 'GET',
|
|
123
|
+
token,
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Make a space public.
|
|
128
|
+
* @param token - Authentication token
|
|
129
|
+
* @param uid - Space UID
|
|
130
|
+
* @param baseUrl - Base URL for the API
|
|
131
|
+
* @returns Promise resolving to the updated space response
|
|
132
|
+
*/
|
|
133
|
+
export const makeSpacePublic = async (token, uid, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
134
|
+
validateToken(token);
|
|
135
|
+
return requestDatalayerAPI({
|
|
136
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/spaces/${uid}/public`,
|
|
137
|
+
method: 'PUT',
|
|
138
|
+
token,
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Make a space private.
|
|
143
|
+
* @param token - Authentication token
|
|
144
|
+
* @param uid - Space UID
|
|
145
|
+
* @param baseUrl - Base URL for the API
|
|
146
|
+
* @returns Promise resolving to the updated space response
|
|
147
|
+
*/
|
|
148
|
+
export const makeSpacePrivate = async (token, uid, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
149
|
+
validateToken(token);
|
|
150
|
+
return requestDatalayerAPI({
|
|
151
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/spaces/${uid}/private`,
|
|
152
|
+
method: 'PUT',
|
|
153
|
+
token,
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Export a space and its contents.
|
|
158
|
+
* @param token - Authentication token
|
|
159
|
+
* @param uid - Space UID
|
|
160
|
+
* @param baseUrl - Base URL for the API
|
|
161
|
+
* @returns Promise resolving to the export data
|
|
162
|
+
*/
|
|
163
|
+
export const exportSpace = async (token, uid, baseUrl = DEFAULT_SERVICE_URLS.SPACER) => {
|
|
164
|
+
validateToken(token);
|
|
165
|
+
return requestDatalayerAPI({
|
|
166
|
+
url: `${baseUrl}${API_BASE_PATHS.SPACER}/spaces/${uid}/export`,
|
|
167
|
+
method: 'GET',
|
|
168
|
+
token,
|
|
169
|
+
});
|
|
170
|
+
};
|
|
@@ -4,6 +4,7 @@ import { UserDTO } from '../../models/UserDTO';
|
|
|
4
4
|
* Browser localStorage-based token storage
|
|
5
5
|
*/
|
|
6
6
|
export declare class BrowserStorage implements TokenStorage {
|
|
7
|
+
private _available;
|
|
7
8
|
/**
|
|
8
9
|
* Get token from browser localStorage
|
|
9
10
|
*/
|
|
@@ -17,7 +18,8 @@ export declare class BrowserStorage implements TokenStorage {
|
|
|
17
18
|
*/
|
|
18
19
|
delete(key: string): void;
|
|
19
20
|
/**
|
|
20
|
-
* Check if browser localStorage is available
|
|
21
|
+
* Check if browser localStorage is available and functional.
|
|
22
|
+
* Result is cached after the first probe to avoid repeated writes.
|
|
21
23
|
*/
|
|
22
24
|
isAvailable(): boolean;
|
|
23
25
|
/**
|
|
@@ -15,11 +15,12 @@ import { DATALAYER_IAM_TOKEN_KEY, DATALAYER_IAM_USER_KEY, } from '../../state/st
|
|
|
15
15
|
* Browser localStorage-based token storage
|
|
16
16
|
*/
|
|
17
17
|
export class BrowserStorage {
|
|
18
|
+
_available;
|
|
18
19
|
/**
|
|
19
20
|
* Get token from browser localStorage
|
|
20
21
|
*/
|
|
21
22
|
get(key) {
|
|
22
|
-
if (
|
|
23
|
+
if (!this.isAvailable()) {
|
|
23
24
|
return null;
|
|
24
25
|
}
|
|
25
26
|
return window.localStorage.getItem(key);
|
|
@@ -28,7 +29,7 @@ export class BrowserStorage {
|
|
|
28
29
|
* Set token in browser localStorage
|
|
29
30
|
*/
|
|
30
31
|
set(key, value) {
|
|
31
|
-
if (
|
|
32
|
+
if (!this.isAvailable()) {
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
34
35
|
window.localStorage.setItem(key, value);
|
|
@@ -37,16 +38,34 @@ export class BrowserStorage {
|
|
|
37
38
|
* Delete token from browser localStorage
|
|
38
39
|
*/
|
|
39
40
|
delete(key) {
|
|
40
|
-
if (
|
|
41
|
+
if (!this.isAvailable()) {
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
43
44
|
window.localStorage.removeItem(key);
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
46
|
-
* Check if browser localStorage is available
|
|
47
|
+
* Check if browser localStorage is available and functional.
|
|
48
|
+
* Result is cached after the first probe to avoid repeated writes.
|
|
47
49
|
*/
|
|
48
50
|
isAvailable() {
|
|
49
|
-
|
|
51
|
+
if (this._available !== undefined) {
|
|
52
|
+
return this._available;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
if (typeof window === 'undefined' || !window.localStorage) {
|
|
56
|
+
this._available = false;
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
const testKey = '__datalayer_storage_test__';
|
|
60
|
+
window.localStorage.setItem(testKey, 'test');
|
|
61
|
+
window.localStorage.removeItem(testKey);
|
|
62
|
+
this._available = true;
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
this._available = false;
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
50
69
|
}
|
|
51
70
|
/**
|
|
52
71
|
* Get stored authentication token
|
|
@@ -395,16 +414,18 @@ export class ElectronStorage {
|
|
|
395
414
|
*/
|
|
396
415
|
export function getDefaultStorage() {
|
|
397
416
|
if (typeof window !== 'undefined') {
|
|
398
|
-
|
|
399
|
-
|
|
417
|
+
const browserStorage = new BrowserStorage();
|
|
418
|
+
if (browserStorage.isAvailable()) {
|
|
419
|
+
return browserStorage;
|
|
420
|
+
}
|
|
421
|
+
// window exists but localStorage is not functional (e.g., Node 22 with --localstorage-file)
|
|
422
|
+
// Fall through to Node.js storage
|
|
400
423
|
}
|
|
401
|
-
|
|
424
|
+
if (typeof process !== 'undefined') {
|
|
402
425
|
// Node.js environment
|
|
403
426
|
return new NodeStorage();
|
|
404
427
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
return new NodeStorage(); // NodeStorage has in-memory fallback
|
|
409
|
-
}
|
|
428
|
+
// Unknown environment, use in-memory storage
|
|
429
|
+
console.warn('Unknown environment, using in-memory storage (data will not persist)');
|
|
430
|
+
return new NodeStorage(); // NodeStorage has in-memory fallback
|
|
410
431
|
}
|
package/lib/client/index.d.ts
CHANGED
|
@@ -26,6 +26,9 @@ import type { LexicalDTO } from '../models/LexicalDTO';
|
|
|
26
26
|
import type { HealthCheck } from '../models/HealthCheck';
|
|
27
27
|
import type { SecretDTO } from '../models/Secret';
|
|
28
28
|
import type { CreateSecretRequest, UpdateSecretRequest } from '../models/Secret';
|
|
29
|
+
import type { ProjectDTO } from '../models/ProjectDTO';
|
|
30
|
+
import type { ProjectDefaultItems } from '../models/ProjectDTO';
|
|
31
|
+
import type { UpdateSpaceRequest } from '../models/SpaceDTO';
|
|
29
32
|
import type { DatasourceDTO } from '../models/Datasource';
|
|
30
33
|
import type { CreateDatasourceRequest, UpdateDatasourceRequest } from '../models/Datasource';
|
|
31
34
|
declare const DatalayerClientWithMixins: typeof DatalayerClientBase;
|
|
@@ -41,7 +44,7 @@ declare const DatalayerClientWithMixins: typeof DatalayerClientBase;
|
|
|
41
44
|
*
|
|
42
45
|
* const user = await client.whoami();
|
|
43
46
|
* const runtime = await client.createRuntime({
|
|
44
|
-
* environment_name: '
|
|
47
|
+
* environment_name: 'ai-agents-env',
|
|
45
48
|
* credits_limit: 100
|
|
46
49
|
* });
|
|
47
50
|
* ```
|
|
@@ -65,7 +68,9 @@ export type { EnvironmentJSON, EnvironmentData, ListEnvironmentsResponse, } from
|
|
|
65
68
|
export { RuntimeSnapshotDTO as Snapshot } from '../models/RuntimeSnapshotDTO';
|
|
66
69
|
export type { RuntimeSnapshotJSON, RuntimeSnapshotData, CreateRuntimeSnapshotRequest, CreateRuntimeSnapshotResponse, GetRuntimeSnapshotResponse, ListRuntimeSnapshotsResponse, } from '../models/RuntimeSnapshotDTO';
|
|
67
70
|
export { SpaceDTO as Space } from '../models/SpaceDTO';
|
|
68
|
-
export type { SpaceJSON, SpaceData, SpaceItem, CreateSpaceRequest, CreateSpaceResponse, SpacesForUserResponse, CollaborationSessionResponse, DeleteSpaceItemResponse, GetSpaceItemResponse, GetSpaceItemsResponse, CreateNotebookRequest, CreateNotebookResponse, GetNotebookResponse, UpdateNotebookRequest, UpdateNotebookResponse, } from '../models/SpaceDTO';
|
|
71
|
+
export type { SpaceJSON, SpaceData, SpaceItem, CreateSpaceRequest, CreateSpaceResponse, SpacesForUserResponse, CollaborationSessionResponse, DeleteSpaceItemResponse, GetSpaceItemResponse, GetSpaceItemsResponse, CreateNotebookRequest, CreateNotebookResponse, GetNotebookResponse, UpdateNotebookRequest, UpdateNotebookResponse, UpdateSpaceRequest, GetSpaceResponse, UpdateSpaceResponse, DeleteSpaceResponse, GetSpaceDefaultItemsResponse, GetSpacesByTypeResponse, } from '../models/SpaceDTO';
|
|
72
|
+
export { ProjectDTO as Project } from '../models/ProjectDTO';
|
|
73
|
+
export type { ProjectJSON, ProjectDefaultItems } from '../models/ProjectDTO';
|
|
69
74
|
export { NotebookDTO as Notebook } from '../models/NotebookDTO';
|
|
70
75
|
export type { NotebookJSON, NotebookData } from '../models/NotebookDTO';
|
|
71
76
|
export { LexicalDTO } from '../models/LexicalDTO';
|
|
@@ -184,5 +189,20 @@ export interface DatalayerClient {
|
|
|
184
189
|
getCollaborationSessionId(documentId: string): Promise<string>;
|
|
185
190
|
getContent(itemId: string): Promise<any>;
|
|
186
191
|
checkSpacerHealth(): Promise<HealthCheck>;
|
|
192
|
+
getSpace(uid: string): Promise<SpaceDTO>;
|
|
193
|
+
updateSpace(uid: string, data: UpdateSpaceRequest): Promise<SpaceDTO>;
|
|
194
|
+
updateUserSpace(uid: string, userId: string, data: UpdateSpaceRequest): Promise<SpaceDTO>;
|
|
195
|
+
deleteSpace(uid: string): Promise<void>;
|
|
196
|
+
makeSpacePublic(uid: string): Promise<SpaceDTO>;
|
|
197
|
+
makeSpacePrivate(uid: string): Promise<SpaceDTO>;
|
|
198
|
+
exportSpace(uid: string): Promise<any>;
|
|
199
|
+
cloneNotebook(id: string): Promise<NotebookDTO>;
|
|
200
|
+
cloneLexical(id: string): Promise<LexicalDTO>;
|
|
201
|
+
getProjects(): Promise<ProjectDTO[]>;
|
|
202
|
+
getProject(uid: string): Promise<ProjectDTO>;
|
|
203
|
+
createProject(name: string, description?: string): Promise<ProjectDTO>;
|
|
204
|
+
updateProject(uid: string, data: UpdateSpaceRequest): Promise<ProjectDTO>;
|
|
205
|
+
renameProject(uid: string, newName: string, description?: string): Promise<ProjectDTO>;
|
|
206
|
+
getProjectDefaultItems(uid: string): Promise<ProjectDefaultItems>;
|
|
187
207
|
calculateCreditsFromMinutes(minutes: number, burningRate: number): number;
|
|
188
208
|
}
|
package/lib/client/index.js
CHANGED
|
@@ -46,7 +46,7 @@ const DatalayerClientWithMixins = composeMixins(IAMMixin, RuntimesMixin, SpacerM
|
|
|
46
46
|
*
|
|
47
47
|
* const user = await client.whoami();
|
|
48
48
|
* const runtime = await client.createRuntime({
|
|
49
|
-
* environment_name: '
|
|
49
|
+
* environment_name: 'ai-agents-env',
|
|
50
50
|
* credits_limit: 100
|
|
51
51
|
* });
|
|
52
52
|
* ```
|
|
@@ -70,6 +70,7 @@ export { RuntimeDTO as Runtime } from '../models/RuntimeDTO.js';
|
|
|
70
70
|
export { EnvironmentDTO as Environment } from '../models/EnvironmentDTO.js';
|
|
71
71
|
export { RuntimeSnapshotDTO as Snapshot } from '../models/RuntimeSnapshotDTO.js';
|
|
72
72
|
export { SpaceDTO as Space } from '../models/SpaceDTO.js';
|
|
73
|
+
export { ProjectDTO as Project } from '../models/ProjectDTO.js';
|
|
73
74
|
export { NotebookDTO as Notebook } from '../models/NotebookDTO.js';
|
|
74
75
|
export { LexicalDTO } from '../models/LexicalDTO.js';
|
|
75
76
|
export { CreditsDTO as Credits } from '../models/CreditsDTO.js';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { UpdateSpaceRequest } from '../../models/SpaceDTO';
|
|
1
2
|
import type { Constructor } from '../utils/mixins';
|
|
2
3
|
import { NotebookDTO } from '../../models/NotebookDTO';
|
|
3
4
|
import { LexicalDTO } from '../../models/LexicalDTO';
|
|
4
5
|
import { SpaceDTO } from '../../models/SpaceDTO';
|
|
6
|
+
import { ProjectDTO, type ProjectDefaultItems } from '../../models/ProjectDTO';
|
|
5
7
|
import { HealthCheck } from '../../models/HealthCheck';
|
|
6
8
|
/** Options for content loading with CDN support. */
|
|
7
9
|
export interface ContentLoadingOptions {
|
|
@@ -107,5 +109,102 @@ export declare function SpacerMixin<TBase extends Constructor>(Base: TBase): {
|
|
|
107
109
|
* Get collaboration session ID for a document
|
|
108
110
|
*/
|
|
109
111
|
getCollaborationSessionId(documentId: string): Promise<string>;
|
|
112
|
+
/**
|
|
113
|
+
* Get a space by UID.
|
|
114
|
+
* @param uid - Space UID
|
|
115
|
+
* @returns Space instance
|
|
116
|
+
*/
|
|
117
|
+
getSpace(uid: string): Promise<SpaceDTO>;
|
|
118
|
+
/**
|
|
119
|
+
* Update a space (owner updating their own space).
|
|
120
|
+
* @param uid - Space UID
|
|
121
|
+
* @param data - Update data (supports arbitrary Solr fields)
|
|
122
|
+
* @returns Updated Space instance
|
|
123
|
+
*/
|
|
124
|
+
updateSpace(uid: string, data: UpdateSpaceRequest): Promise<SpaceDTO>;
|
|
125
|
+
/**
|
|
126
|
+
* Update a user-specific space (e.g., org admin context).
|
|
127
|
+
* @param uid - Space UID
|
|
128
|
+
* @param userId - User ID
|
|
129
|
+
* @param data - Update data (supports arbitrary Solr fields)
|
|
130
|
+
* @returns Updated Space instance
|
|
131
|
+
*/
|
|
132
|
+
updateUserSpace(uid: string, userId: string, data: UpdateSpaceRequest): Promise<SpaceDTO>;
|
|
133
|
+
/**
|
|
134
|
+
* Delete a space and all its contents.
|
|
135
|
+
* @param uid - Space UID
|
|
136
|
+
*/
|
|
137
|
+
deleteSpace(uid: string): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Make a space public.
|
|
140
|
+
* @param uid - Space UID
|
|
141
|
+
* @returns Updated Space instance
|
|
142
|
+
*/
|
|
143
|
+
makeSpacePublic(uid: string): Promise<SpaceDTO>;
|
|
144
|
+
/**
|
|
145
|
+
* Make a space private.
|
|
146
|
+
* @param uid - Space UID
|
|
147
|
+
* @returns Updated Space instance
|
|
148
|
+
*/
|
|
149
|
+
makeSpacePrivate(uid: string): Promise<SpaceDTO>;
|
|
150
|
+
/**
|
|
151
|
+
* Export a space and its contents.
|
|
152
|
+
* @param uid - Space UID
|
|
153
|
+
* @returns Export data
|
|
154
|
+
*/
|
|
155
|
+
exportSpace(uid: string): Promise<any>;
|
|
156
|
+
/**
|
|
157
|
+
* Clone a notebook.
|
|
158
|
+
* @param id - Notebook ID to clone
|
|
159
|
+
* @returns Cloned Notebook instance
|
|
160
|
+
*/
|
|
161
|
+
cloneNotebook(id: string): Promise<NotebookDTO>;
|
|
162
|
+
/**
|
|
163
|
+
* Clone a lexical document.
|
|
164
|
+
* @param id - Document ID to clone
|
|
165
|
+
* @returns Cloned Lexical instance
|
|
166
|
+
*/
|
|
167
|
+
cloneLexical(id: string): Promise<LexicalDTO>;
|
|
168
|
+
/**
|
|
169
|
+
* Get all projects for the authenticated user.
|
|
170
|
+
* Projects are spaces with variant='project'.
|
|
171
|
+
* @returns Array of Project instances
|
|
172
|
+
*/
|
|
173
|
+
getProjects(): Promise<ProjectDTO[]>;
|
|
174
|
+
/**
|
|
175
|
+
* Get a project by UID.
|
|
176
|
+
* @param uid - Project UID
|
|
177
|
+
* @returns Project instance
|
|
178
|
+
*/
|
|
179
|
+
getProject(uid: string): Promise<ProjectDTO>;
|
|
180
|
+
/**
|
|
181
|
+
* Create a new project.
|
|
182
|
+
* @param name - Project name
|
|
183
|
+
* @param description - Project description
|
|
184
|
+
* @returns Created Project instance
|
|
185
|
+
*/
|
|
186
|
+
createProject(name: string, description?: string): Promise<ProjectDTO>;
|
|
187
|
+
/**
|
|
188
|
+
* Update a project.
|
|
189
|
+
* @param uid - Project UID
|
|
190
|
+
* @param data - Update data (supports arbitrary Solr fields)
|
|
191
|
+
* @returns Updated Project instance
|
|
192
|
+
*/
|
|
193
|
+
updateProject(uid: string, data: UpdateSpaceRequest): Promise<ProjectDTO>;
|
|
194
|
+
/**
|
|
195
|
+
* Rename a project.
|
|
196
|
+
* @param uid - Project UID
|
|
197
|
+
* @param newName - New project name
|
|
198
|
+
* @param description - Project description to preserve.
|
|
199
|
+
* @param userId - Authenticated user ID for user-scoped update.
|
|
200
|
+
* @returns Updated Project instance
|
|
201
|
+
*/
|
|
202
|
+
renameProject(uid: string, newName: string, description?: string): Promise<ProjectDTO>;
|
|
203
|
+
/**
|
|
204
|
+
* Get default items (notebook UID and document UID) for a project.
|
|
205
|
+
* @param uid - Project UID
|
|
206
|
+
* @returns Default notebook and document UIDs
|
|
207
|
+
*/
|
|
208
|
+
getProjectDefaultItems(uid: string): Promise<ProjectDefaultItems>;
|
|
110
209
|
};
|
|
111
210
|
} & TBase;
|