@datalayer/core 0.0.27 → 1.0.1
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/index.d.ts +1 -1
- package/lib/api/index.js +1 -1
- package/lib/client/utils/spacerUtils.d.ts +2 -2
- package/lib/client/utils/spacerUtils.js +4 -4
- package/lib/components/storage/ContentsBrowser.js +2 -2
- package/lib/hooks/useCache.d.ts +9 -1
- package/lib/hooks/useCache.js +67 -6
- package/lib/models/CreditsDTO.d.ts +1 -1
- package/lib/models/CreditsDTO.js +1 -1
- package/lib/models/Datasource.d.ts +4 -4
- package/lib/models/Datasource.js +7 -7
- package/lib/models/EnvironmentDTO.d.ts +3 -3
- package/lib/models/EnvironmentDTO.js +3 -3
- package/lib/models/HealthCheck.d.ts +2 -2
- package/lib/models/HealthCheck.js +2 -2
- package/lib/models/ItemDTO.d.ts +3 -3
- package/lib/models/ItemDTO.js +10 -10
- package/lib/models/LexicalDTO.d.ts +3 -3
- package/lib/models/LexicalDTO.js +4 -4
- package/lib/models/NotebookDTO.d.ts +3 -3
- package/lib/models/NotebookDTO.js +6 -6
- package/lib/models/RuntimeDTO.d.ts +4 -4
- package/lib/models/RuntimeDTO.js +9 -9
- package/lib/models/RuntimeSnapshotDTO.d.ts +3 -3
- package/lib/models/RuntimeSnapshotDTO.js +7 -7
- package/lib/models/Secret.d.ts +4 -4
- package/lib/models/Secret.js +7 -7
- package/lib/models/Space.js +3 -0
- package/lib/models/SpaceDTO.d.ts +3 -3
- package/lib/models/SpaceDTO.js +14 -14
- package/lib/models/UserDTO.d.ts +2 -2
- package/lib/models/UserDTO.js +2 -2
- package/lib/theme/DatalayerTheme.js +5 -5
- package/package.json +1 -1
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
|
-
* Client classes, use @datalayer/core/
|
|
5
|
+
* Client classes, use @datalayer/core/client 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
|
-
* Client classes, use @datalayer/core/
|
|
9
|
+
* Client classes, use @datalayer/core/client instead.
|
|
10
10
|
*
|
|
11
11
|
* @module @datalayer/core/api
|
|
12
12
|
*/
|
|
@@ -12,7 +12,7 @@ import { LexicalDTO } from '../../models/LexicalDTO';
|
|
|
12
12
|
* to avoid code duplication.
|
|
13
13
|
*
|
|
14
14
|
* @param response - Raw API response containing space items
|
|
15
|
-
* @param
|
|
15
|
+
* @param client - Client instance to pass to model constructors
|
|
16
16
|
* @returns Array of Notebook and Lexical model instances
|
|
17
17
|
*/
|
|
18
|
-
export declare function convertSpaceItemsToModels(items: GetSpaceItemsResponse['items'],
|
|
18
|
+
export declare function convertSpaceItemsToModels(items: GetSpaceItemsResponse['items'], client: DatalayerClient): (NotebookDTO | LexicalDTO)[];
|
|
@@ -11,20 +11,20 @@ import { ItemTypes } from '../constants';
|
|
|
11
11
|
* to avoid code duplication.
|
|
12
12
|
*
|
|
13
13
|
* @param response - Raw API response containing space items
|
|
14
|
-
* @param
|
|
14
|
+
* @param client - Client instance to pass to model constructors
|
|
15
15
|
* @returns Array of Notebook and Lexical model instances
|
|
16
16
|
*/
|
|
17
|
-
export function convertSpaceItemsToModels(items,
|
|
17
|
+
export function convertSpaceItemsToModels(items, client) {
|
|
18
18
|
const modelItems = [];
|
|
19
19
|
for (const item of items) {
|
|
20
20
|
// Check various possible type fields
|
|
21
21
|
const itemType = item.type_s;
|
|
22
22
|
// Only include notebooks and lexicals
|
|
23
23
|
if (itemType === ItemTypes.NOTEBOOK) {
|
|
24
|
-
modelItems.push(new NotebookDTO(item,
|
|
24
|
+
modelItems.push(new NotebookDTO(item, client));
|
|
25
25
|
}
|
|
26
26
|
else if (itemType === ItemTypes.LEXICAL) {
|
|
27
|
-
modelItems.push(new LexicalDTO(item,
|
|
27
|
+
modelItems.push(new LexicalDTO(item, client));
|
|
28
28
|
}
|
|
29
29
|
// Skip everything else (exercises, cells, etc.)
|
|
30
30
|
}
|
|
@@ -221,9 +221,9 @@ export function ContentsBrowser(props) {
|
|
|
221
221
|
return child.type === 'directory' ? (_jsx(DirectoryItem, { item: child, contents: contents, current: selectedItem, documentRegistry: documentRegistry, onContextMenu: onContextMenu, onSelect: onSelect }, child.name)) : (_jsx(TreeItem, { item: child, current: selectedItem?.path === child.path, onSelect: item => {
|
|
222
222
|
onSelect(item, refresh);
|
|
223
223
|
}, onContextMenu: onContextMenu }, child.name));
|
|
224
|
-
}) }), _jsx(ActionMenu, { anchorRef: contextMenuAnchor ?? undefined, open: contextMenuAnchor?.current !== null, onOpenChange: () => {
|
|
224
|
+
}) }), contextMenuAnchor !== null && (_jsx(ActionMenu, { anchorRef: contextMenuAnchor ?? undefined, open: contextMenuAnchor?.current !== null, onOpenChange: () => {
|
|
225
225
|
setContextMenuAnchor(null);
|
|
226
|
-
}, children: _jsx(ActionMenu.Overlay, { children: _jsxs(ActionList, { children: [_jsx(ActionList.Item, { title: "Delete the active item.", onSelect: onSelectDelete, children: "Delete\u2026" }), localContents && (_jsx(ActionList.Item, { title: "Copy the active item to the local drive.", onSelect: onSelectCopyToLocal, children: "Copy to local drive\u2026" }))] }) }) }), openDeleteConfirmation && (_jsx(Dialog, { title: _jsx("span", { style: { color: 'var(--fgColor-default)' }, children: "Confirm deletion" }), onClose: () => {
|
|
226
|
+
}, children: _jsx(ActionMenu.Overlay, { children: _jsxs(ActionList, { children: [_jsx(ActionList.Item, { title: "Delete the active item.", onSelect: onSelectDelete, children: "Delete\u2026" }), localContents && (_jsx(ActionList.Item, { title: "Copy the active item to the local drive.", onSelect: onSelectCopyToLocal, children: "Copy to local drive\u2026" }))] }) }) })), openDeleteConfirmation && (_jsx(Dialog, { title: _jsx("span", { style: { color: 'var(--fgColor-default)' }, children: "Confirm deletion" }), onClose: () => {
|
|
227
227
|
setOpenDeleteConfirmation(false);
|
|
228
228
|
}, footerButtons: [
|
|
229
229
|
{
|
package/lib/hooks/useCache.d.ts
CHANGED
|
@@ -451,7 +451,8 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
451
451
|
space: Partial<IAnySpace>;
|
|
452
452
|
organization?: IAnyOrganization;
|
|
453
453
|
}, unknown>;
|
|
454
|
-
useUpdateSpace: () => import("@tanstack/react-query").UseMutationResult<any, Error, Partial<IAnySpace>, unknown>;
|
|
454
|
+
useUpdateSpace: () => import("@tanstack/react-query").UseMutationResult<any, Error, Partial<IAnySpace> & Record<string, unknown>, unknown>;
|
|
455
|
+
useDeleteSpace: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
455
456
|
useUpdateOrganizationSpace: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
456
457
|
organizationId: string;
|
|
457
458
|
spaceId: string;
|
|
@@ -507,6 +508,7 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
507
508
|
id: string;
|
|
508
509
|
url: string | undefined;
|
|
509
510
|
messageCount: number;
|
|
511
|
+
agent_spec_id: string | undefined;
|
|
510
512
|
pod_name: string;
|
|
511
513
|
environment_name: string;
|
|
512
514
|
environment_title?: string;
|
|
@@ -526,6 +528,7 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
526
528
|
id: string;
|
|
527
529
|
url: string | undefined;
|
|
528
530
|
messageCount: number;
|
|
531
|
+
agent_spec_id: string | undefined;
|
|
529
532
|
pod_name: string;
|
|
530
533
|
environment_name: string;
|
|
531
534
|
environment_title?: string;
|
|
@@ -546,6 +549,7 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
546
549
|
type?: string;
|
|
547
550
|
editorVariant?: string;
|
|
548
551
|
enableCodemode?: boolean;
|
|
552
|
+
agentSpecId?: string;
|
|
549
553
|
}, unknown>;
|
|
550
554
|
useDeleteAgentRuntime: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
551
555
|
useRefreshAgentRuntimes: () => () => void;
|
|
@@ -712,6 +716,10 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
712
716
|
useRefreshSpaceAssignments: (options?: UseMutationOptions<unknown, Error, string>) => import("@tanstack/react-query").UseMutationResult<unknown, Error, string, unknown>;
|
|
713
717
|
useDeleteItem: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
714
718
|
useSpaceItems: (spaceId: string) => import("@tanstack/react-query").UseQueryResult<any[], Error>;
|
|
719
|
+
useSpaceDefaultItems: (spaceId: string | undefined) => import("@tanstack/react-query").UseQueryResult<{
|
|
720
|
+
defaultNotebookUid: string | null;
|
|
721
|
+
defaultDocumentUid: string | null;
|
|
722
|
+
}, Error>;
|
|
715
723
|
useMakeItemPublic: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
716
724
|
useMakeItemPrivate: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
717
725
|
useSearchPublicItems: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
package/lib/hooks/useCache.js
CHANGED
|
@@ -1321,17 +1321,20 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1321
1321
|
});
|
|
1322
1322
|
};
|
|
1323
1323
|
/**
|
|
1324
|
-
* Update space with optimistic update
|
|
1324
|
+
* Update space with optimistic update.
|
|
1325
|
+
* Any extra fields (e.g. attached_agent_pod_name_s) are forwarded to the backend.
|
|
1325
1326
|
*/
|
|
1326
1327
|
const useUpdateSpace = () => {
|
|
1327
1328
|
return useMutation({
|
|
1328
1329
|
mutationFn: async (space) => {
|
|
1330
|
+
const { id, name, description, ...extraFields } = space;
|
|
1329
1331
|
return requestDatalayer({
|
|
1330
|
-
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${
|
|
1332
|
+
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${id}/users/${user?.id}`,
|
|
1331
1333
|
method: 'PUT',
|
|
1332
1334
|
body: {
|
|
1333
|
-
name
|
|
1334
|
-
description
|
|
1335
|
+
name,
|
|
1336
|
+
description,
|
|
1337
|
+
...extraFields,
|
|
1335
1338
|
},
|
|
1336
1339
|
});
|
|
1337
1340
|
},
|
|
@@ -1348,6 +1351,25 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1348
1351
|
},
|
|
1349
1352
|
});
|
|
1350
1353
|
};
|
|
1354
|
+
/**
|
|
1355
|
+
* Delete a space and all its contents.
|
|
1356
|
+
*/
|
|
1357
|
+
const useDeleteSpace = () => {
|
|
1358
|
+
return useMutation({
|
|
1359
|
+
mutationFn: async (spaceUid) => {
|
|
1360
|
+
return requestDatalayer({
|
|
1361
|
+
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${spaceUid}`,
|
|
1362
|
+
method: 'DELETE',
|
|
1363
|
+
});
|
|
1364
|
+
},
|
|
1365
|
+
onSuccess: () => {
|
|
1366
|
+
// Invalidate all space queries
|
|
1367
|
+
queryClient.invalidateQueries({
|
|
1368
|
+
queryKey: queryKeys.spaces.all(),
|
|
1369
|
+
});
|
|
1370
|
+
},
|
|
1371
|
+
});
|
|
1372
|
+
};
|
|
1351
1373
|
// ============================================================================
|
|
1352
1374
|
// Agent Spaces Hooks
|
|
1353
1375
|
// ============================================================================
|
|
@@ -1604,6 +1626,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1604
1626
|
// Map ingress URL to url for UI consistency
|
|
1605
1627
|
url: rt.ingress,
|
|
1606
1628
|
messageCount: 0, // Default for UI compatibility
|
|
1629
|
+
agent_spec_id: rt.agent_spec_id || undefined,
|
|
1607
1630
|
}));
|
|
1608
1631
|
// Set detail cache for each runtime
|
|
1609
1632
|
agentRuntimes.forEach((runtime) => {
|
|
@@ -1652,12 +1675,22 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1652
1675
|
// Map ingress URL to url for UI consistency
|
|
1653
1676
|
url: rt.ingress,
|
|
1654
1677
|
messageCount: 0,
|
|
1678
|
+
agent_spec_id: rt.agent_spec_id || undefined,
|
|
1655
1679
|
};
|
|
1656
1680
|
}
|
|
1657
1681
|
throw new Error('Failed to fetch agent runtime');
|
|
1658
1682
|
},
|
|
1659
1683
|
...DEFAULT_QUERY_OPTIONS,
|
|
1660
|
-
|
|
1684
|
+
// Poll every 5 seconds while the runtime exists. Stop polling on error
|
|
1685
|
+
// (e.g. 404 — runtime deleted, 500 — broken state) to avoid hammering the server.
|
|
1686
|
+
refetchInterval: query => {
|
|
1687
|
+
if (query.state.error)
|
|
1688
|
+
return false;
|
|
1689
|
+
return 5000;
|
|
1690
|
+
},
|
|
1691
|
+
// Don't retry failed detail requests. The refetchInterval handles
|
|
1692
|
+
// periodic re-checks, so retrying only generates duplicate failing requests.
|
|
1693
|
+
retry: false,
|
|
1661
1694
|
enabled: !!podName,
|
|
1662
1695
|
});
|
|
1663
1696
|
};
|
|
@@ -1669,11 +1702,12 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1669
1702
|
method: 'POST',
|
|
1670
1703
|
body: {
|
|
1671
1704
|
environment_name: data.environmentName || 'ai-agents-env',
|
|
1672
|
-
given_name: data.givenName || 'Agent
|
|
1705
|
+
given_name: data.givenName || 'Agent',
|
|
1673
1706
|
credits_limit: data.creditsLimit || 10,
|
|
1674
1707
|
type: data.type || 'notebook',
|
|
1675
1708
|
editor_variant: data.editorVariant || 'none',
|
|
1676
1709
|
enable_codemode: data.enableCodemode ?? false,
|
|
1710
|
+
agent_spec_id: data.agentSpecId || undefined,
|
|
1677
1711
|
},
|
|
1678
1712
|
});
|
|
1679
1713
|
},
|
|
@@ -1691,6 +1725,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
1691
1725
|
// Map ingress URL to url for UI consistency
|
|
1692
1726
|
url: rt.ingress,
|
|
1693
1727
|
messageCount: 0,
|
|
1728
|
+
agent_spec_id: rt.agent_spec_id || undefined,
|
|
1694
1729
|
});
|
|
1695
1730
|
// Invalidate list
|
|
1696
1731
|
queryClient.invalidateQueries({
|
|
@@ -3613,6 +3648,30 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
3613
3648
|
...DEFAULT_QUERY_OPTIONS,
|
|
3614
3649
|
});
|
|
3615
3650
|
};
|
|
3651
|
+
/**
|
|
3652
|
+
* Get default items (notebook UID & document UID) for a space / project.
|
|
3653
|
+
* Calls GET /api/spacer/v1/spaces/{spaceId}/default-items
|
|
3654
|
+
*/
|
|
3655
|
+
const useSpaceDefaultItems = (spaceId) => {
|
|
3656
|
+
return useQuery({
|
|
3657
|
+
queryKey: ['spaces', spaceId, 'default-items'],
|
|
3658
|
+
queryFn: async () => {
|
|
3659
|
+
const resp = await requestDatalayer({
|
|
3660
|
+
url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${spaceId}/default-items`,
|
|
3661
|
+
method: 'GET',
|
|
3662
|
+
});
|
|
3663
|
+
if (resp.success) {
|
|
3664
|
+
return {
|
|
3665
|
+
defaultNotebookUid: resp.default_notebook_uid,
|
|
3666
|
+
defaultDocumentUid: resp.default_document_uid,
|
|
3667
|
+
};
|
|
3668
|
+
}
|
|
3669
|
+
throw new Error(resp.message || 'Failed to fetch default items');
|
|
3670
|
+
},
|
|
3671
|
+
enabled: !!spaceId,
|
|
3672
|
+
...DEFAULT_QUERY_OPTIONS,
|
|
3673
|
+
});
|
|
3674
|
+
};
|
|
3616
3675
|
/**
|
|
3617
3676
|
* Make item public
|
|
3618
3677
|
*/
|
|
@@ -6467,6 +6526,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
6467
6526
|
useUserSpaces,
|
|
6468
6527
|
useCreateSpace,
|
|
6469
6528
|
useUpdateSpace,
|
|
6529
|
+
useDeleteSpace,
|
|
6470
6530
|
useUpdateOrganizationSpace,
|
|
6471
6531
|
useAddMemberToOrganizationSpace,
|
|
6472
6532
|
useRemoveMemberFromOrganizationSpace,
|
|
@@ -6576,6 +6636,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
6576
6636
|
// Items (Generic)
|
|
6577
6637
|
useDeleteItem,
|
|
6578
6638
|
useSpaceItems,
|
|
6639
|
+
useSpaceDefaultItems,
|
|
6579
6640
|
useMakeItemPublic,
|
|
6580
6641
|
useMakeItemPrivate,
|
|
6581
6642
|
useSearchPublicItems,
|
|
@@ -42,7 +42,7 @@ export interface CreditsResponse {
|
|
|
42
42
|
*
|
|
43
43
|
* @example
|
|
44
44
|
* ```typescript
|
|
45
|
-
* const credits = await
|
|
45
|
+
* const credits = await client.getCredits();
|
|
46
46
|
* console.log(`Available: ${credits.available}`);
|
|
47
47
|
* console.log(`Quota: ${credits.quota || 'unlimited'}`);
|
|
48
48
|
*
|
package/lib/models/CreditsDTO.js
CHANGED
|
@@ -13,7 +13,7 @@ import { validateJSON } from '../api/utils/validation';
|
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* ```typescript
|
|
16
|
-
* const credits = await
|
|
16
|
+
* const credits = await client.getCredits();
|
|
17
17
|
* console.log(`Available: ${credits.available}`);
|
|
18
18
|
* console.log(`Quota: ${credits.quota || 'unlimited'}`);
|
|
19
19
|
*
|
|
@@ -126,7 +126,7 @@ export interface UpdateDatasourceResponse {
|
|
|
126
126
|
*
|
|
127
127
|
* @example
|
|
128
128
|
* ```typescript
|
|
129
|
-
* const datasource = await
|
|
129
|
+
* const datasource = await client.createDatasource({
|
|
130
130
|
* type: 'Amazon Athena',
|
|
131
131
|
* name: 'my-athena-datasource',
|
|
132
132
|
* description: 'Production Athena datasource',
|
|
@@ -141,14 +141,14 @@ export interface UpdateDatasourceResponse {
|
|
|
141
141
|
export declare class DatasourceDTO {
|
|
142
142
|
/** @internal */
|
|
143
143
|
_data: DatasourceData;
|
|
144
|
-
private
|
|
144
|
+
private _client;
|
|
145
145
|
private _deleted;
|
|
146
146
|
/**
|
|
147
147
|
* Create a Datasource instance.
|
|
148
148
|
* @param data - Datasource data from API
|
|
149
|
-
* @param
|
|
149
|
+
* @param client - Client instance
|
|
150
150
|
*/
|
|
151
|
-
constructor(data: DatasourceData,
|
|
151
|
+
constructor(data: DatasourceData, client: DatalayerClient);
|
|
152
152
|
private _checkDeleted;
|
|
153
153
|
get uid(): string;
|
|
154
154
|
get type(): DatasourceType;
|
package/lib/models/Datasource.js
CHANGED
|
@@ -25,7 +25,7 @@ import { validateJSON } from '../api/utils/validation';
|
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
27
27
|
* ```typescript
|
|
28
|
-
* const datasource = await
|
|
28
|
+
* const datasource = await client.createDatasource({
|
|
29
29
|
* type: 'Amazon Athena',
|
|
30
30
|
* name: 'my-athena-datasource',
|
|
31
31
|
* description: 'Production Athena datasource',
|
|
@@ -40,16 +40,16 @@ import { validateJSON } from '../api/utils/validation';
|
|
|
40
40
|
export class DatasourceDTO {
|
|
41
41
|
/** @internal */
|
|
42
42
|
_data;
|
|
43
|
-
|
|
43
|
+
_client;
|
|
44
44
|
_deleted = false;
|
|
45
45
|
/**
|
|
46
46
|
* Create a Datasource instance.
|
|
47
47
|
* @param data - Datasource data from API
|
|
48
|
-
* @param
|
|
48
|
+
* @param client - Client instance
|
|
49
49
|
*/
|
|
50
|
-
constructor(data,
|
|
50
|
+
constructor(data, client) {
|
|
51
51
|
this._data = data;
|
|
52
|
-
this.
|
|
52
|
+
this._client = client;
|
|
53
53
|
}
|
|
54
54
|
// ========================================================================
|
|
55
55
|
// Helper Methods
|
|
@@ -108,7 +108,7 @@ export class DatasourceDTO {
|
|
|
108
108
|
*/
|
|
109
109
|
async update(updates) {
|
|
110
110
|
this._checkDeleted();
|
|
111
|
-
const updated = await this.
|
|
111
|
+
const updated = await this._client.updateDatasource(this.uid, updates);
|
|
112
112
|
return updated;
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
@@ -116,7 +116,7 @@ export class DatasourceDTO {
|
|
|
116
116
|
*/
|
|
117
117
|
async delete() {
|
|
118
118
|
this._checkDeleted();
|
|
119
|
-
await this.
|
|
119
|
+
await this._client.deleteDatasource(this.uid);
|
|
120
120
|
this._deleted = true;
|
|
121
121
|
}
|
|
122
122
|
// ========================================================================
|
|
@@ -80,7 +80,7 @@ export interface ListEnvironmentsResponse {
|
|
|
80
80
|
*
|
|
81
81
|
* @example
|
|
82
82
|
* ```typescript
|
|
83
|
-
* const environments = await
|
|
83
|
+
* const environments = await client.listEnvironments();
|
|
84
84
|
* const aiEnv = environments.find(env => env.name === 'ai-env');
|
|
85
85
|
* console.log(aiEnv.title); // "AI Environment"
|
|
86
86
|
* ```
|
|
@@ -92,9 +92,9 @@ export declare class EnvironmentDTO {
|
|
|
92
92
|
* Create an Environment instance.
|
|
93
93
|
*
|
|
94
94
|
* @param data - Environment data from API
|
|
95
|
-
* @param
|
|
95
|
+
* @param _client - Client instance (not currently used but kept for consistency)
|
|
96
96
|
*/
|
|
97
|
-
constructor(data: EnvironmentData,
|
|
97
|
+
constructor(data: EnvironmentData, _client: DatalayerClient);
|
|
98
98
|
/** Human-readable title for the environment (e.g., 'AI Environment', 'Python CPU Environment'). */
|
|
99
99
|
get title(): string;
|
|
100
100
|
/** Unique name identifier for the environment (e.g., 'ai-env', 'python-cpu-env'). */
|
|
@@ -9,7 +9,7 @@ import { validateJSON } from '../api/utils/validation';
|
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* ```typescript
|
|
12
|
-
* const environments = await
|
|
12
|
+
* const environments = await client.listEnvironments();
|
|
13
13
|
* const aiEnv = environments.find(env => env.name === 'ai-env');
|
|
14
14
|
* console.log(aiEnv.title); // "AI Environment"
|
|
15
15
|
* ```
|
|
@@ -21,9 +21,9 @@ export class EnvironmentDTO {
|
|
|
21
21
|
* Create an Environment instance.
|
|
22
22
|
*
|
|
23
23
|
* @param data - Environment data from API
|
|
24
|
-
* @param
|
|
24
|
+
* @param _client - Client instance (not currently used but kept for consistency)
|
|
25
25
|
*/
|
|
26
|
-
constructor(data,
|
|
26
|
+
constructor(data, _client) {
|
|
27
27
|
this._data = data;
|
|
28
28
|
// Client instance not currently used but kept for future extensibility
|
|
29
29
|
}
|
|
@@ -11,9 +11,9 @@ export declare class HealthCheck {
|
|
|
11
11
|
/**
|
|
12
12
|
* Create a HealthCheck instance.
|
|
13
13
|
* @param data - The health check data
|
|
14
|
-
* @param
|
|
14
|
+
* @param client - Reference to the Client instance (unused but kept for consistency)
|
|
15
15
|
*/
|
|
16
|
-
constructor(data: any,
|
|
16
|
+
constructor(data: any, client: any);
|
|
17
17
|
/**
|
|
18
18
|
* Check if the service is healthy.
|
|
19
19
|
* @returns True if the service is healthy
|
|
@@ -17,9 +17,9 @@ export class HealthCheck {
|
|
|
17
17
|
/**
|
|
18
18
|
* Create a HealthCheck instance.
|
|
19
19
|
* @param data - The health check data
|
|
20
|
-
* @param
|
|
20
|
+
* @param client - Reference to the Client instance (unused but kept for consistency)
|
|
21
21
|
*/
|
|
22
|
-
constructor(data,
|
|
22
|
+
constructor(data, client) {
|
|
23
23
|
// Initialize properties
|
|
24
24
|
this.healthy = data.healthy || false;
|
|
25
25
|
this.status = data.status || 'unknown';
|
package/lib/models/ItemDTO.d.ts
CHANGED
|
@@ -13,14 +13,14 @@ import type { DatalayerClient } from '../index';
|
|
|
13
13
|
*/
|
|
14
14
|
export declare abstract class ItemDTO<TData> {
|
|
15
15
|
protected _data: TData;
|
|
16
|
-
private
|
|
16
|
+
private _client;
|
|
17
17
|
private _deleted;
|
|
18
18
|
/**
|
|
19
19
|
* Create an Item instance.
|
|
20
20
|
* @param data - Item data from API
|
|
21
|
-
* @param
|
|
21
|
+
* @param client - Client instance
|
|
22
22
|
*/
|
|
23
|
-
constructor(data: TData,
|
|
23
|
+
constructor(data: TData, client: DatalayerClient);
|
|
24
24
|
/** Check if this item has been deleted. */
|
|
25
25
|
get isDeleted(): boolean;
|
|
26
26
|
/**
|
package/lib/models/ItemDTO.js
CHANGED
|
@@ -12,16 +12,16 @@ import * as items from '../api/spacer/items';
|
|
|
12
12
|
*/
|
|
13
13
|
export class ItemDTO {
|
|
14
14
|
_data;
|
|
15
|
-
|
|
15
|
+
_client;
|
|
16
16
|
_deleted = false;
|
|
17
17
|
/**
|
|
18
18
|
* Create an Item instance.
|
|
19
19
|
* @param data - Item data from API
|
|
20
|
-
* @param
|
|
20
|
+
* @param client - Client instance
|
|
21
21
|
*/
|
|
22
|
-
constructor(data,
|
|
22
|
+
constructor(data, client) {
|
|
23
23
|
this._data = data;
|
|
24
|
-
this.
|
|
24
|
+
this._client = client;
|
|
25
25
|
}
|
|
26
26
|
// ========================================================================
|
|
27
27
|
// Deletion State Management
|
|
@@ -105,8 +105,8 @@ export class ItemDTO {
|
|
|
105
105
|
*/
|
|
106
106
|
async delete() {
|
|
107
107
|
this._checkDeleted();
|
|
108
|
-
const token = this.
|
|
109
|
-
const spacerRunUrl = this.
|
|
108
|
+
const token = this._client.getToken();
|
|
109
|
+
const spacerRunUrl = this._client.getSpacerRunUrl();
|
|
110
110
|
await items.deleteItem(token, this.uid, spacerRunUrl);
|
|
111
111
|
this._deleted = true;
|
|
112
112
|
}
|
|
@@ -137,8 +137,8 @@ export class ItemDTO {
|
|
|
137
137
|
}
|
|
138
138
|
// Third try: Fetch full item details from API
|
|
139
139
|
try {
|
|
140
|
-
const token = this.
|
|
141
|
-
const spacerRunUrl = this.
|
|
140
|
+
const token = this._client.getToken();
|
|
141
|
+
const spacerRunUrl = this._client.getSpacerRunUrl();
|
|
142
142
|
const response = await items.getItem(token, this.uid, spacerRunUrl);
|
|
143
143
|
// Update internal data with full item details
|
|
144
144
|
if (response.success && response.item) {
|
|
@@ -173,11 +173,11 @@ export class ItemDTO {
|
|
|
173
173
|
// ========================================================================
|
|
174
174
|
/** Get Client token for API calls. */
|
|
175
175
|
_getToken() {
|
|
176
|
-
return this.
|
|
176
|
+
return this._client.getToken();
|
|
177
177
|
}
|
|
178
178
|
/** Get spacer API URL for API calls. */
|
|
179
179
|
_getSpacerRunUrl() {
|
|
180
|
-
return this.
|
|
180
|
+
return this._client.getSpacerRunUrl();
|
|
181
181
|
}
|
|
182
182
|
/** Update internal data after API call. */
|
|
183
183
|
_updateData(newData) {
|
|
@@ -109,7 +109,7 @@ export interface LexicalJSON {
|
|
|
109
109
|
*
|
|
110
110
|
* @example
|
|
111
111
|
* ```typescript
|
|
112
|
-
* const lexical = await
|
|
112
|
+
* const lexical = await client.createLexical(formData);
|
|
113
113
|
* await lexical.update({ name: 'Updated Documentation' });
|
|
114
114
|
* ```
|
|
115
115
|
*/
|
|
@@ -118,9 +118,9 @@ export declare class LexicalDTO extends ItemDTO<LexicalData> {
|
|
|
118
118
|
* Create a Lexical instance.
|
|
119
119
|
*
|
|
120
120
|
* @param data - Lexical data from API
|
|
121
|
-
* @param
|
|
121
|
+
* @param client - Client instance
|
|
122
122
|
*/
|
|
123
|
-
constructor(data: LexicalData,
|
|
123
|
+
constructor(data: LexicalData, client: DatalayerClient);
|
|
124
124
|
/** Document type identifier. */
|
|
125
125
|
get type(): string;
|
|
126
126
|
/** The cached name of the document. */
|
package/lib/models/LexicalDTO.js
CHANGED
|
@@ -17,7 +17,7 @@ import { validateJSON } from '../api/utils/validation';
|
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```typescript
|
|
20
|
-
* const lexical = await
|
|
20
|
+
* const lexical = await client.createLexical(formData);
|
|
21
21
|
* await lexical.update({ name: 'Updated Documentation' });
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
@@ -26,10 +26,10 @@ export class LexicalDTO extends ItemDTO {
|
|
|
26
26
|
* Create a Lexical instance.
|
|
27
27
|
*
|
|
28
28
|
* @param data - Lexical data from API
|
|
29
|
-
* @param
|
|
29
|
+
* @param client - Client instance
|
|
30
30
|
*/
|
|
31
|
-
constructor(data,
|
|
32
|
-
super(data,
|
|
31
|
+
constructor(data, client) {
|
|
32
|
+
super(data, client);
|
|
33
33
|
}
|
|
34
34
|
// ========================================================================
|
|
35
35
|
// Abstract Method Implementations
|
|
@@ -42,7 +42,7 @@ export interface NotebookJSON {
|
|
|
42
42
|
*
|
|
43
43
|
* @example
|
|
44
44
|
* ```typescript
|
|
45
|
-
* const notebook = await
|
|
45
|
+
* const notebook = await client.createNotebook(formData);
|
|
46
46
|
* const kernelSpec = await notebook.getKernelSpec();
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
@@ -51,9 +51,9 @@ export declare class NotebookDTO extends ItemDTO<NotebookData> {
|
|
|
51
51
|
* Create a Notebook instance.
|
|
52
52
|
*
|
|
53
53
|
* @param data - Notebook data from API
|
|
54
|
-
* @param
|
|
54
|
+
* @param client - Client instance
|
|
55
55
|
*/
|
|
56
|
-
constructor(data: NotebookData,
|
|
56
|
+
constructor(data: NotebookData, client: DatalayerClient);
|
|
57
57
|
/** Document type identifier. */
|
|
58
58
|
get type(): string;
|
|
59
59
|
/** The cached name of the notebook. */
|
|
@@ -12,7 +12,7 @@ import { validateJSON } from '../api/utils/validation';
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```typescript
|
|
15
|
-
* const notebook = await
|
|
15
|
+
* const notebook = await client.createNotebook(formData);
|
|
16
16
|
* const kernelSpec = await notebook.getKernelSpec();
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
@@ -21,10 +21,10 @@ export class NotebookDTO extends ItemDTO {
|
|
|
21
21
|
* Create a Notebook instance.
|
|
22
22
|
*
|
|
23
23
|
* @param data - Notebook data from API
|
|
24
|
-
* @param
|
|
24
|
+
* @param client - Client instance
|
|
25
25
|
*/
|
|
26
|
-
constructor(data,
|
|
27
|
-
super(data,
|
|
26
|
+
constructor(data, client) {
|
|
27
|
+
super(data, client);
|
|
28
28
|
}
|
|
29
29
|
// ========================================================================
|
|
30
30
|
// Abstract Method Implementations
|
|
@@ -74,8 +74,8 @@ export class NotebookDTO extends ItemDTO {
|
|
|
74
74
|
async update(name, description) {
|
|
75
75
|
// FIXME: check if both are needed, and use the existing values if only one provided
|
|
76
76
|
this._checkDeleted();
|
|
77
|
-
const token = this.
|
|
78
|
-
const spacerRunUrl = this.
|
|
77
|
+
const token = this._client.getToken();
|
|
78
|
+
const spacerRunUrl = this._client.getSpacerRunUrl();
|
|
79
79
|
const updateData = {};
|
|
80
80
|
if (name !== undefined)
|
|
81
81
|
updateData.name = name;
|
|
@@ -105,22 +105,22 @@ export interface ListRuntimesResponse {
|
|
|
105
105
|
*
|
|
106
106
|
* @example
|
|
107
107
|
* ```typescript
|
|
108
|
-
* const runtime = await
|
|
108
|
+
* const runtime = await client.createRuntime({ environment_name: 'python-cpu' });
|
|
109
109
|
* await runtime.waitUntilReady();
|
|
110
110
|
* ```
|
|
111
111
|
*/
|
|
112
112
|
export declare class RuntimeDTO {
|
|
113
113
|
/** @internal */
|
|
114
114
|
_data: RuntimeData;
|
|
115
|
-
private
|
|
115
|
+
private _client;
|
|
116
116
|
private _deleted;
|
|
117
117
|
/**
|
|
118
118
|
* Create a Runtime instance.
|
|
119
119
|
*
|
|
120
120
|
* @param data - Runtime data from API
|
|
121
|
-
* @param
|
|
121
|
+
* @param client - Client instance
|
|
122
122
|
*/
|
|
123
|
-
constructor(data: RuntimeData,
|
|
123
|
+
constructor(data: RuntimeData, client: DatalayerClient);
|
|
124
124
|
/**
|
|
125
125
|
* Check if this runtime has been deleted and throw error if so.
|
|
126
126
|
* @throws Error if deleted
|
package/lib/models/RuntimeDTO.js
CHANGED
|
@@ -15,24 +15,24 @@ import { validateJSON } from '../api/utils/validation';
|
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
|
18
|
-
* const runtime = await
|
|
18
|
+
* const runtime = await client.createRuntime({ environment_name: 'python-cpu' });
|
|
19
19
|
* await runtime.waitUntilReady();
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
export class RuntimeDTO {
|
|
23
23
|
/** @internal */
|
|
24
24
|
_data;
|
|
25
|
-
|
|
25
|
+
_client;
|
|
26
26
|
_deleted = false;
|
|
27
27
|
/**
|
|
28
28
|
* Create a Runtime instance.
|
|
29
29
|
*
|
|
30
30
|
* @param data - Runtime data from API
|
|
31
|
-
* @param
|
|
31
|
+
* @param client - Client instance
|
|
32
32
|
*/
|
|
33
|
-
constructor(data,
|
|
33
|
+
constructor(data, client) {
|
|
34
34
|
this._data = data;
|
|
35
|
-
this.
|
|
35
|
+
this._client = client;
|
|
36
36
|
}
|
|
37
37
|
// ========================================================================
|
|
38
38
|
// Helper Methods
|
|
@@ -112,7 +112,7 @@ export class RuntimeDTO {
|
|
|
112
112
|
* After deletion, subsequent calls to dynamic methods will throw errors.
|
|
113
113
|
*/
|
|
114
114
|
async delete() {
|
|
115
|
-
await this.
|
|
115
|
+
await this._client.deleteRuntime(this.podName);
|
|
116
116
|
this._deleted = true;
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
@@ -123,8 +123,8 @@ export class RuntimeDTO {
|
|
|
123
123
|
*/
|
|
124
124
|
async update(from) {
|
|
125
125
|
this._checkDeleted();
|
|
126
|
-
const updated = await updateRuntime(this.
|
|
127
|
-
return new RuntimeDTO(updated, this.
|
|
126
|
+
const updated = await updateRuntime(this._client.getToken(), this.podName, from, this._client.getRuntimesRunUrl());
|
|
127
|
+
return new RuntimeDTO(updated, this._client);
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
130
|
* Create a snapshot of this runtime.
|
|
@@ -136,7 +136,7 @@ export class RuntimeDTO {
|
|
|
136
136
|
*/
|
|
137
137
|
async createSnapshot(name, description, stop) {
|
|
138
138
|
this._checkDeleted();
|
|
139
|
-
return await this.
|
|
139
|
+
return await this._client.createSnapshot(this.podName, name, description, stop);
|
|
140
140
|
}
|
|
141
141
|
// ========================================================================
|
|
142
142
|
// Utility Methods
|
|
@@ -116,15 +116,15 @@ export interface ListRuntimeSnapshotsResponse {
|
|
|
116
116
|
*/
|
|
117
117
|
export declare class RuntimeSnapshotDTO {
|
|
118
118
|
protected _data: RuntimeSnapshotData;
|
|
119
|
-
private
|
|
119
|
+
private _client;
|
|
120
120
|
private _deleted;
|
|
121
121
|
/**
|
|
122
122
|
* Create a Runtime Snapshot instance.
|
|
123
123
|
*
|
|
124
124
|
* @param data - Snapshot data from API
|
|
125
|
-
* @param
|
|
125
|
+
* @param client - Client instance
|
|
126
126
|
*/
|
|
127
|
-
constructor(data: RuntimeSnapshotData,
|
|
127
|
+
constructor(data: RuntimeSnapshotData, client: DatalayerClient);
|
|
128
128
|
/**
|
|
129
129
|
* Check if this snapshot has been deleted and throw error if so.
|
|
130
130
|
* @throws Error if deleted
|
|
@@ -16,17 +16,17 @@ import { validateJSON } from '../api/utils/validation';
|
|
|
16
16
|
*/
|
|
17
17
|
export class RuntimeSnapshotDTO {
|
|
18
18
|
_data;
|
|
19
|
-
|
|
19
|
+
_client;
|
|
20
20
|
_deleted = false;
|
|
21
21
|
/**
|
|
22
22
|
* Create a Runtime Snapshot instance.
|
|
23
23
|
*
|
|
24
24
|
* @param data - Snapshot data from API
|
|
25
|
-
* @param
|
|
25
|
+
* @param client - Client instance
|
|
26
26
|
*/
|
|
27
|
-
constructor(data,
|
|
27
|
+
constructor(data, client) {
|
|
28
28
|
this._data = data;
|
|
29
|
-
this.
|
|
29
|
+
this._client = client;
|
|
30
30
|
}
|
|
31
31
|
// ========================================================================
|
|
32
32
|
// Helper Methods
|
|
@@ -77,8 +77,8 @@ export class RuntimeSnapshotDTO {
|
|
|
77
77
|
*/
|
|
78
78
|
async delete() {
|
|
79
79
|
this._checkDeleted();
|
|
80
|
-
const token = this.
|
|
81
|
-
const runtimesRunUrl = this.
|
|
80
|
+
const token = this._client.getToken();
|
|
81
|
+
const runtimesRunUrl = this._client.getRuntimesRunUrl();
|
|
82
82
|
await snapshots.deleteSnapshot(token, this.uid, runtimesRunUrl);
|
|
83
83
|
this._deleted = true;
|
|
84
84
|
}
|
|
@@ -90,7 +90,7 @@ export class RuntimeSnapshotDTO {
|
|
|
90
90
|
*/
|
|
91
91
|
async restore(minutesLimit) {
|
|
92
92
|
this._checkDeleted();
|
|
93
|
-
return await this.
|
|
93
|
+
return await this._client.createRuntime({
|
|
94
94
|
environmentName: this.environment,
|
|
95
95
|
type: 'notebook',
|
|
96
96
|
givenName: `Restored from ${this.name}`,
|
package/lib/models/Secret.d.ts
CHANGED
|
@@ -116,7 +116,7 @@ export interface DeleteSecretResponse {
|
|
|
116
116
|
*
|
|
117
117
|
* @example
|
|
118
118
|
* ```typescript
|
|
119
|
-
* const secret = await
|
|
119
|
+
* const secret = await client.createSecret({
|
|
120
120
|
* variant: 'password',
|
|
121
121
|
* name: 'db_password',
|
|
122
122
|
* description: 'Production DB password',
|
|
@@ -131,14 +131,14 @@ export interface DeleteSecretResponse {
|
|
|
131
131
|
export declare class SecretDTO {
|
|
132
132
|
/** @internal */
|
|
133
133
|
_data: SecretData;
|
|
134
|
-
private
|
|
134
|
+
private _client;
|
|
135
135
|
private _deleted;
|
|
136
136
|
/**
|
|
137
137
|
* Create a Secret instance.
|
|
138
138
|
* @param data - Secret data from API
|
|
139
|
-
* @param
|
|
139
|
+
* @param client - Client instance
|
|
140
140
|
*/
|
|
141
|
-
constructor(data: SecretData,
|
|
141
|
+
constructor(data: SecretData, client: DatalayerClient);
|
|
142
142
|
private _checkDeleted;
|
|
143
143
|
private _decodeValue;
|
|
144
144
|
get uid(): string;
|
package/lib/models/Secret.js
CHANGED
|
@@ -21,7 +21,7 @@ import { validateJSON } from '../api/utils/validation';
|
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```typescript
|
|
24
|
-
* const secret = await
|
|
24
|
+
* const secret = await client.createSecret({
|
|
25
25
|
* variant: 'password',
|
|
26
26
|
* name: 'db_password',
|
|
27
27
|
* description: 'Production DB password',
|
|
@@ -36,16 +36,16 @@ import { validateJSON } from '../api/utils/validation';
|
|
|
36
36
|
export class SecretDTO {
|
|
37
37
|
/** @internal */
|
|
38
38
|
_data;
|
|
39
|
-
|
|
39
|
+
_client;
|
|
40
40
|
_deleted = false;
|
|
41
41
|
/**
|
|
42
42
|
* Create a Secret instance.
|
|
43
43
|
* @param data - Secret data from API
|
|
44
|
-
* @param
|
|
44
|
+
* @param client - Client instance
|
|
45
45
|
*/
|
|
46
|
-
constructor(data,
|
|
46
|
+
constructor(data, client) {
|
|
47
47
|
this._data = data;
|
|
48
|
-
this.
|
|
48
|
+
this._client = client;
|
|
49
49
|
}
|
|
50
50
|
// ========================================================================
|
|
51
51
|
// Helper Methods
|
|
@@ -105,7 +105,7 @@ export class SecretDTO {
|
|
|
105
105
|
*/
|
|
106
106
|
async update(updates) {
|
|
107
107
|
this._checkDeleted();
|
|
108
|
-
const updated = await this.
|
|
108
|
+
const updated = await this._client.updateSecret(this.uid, updates);
|
|
109
109
|
return updated;
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
@@ -113,7 +113,7 @@ export class SecretDTO {
|
|
|
113
113
|
*/
|
|
114
114
|
async delete() {
|
|
115
115
|
this._checkDeleted();
|
|
116
|
-
await this.
|
|
116
|
+
await this._client.deleteSecret(this.uid);
|
|
117
117
|
this._deleted = true;
|
|
118
118
|
}
|
|
119
119
|
// ========================================================================
|
package/lib/models/Space.js
CHANGED
|
@@ -34,6 +34,9 @@ export const asSpace = (raw_space) => {
|
|
|
34
34
|
organization: {
|
|
35
35
|
handle: raw_space.handle_s,
|
|
36
36
|
},
|
|
37
|
+
// Preserve raw Solr fields so consumers can access dynamic fields
|
|
38
|
+
// (e.g. attached_agent_pod_name_s for project-agent assignment)
|
|
39
|
+
...raw_space,
|
|
37
40
|
};
|
|
38
41
|
return space;
|
|
39
42
|
};
|
package/lib/models/SpaceDTO.d.ts
CHANGED
|
@@ -48,16 +48,16 @@ export interface SpaceJSON {
|
|
|
48
48
|
*/
|
|
49
49
|
export declare class SpaceDTO {
|
|
50
50
|
protected _data: SpaceData;
|
|
51
|
-
private
|
|
51
|
+
private _client;
|
|
52
52
|
private _items;
|
|
53
53
|
private _deleted;
|
|
54
54
|
/**
|
|
55
55
|
* Create a Space instance.
|
|
56
56
|
*
|
|
57
57
|
* @param data - Space data from API
|
|
58
|
-
* @param
|
|
58
|
+
* @param client - Client instance
|
|
59
59
|
*/
|
|
60
|
-
constructor(data: SpaceData,
|
|
60
|
+
constructor(data: SpaceData, client: DatalayerClient);
|
|
61
61
|
/**
|
|
62
62
|
* Check if this space has been deleted and throw error if so.
|
|
63
63
|
* @throws Error if deleted
|
package/lib/models/SpaceDTO.js
CHANGED
|
@@ -29,18 +29,18 @@ import { validateJSON } from '../api/utils/validation';
|
|
|
29
29
|
*/
|
|
30
30
|
export class SpaceDTO {
|
|
31
31
|
_data;
|
|
32
|
-
|
|
32
|
+
_client;
|
|
33
33
|
_items = null;
|
|
34
34
|
_deleted = false;
|
|
35
35
|
/**
|
|
36
36
|
* Create a Space instance.
|
|
37
37
|
*
|
|
38
38
|
* @param data - Space data from API
|
|
39
|
-
* @param
|
|
39
|
+
* @param client - Client instance
|
|
40
40
|
*/
|
|
41
|
-
constructor(data,
|
|
41
|
+
constructor(data, client) {
|
|
42
42
|
this._data = data;
|
|
43
|
-
this.
|
|
43
|
+
this._client = client;
|
|
44
44
|
}
|
|
45
45
|
// ========================================================================
|
|
46
46
|
// Helper Methods
|
|
@@ -58,8 +58,8 @@ export class SpaceDTO {
|
|
|
58
58
|
* Refresh space data from the API by fetching user's spaces.
|
|
59
59
|
*/
|
|
60
60
|
async refresh() {
|
|
61
|
-
const token = this.
|
|
62
|
-
const spacerRunUrl = this.
|
|
61
|
+
const token = this._client.getToken();
|
|
62
|
+
const spacerRunUrl = this._client.getSpacerRunUrl();
|
|
63
63
|
const response = await users.getMySpaces(token, spacerRunUrl);
|
|
64
64
|
const freshSpace = response.spaces.find(s => s.uid === this.uid);
|
|
65
65
|
if (freshSpace) {
|
|
@@ -110,8 +110,8 @@ export class SpaceDTO {
|
|
|
110
110
|
async _createItem(data) {
|
|
111
111
|
this._checkDeleted();
|
|
112
112
|
// Get necessary configuration from Client
|
|
113
|
-
const token = this.
|
|
114
|
-
const spacerRunUrl = this.
|
|
113
|
+
const token = this._client.getToken();
|
|
114
|
+
const spacerRunUrl = this._client.getSpacerRunUrl();
|
|
115
115
|
if (data.type === ItemTypes.NOTEBOOK) {
|
|
116
116
|
const requestData = {
|
|
117
117
|
spaceId: this.uid,
|
|
@@ -125,7 +125,7 @@ export class SpaceDTO {
|
|
|
125
125
|
throw new Error('Failed to create notebook: No notebook returned');
|
|
126
126
|
}
|
|
127
127
|
else {
|
|
128
|
-
return new NotebookDTO(response.notebook, this.
|
|
128
|
+
return new NotebookDTO(response.notebook, this._client);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
else if (data.type === ItemTypes.LEXICAL) {
|
|
@@ -141,7 +141,7 @@ export class SpaceDTO {
|
|
|
141
141
|
throw new Error('Failed to create lexical document: No document returned');
|
|
142
142
|
}
|
|
143
143
|
else {
|
|
144
|
-
return new LexicalDTO(response.document, this.
|
|
144
|
+
return new LexicalDTO(response.document, this._client);
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
else {
|
|
@@ -155,11 +155,11 @@ export class SpaceDTO {
|
|
|
155
155
|
*/
|
|
156
156
|
async getItems() {
|
|
157
157
|
this._checkDeleted();
|
|
158
|
-
const token = this.
|
|
159
|
-
const spacerRunUrl = this.
|
|
158
|
+
const token = this._client.getToken();
|
|
159
|
+
const spacerRunUrl = this._client.getSpacerRunUrl();
|
|
160
160
|
const response = await items.getSpaceItems(token, this.uid, spacerRunUrl);
|
|
161
161
|
// Use shared utility function to convert items to model instances
|
|
162
|
-
this._items = convertSpaceItemsToModels(response.items || [], this.
|
|
162
|
+
this._items = convertSpaceItemsToModels(response.items || [], this._client);
|
|
163
163
|
return this._items;
|
|
164
164
|
}
|
|
165
165
|
/**
|
|
@@ -215,7 +215,7 @@ export class SpaceDTO {
|
|
|
215
215
|
variant: this.variant,
|
|
216
216
|
handle: this.handle,
|
|
217
217
|
items: this._data.items
|
|
218
|
-
? convertSpaceItemsToModels(this._data.items, this.
|
|
218
|
+
? convertSpaceItemsToModels(this._data.items, this._client).map(item => item.toJSON())
|
|
219
219
|
: [],
|
|
220
220
|
};
|
|
221
221
|
validateJSON(obj, 'Space');
|
package/lib/models/UserDTO.d.ts
CHANGED
|
@@ -54,9 +54,9 @@ export declare class UserDTO {
|
|
|
54
54
|
* Create a User instance.
|
|
55
55
|
*
|
|
56
56
|
* @param data - User data from API
|
|
57
|
-
* @param
|
|
57
|
+
* @param client - Client instance (currently unused but kept for compatibility)
|
|
58
58
|
*/
|
|
59
|
-
constructor(data: UserData,
|
|
59
|
+
constructor(data: UserData, client?: DatalayerClient);
|
|
60
60
|
get id(): string;
|
|
61
61
|
get uid(): string;
|
|
62
62
|
get email(): string;
|
package/lib/models/UserDTO.js
CHANGED
|
@@ -13,9 +13,9 @@ export class UserDTO {
|
|
|
13
13
|
* Create a User instance.
|
|
14
14
|
*
|
|
15
15
|
* @param data - User data from API
|
|
16
|
-
* @param
|
|
16
|
+
* @param client - Client instance (currently unused but kept for compatibility)
|
|
17
17
|
*/
|
|
18
|
-
constructor(data,
|
|
18
|
+
constructor(data, client) {
|
|
19
19
|
this._data = data;
|
|
20
20
|
}
|
|
21
21
|
// Basic properties
|
|
@@ -74,9 +74,9 @@ const datalayerThemeDefs = {
|
|
|
74
74
|
hoverBg: datalayerColors.greenHover,
|
|
75
75
|
hoverBorder: datalayerColors.greenHover,
|
|
76
76
|
selectedBg: datalayerColors.greenHover,
|
|
77
|
-
disabledText: 'rgba(255, 255, 255, 0.
|
|
78
|
-
disabledBg:
|
|
79
|
-
disabledBorder:
|
|
77
|
+
disabledText: 'rgba(255, 255, 255, 0.8)',
|
|
78
|
+
disabledBg: '#94C9B9',
|
|
79
|
+
disabledBorder: '#94C9B9',
|
|
80
80
|
icon: datalayerColors.white,
|
|
81
81
|
counterBg: 'rgba(0, 0, 0, 0.2)',
|
|
82
82
|
},
|
|
@@ -165,8 +165,8 @@ const datalayerThemeDefs = {
|
|
|
165
165
|
hoverBorder: 'rgba(240, 246, 252, 0.1)',
|
|
166
166
|
selectedBg: datalayerColors.greenBright,
|
|
167
167
|
disabledText: 'rgba(255, 255, 255, 0.5)',
|
|
168
|
-
disabledBg: 'rgba(22, 160, 133, 0.
|
|
169
|
-
disabledBorder: 'rgba(
|
|
168
|
+
disabledBg: 'rgba(22, 160, 133, 0.35)',
|
|
169
|
+
disabledBorder: 'rgba(22, 160, 133, 0.2)',
|
|
170
170
|
icon: datalayerColors.white,
|
|
171
171
|
counterBg: 'rgba(0, 0, 0, 0.2)',
|
|
172
172
|
},
|