@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
|
@@ -15,8 +15,10 @@ import * as items from '../../api/spacer/items.js';
|
|
|
15
15
|
import { NotebookDTO } from '../../models/NotebookDTO.js';
|
|
16
16
|
import { LexicalDTO } from '../../models/LexicalDTO.js';
|
|
17
17
|
import { SpaceDTO } from '../../models/SpaceDTO.js';
|
|
18
|
+
import { ProjectDTO } from '../../models/ProjectDTO.js';
|
|
18
19
|
import { HealthCheck } from '../../models/HealthCheck.js';
|
|
19
20
|
import { convertSpaceItemsToModels } from '../utils/spacerUtils.js';
|
|
21
|
+
import { generateHandle } from '../utils/slugify.js';
|
|
20
22
|
/** Spacer mixin providing workspace and content management. */
|
|
21
23
|
export function SpacerMixin(Base) {
|
|
22
24
|
return class extends Base {
|
|
@@ -336,5 +338,257 @@ export function SpacerMixin(Base) {
|
|
|
336
338
|
}
|
|
337
339
|
return response.sessionId;
|
|
338
340
|
}
|
|
341
|
+
// ========================================================================
|
|
342
|
+
// Additional Space Operations
|
|
343
|
+
// ========================================================================
|
|
344
|
+
/**
|
|
345
|
+
* Get a space by UID.
|
|
346
|
+
* @param uid - Space UID
|
|
347
|
+
* @returns Space instance
|
|
348
|
+
*/
|
|
349
|
+
async getSpace(uid) {
|
|
350
|
+
const token = this.getToken();
|
|
351
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
352
|
+
const response = await spaces.getSpace(token, uid, spacerRunUrl);
|
|
353
|
+
if (!response.space) {
|
|
354
|
+
throw new Error(`Space with UID '${uid}' not found`);
|
|
355
|
+
}
|
|
356
|
+
return new SpaceDTO(response.space, this);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Update a space (owner updating their own space).
|
|
360
|
+
* @param uid - Space UID
|
|
361
|
+
* @param data - Update data (supports arbitrary Solr fields)
|
|
362
|
+
* @returns Updated Space instance
|
|
363
|
+
*/
|
|
364
|
+
async updateSpace(uid, data) {
|
|
365
|
+
const token = this.getToken();
|
|
366
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
367
|
+
const response = await spaces.updateSpace(token, uid, data, spacerRunUrl);
|
|
368
|
+
if (!response.space) {
|
|
369
|
+
throw new Error(`Failed to update space '${uid}'`);
|
|
370
|
+
}
|
|
371
|
+
return new SpaceDTO(response.space, this);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Update a user-specific space (e.g., org admin context).
|
|
375
|
+
* @param uid - Space UID
|
|
376
|
+
* @param userId - User ID
|
|
377
|
+
* @param data - Update data (supports arbitrary Solr fields)
|
|
378
|
+
* @returns Updated Space instance
|
|
379
|
+
*/
|
|
380
|
+
async updateUserSpace(uid, userId, data) {
|
|
381
|
+
const token = this.getToken();
|
|
382
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
383
|
+
const response = await spaces.updateUserSpace(token, uid, userId, data, spacerRunUrl);
|
|
384
|
+
if (!response.space) {
|
|
385
|
+
throw new Error(`Failed to update space '${uid}' for user '${userId}'`);
|
|
386
|
+
}
|
|
387
|
+
return new SpaceDTO(response.space, this);
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Delete a space and all its contents.
|
|
391
|
+
* @param uid - Space UID
|
|
392
|
+
*/
|
|
393
|
+
async deleteSpace(uid) {
|
|
394
|
+
const token = this.getToken();
|
|
395
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
396
|
+
await spaces.deleteSpace(token, uid, spacerRunUrl);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Make a space public.
|
|
400
|
+
* @param uid - Space UID
|
|
401
|
+
* @returns Updated Space instance
|
|
402
|
+
*/
|
|
403
|
+
async makeSpacePublic(uid) {
|
|
404
|
+
const token = this.getToken();
|
|
405
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
406
|
+
const response = await spaces.makeSpacePublic(token, uid, spacerRunUrl);
|
|
407
|
+
if (!response.space) {
|
|
408
|
+
throw new Error(`Failed to make space '${uid}' public`);
|
|
409
|
+
}
|
|
410
|
+
return new SpaceDTO(response.space, this);
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Make a space private.
|
|
414
|
+
* @param uid - Space UID
|
|
415
|
+
* @returns Updated Space instance
|
|
416
|
+
*/
|
|
417
|
+
async makeSpacePrivate(uid) {
|
|
418
|
+
const token = this.getToken();
|
|
419
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
420
|
+
const response = await spaces.makeSpacePrivate(token, uid, spacerRunUrl);
|
|
421
|
+
if (!response.space) {
|
|
422
|
+
throw new Error(`Failed to make space '${uid}' private`);
|
|
423
|
+
}
|
|
424
|
+
return new SpaceDTO(response.space, this);
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Export a space and its contents.
|
|
428
|
+
* @param uid - Space UID
|
|
429
|
+
* @returns Export data
|
|
430
|
+
*/
|
|
431
|
+
async exportSpace(uid) {
|
|
432
|
+
const token = this.getToken();
|
|
433
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
434
|
+
return spaces.exportSpace(token, uid, spacerRunUrl);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Clone a notebook.
|
|
438
|
+
* @param id - Notebook ID to clone
|
|
439
|
+
* @returns Cloned Notebook instance
|
|
440
|
+
*/
|
|
441
|
+
async cloneNotebook(id) {
|
|
442
|
+
const token = this.getToken();
|
|
443
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
444
|
+
const response = await notebooks.cloneNotebook(token, id, spacerRunUrl);
|
|
445
|
+
if (!response.notebook) {
|
|
446
|
+
throw new Error(`Failed to clone notebook '${id}'`);
|
|
447
|
+
}
|
|
448
|
+
return new NotebookDTO(response.notebook, this);
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Clone a lexical document.
|
|
452
|
+
* @param id - Document ID to clone
|
|
453
|
+
* @returns Cloned Lexical instance
|
|
454
|
+
*/
|
|
455
|
+
async cloneLexical(id) {
|
|
456
|
+
const token = this.getToken();
|
|
457
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
458
|
+
const response = await lexicals.cloneLexical(token, id, spacerRunUrl);
|
|
459
|
+
if (!response.document) {
|
|
460
|
+
throw new Error(`Failed to clone lexical document '${id}'`);
|
|
461
|
+
}
|
|
462
|
+
return new LexicalDTO(response.document, this);
|
|
463
|
+
}
|
|
464
|
+
// ========================================================================
|
|
465
|
+
// Projects
|
|
466
|
+
// ========================================================================
|
|
467
|
+
/**
|
|
468
|
+
* Get all projects for the authenticated user.
|
|
469
|
+
* Projects are spaces with variant='project'.
|
|
470
|
+
* @returns Array of Project instances
|
|
471
|
+
*/
|
|
472
|
+
async getProjects() {
|
|
473
|
+
// Use getMySpaces and filter by variant, because the
|
|
474
|
+
// /spaces/types/project endpoint returns empty results.
|
|
475
|
+
const allSpaces = await this.getMySpaces();
|
|
476
|
+
return allSpaces
|
|
477
|
+
.filter(s => s.variant === 'project')
|
|
478
|
+
.map(s => new ProjectDTO(s.rawData()));
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Get a project by UID.
|
|
482
|
+
* @param uid - Project UID
|
|
483
|
+
* @returns Project instance
|
|
484
|
+
*/
|
|
485
|
+
async getProject(uid) {
|
|
486
|
+
const token = this.getToken();
|
|
487
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
488
|
+
const response = await spaces.getSpace(token, uid, spacerRunUrl);
|
|
489
|
+
if (!response.space) {
|
|
490
|
+
throw new Error(`Project with UID '${uid}' not found`);
|
|
491
|
+
}
|
|
492
|
+
return new ProjectDTO(response.space);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Create a new project.
|
|
496
|
+
* @param name - Project name
|
|
497
|
+
* @param description - Project description
|
|
498
|
+
* @returns Created Project instance
|
|
499
|
+
*/
|
|
500
|
+
async createProject(name, description) {
|
|
501
|
+
const token = this.getToken();
|
|
502
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
503
|
+
const spaceHandle = generateHandle(name);
|
|
504
|
+
const data = {
|
|
505
|
+
name,
|
|
506
|
+
description: description || '',
|
|
507
|
+
variant: 'project',
|
|
508
|
+
spaceHandle,
|
|
509
|
+
organizationId: '',
|
|
510
|
+
seedSpaceId: '',
|
|
511
|
+
public: false,
|
|
512
|
+
};
|
|
513
|
+
const response = await spaces.createSpace(token, data, spacerRunUrl);
|
|
514
|
+
if (!response.space) {
|
|
515
|
+
throw new Error('Failed to create project: no project returned');
|
|
516
|
+
}
|
|
517
|
+
return new ProjectDTO(response.space);
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Update a project.
|
|
521
|
+
* @param uid - Project UID
|
|
522
|
+
* @param data - Update data (supports arbitrary Solr fields)
|
|
523
|
+
* @returns Updated Project instance
|
|
524
|
+
*/
|
|
525
|
+
async updateProject(uid, data) {
|
|
526
|
+
const token = this.getToken();
|
|
527
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
528
|
+
// Resolve userId from: IAM mixin cache > AuthenticationManager cache > whoami()
|
|
529
|
+
let resolvedUserId;
|
|
530
|
+
const iamUser = this.currentUserCache;
|
|
531
|
+
if (iamUser) {
|
|
532
|
+
resolvedUserId = iamUser.uid ?? iamUser.id;
|
|
533
|
+
}
|
|
534
|
+
if (!resolvedUserId) {
|
|
535
|
+
const authUser = this.auth?.getCurrentUser?.();
|
|
536
|
+
if (authUser) {
|
|
537
|
+
resolvedUserId = authUser.uid ?? authUser.id;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
if (!resolvedUserId) {
|
|
541
|
+
try {
|
|
542
|
+
const user = await this.whoami();
|
|
543
|
+
resolvedUserId = user?.uid ?? user?.id;
|
|
544
|
+
}
|
|
545
|
+
catch (_e) {
|
|
546
|
+
// whoami() not available — no user context
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
if (!resolvedUserId) {
|
|
550
|
+
throw new Error('Cannot update project: no authenticated user');
|
|
551
|
+
}
|
|
552
|
+
const response = await spaces.updateUserSpace(token, uid, resolvedUserId, data, spacerRunUrl);
|
|
553
|
+
if (response.space) {
|
|
554
|
+
return new ProjectDTO(response.space);
|
|
555
|
+
}
|
|
556
|
+
// Backend returns space: null on success for user-scoped updates.
|
|
557
|
+
// Re-fetch the project to return fresh data.
|
|
558
|
+
const freshResponse = await spaces.getSpace(token, uid, spacerRunUrl);
|
|
559
|
+
if (!freshResponse.space) {
|
|
560
|
+
throw new Error(`Failed to update project '${uid}'`);
|
|
561
|
+
}
|
|
562
|
+
return new ProjectDTO(freshResponse.space);
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Rename a project.
|
|
566
|
+
* @param uid - Project UID
|
|
567
|
+
* @param newName - New project name
|
|
568
|
+
* @param description - Project description to preserve.
|
|
569
|
+
* @param userId - Authenticated user ID for user-scoped update.
|
|
570
|
+
* @returns Updated Project instance
|
|
571
|
+
*/
|
|
572
|
+
async renameProject(uid, newName, description) {
|
|
573
|
+
const data = { name: newName };
|
|
574
|
+
if (description !== undefined) {
|
|
575
|
+
data.description = description;
|
|
576
|
+
}
|
|
577
|
+
return this.updateProject(uid, data);
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Get default items (notebook UID and document UID) for a project.
|
|
581
|
+
* @param uid - Project UID
|
|
582
|
+
* @returns Default notebook and document UIDs
|
|
583
|
+
*/
|
|
584
|
+
async getProjectDefaultItems(uid) {
|
|
585
|
+
const token = this.getToken();
|
|
586
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
587
|
+
const response = await spaces.getSpaceDefaultItems(token, uid, spacerRunUrl);
|
|
588
|
+
return {
|
|
589
|
+
defaultNotebookUid: response.default_notebook_uid,
|
|
590
|
+
defaultDocumentUid: response.default_document_uid,
|
|
591
|
+
};
|
|
592
|
+
}
|
|
339
593
|
};
|
|
340
594
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a URL-friendly handle from a name.
|
|
3
|
+
*
|
|
4
|
+
* @param name - The name to convert to a handle
|
|
5
|
+
* @param fallbackPrefix - Prefix for the fallback handle if name produces empty result
|
|
6
|
+
* @returns URL-friendly handle string
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateHandle(name: string, fallbackPrefix?: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Generate a URL-friendly handle from a name.
|
|
7
|
+
*
|
|
8
|
+
* @param name - The name to convert to a handle
|
|
9
|
+
* @param fallbackPrefix - Prefix for the fallback handle if name produces empty result
|
|
10
|
+
* @returns URL-friendly handle string
|
|
11
|
+
*/
|
|
12
|
+
export function generateHandle(name, fallbackPrefix = 'project') {
|
|
13
|
+
const handle = name
|
|
14
|
+
.toLowerCase()
|
|
15
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
16
|
+
.replace(/^-|-$/g, '');
|
|
17
|
+
return handle || `${fallbackPrefix}-${Date.now()}`;
|
|
18
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Point } from './types';
|
|
2
|
+
export type { Point } from './types';
|
|
1
3
|
/**
|
|
2
4
|
* Get minimum value from array
|
|
3
5
|
*/
|
|
@@ -18,8 +20,4 @@ export interface DataToPointsOptions {
|
|
|
18
20
|
max?: number;
|
|
19
21
|
min?: number;
|
|
20
22
|
}
|
|
21
|
-
export interface Point {
|
|
22
|
-
x: number;
|
|
23
|
-
y: number;
|
|
24
|
-
}
|
|
25
23
|
export declare const dataToPoints: ({ data, limit, width, height, margin, max: maxVal, min: minVal, }: DataToPointsOptions) => Point[];
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
/*
|
|
6
|
-
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
7
|
-
* Distributed under the terms of the Modified BSD License.
|
|
8
|
-
*/
|
|
9
5
|
/**
|
|
10
6
|
* Get minimum value from array
|
|
11
7
|
*/
|
|
@@ -2,3 +2,4 @@ export { Sparklines } from './Sparklines';
|
|
|
2
2
|
export { SparklinesLine } from './SparklinesLine';
|
|
3
3
|
export type { SparklinesProps, SparklinesLineProps, Point } from './types';
|
|
4
4
|
export { dataToPoints, min, max } from './dataProcessing';
|
|
5
|
+
export type { DataToPointsOptions } from './dataProcessing';
|
package/lib/hooks/useCache.js
CHANGED
|
@@ -3249,7 +3249,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
|
|
|
3249
3249
|
};
|
|
3250
3250
|
/**
|
|
3251
3251
|
* Get default items (notebook UID & document UID) for a space / project.
|
|
3252
|
-
* Calls GET /api/spacer/v1/spaces
|
|
3252
|
+
* Calls `GET /api/spacer/v1/spaces/:spaceId/default-items`
|
|
3253
3253
|
*/
|
|
3254
3254
|
const useSpaceDefaultItems = (spaceId) => {
|
|
3255
3255
|
return useQuery({
|
|
@@ -571,17 +571,11 @@ export declare function useRefreshProjects(): import("@tanstack/react-query").Us
|
|
|
571
571
|
* Hook to delete a project (space) and all its contents.
|
|
572
572
|
*/
|
|
573
573
|
export declare function useDeleteProject(): import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
574
|
-
|
|
575
|
-
* Default items (notebook UID and document UID) for a project.
|
|
576
|
-
*/
|
|
577
|
-
export type ProjectDefaultItems = {
|
|
578
|
-
defaultNotebookUid: string | null;
|
|
579
|
-
defaultDocumentUid: string | null;
|
|
580
|
-
};
|
|
574
|
+
export type { ProjectDefaultItems } from '../models/ProjectDTO';
|
|
581
575
|
/**
|
|
582
576
|
* Hook to fetch the default notebook and document UIDs for a project.
|
|
583
577
|
*
|
|
584
|
-
* This calls the spacer `GET /spaces
|
|
578
|
+
* This calls the spacer `GET /spaces/:uid/default-items` endpoint which
|
|
585
579
|
* returns the UID of the first notebook and first document in the space.
|
|
586
580
|
*/
|
|
587
581
|
export declare function useProjectDefaultItems(projectUid: string | undefined): import("@tanstack/react-query").UseQueryResult<{
|
package/lib/hooks/useProjects.js
CHANGED
|
@@ -157,7 +157,7 @@ export function useDeleteProject() {
|
|
|
157
157
|
/**
|
|
158
158
|
* Hook to fetch the default notebook and document UIDs for a project.
|
|
159
159
|
*
|
|
160
|
-
* This calls the spacer `GET /spaces
|
|
160
|
+
* This calls the spacer `GET /spaces/:uid/default-items` endpoint which
|
|
161
161
|
* returns the UID of the first notebook and first document in the space.
|
|
162
162
|
*/
|
|
163
163
|
export function useProjectDefaultItems(projectUid) {
|
package/lib/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { API_BASE_PATHS } from './api/constants';
|
|
|
11
11
|
export * as runtimesApi from './api/runtimes';
|
|
12
12
|
export * as iamApi from './api/iam';
|
|
13
13
|
export * as spacerApi from './api/spacer';
|
|
14
|
-
export { DatalayerClient, type DatalayerClientConfig, type ClientHandlers, User, Runtime, Environment, Snapshot, Space, Notebook, LexicalDTO, Secret, Credits, Item, type RuntimeJSON, type EnvironmentJSON, type UserJSON, type RuntimeData, type EnvironmentData, type UserData, type SpaceData, type SpaceItem, type NotebookData, type LexicalData, type RuntimeSnapshotData, type CreditsInfo, type CreditReservation, type CreateRuntimeRequest, type CreateRuntimeResponse, type ListRuntimesResponse, type ListEnvironmentsResponse, type CreateRuntimeSnapshotRequest, type CreateRuntimeSnapshotResponse, type GetRuntimeSnapshotResponse, type ListRuntimeSnapshotsResponse, type CreateSpaceRequest, type CreateSpaceResponse, type SpacesForUserResponse, type CollaborationSessionResponse, type DeleteSpaceItemResponse, type GetSpaceItemResponse, type GetSpaceItemsResponse, type CreateNotebookRequest, type CreateNotebookResponse, type GetNotebookResponse, type UpdateNotebookRequest, type UpdateNotebookResponse, type CreateLexicalRequest, type CreateLexicalResponse, type GetLexicalResponse, type UpdateLexicalRequest, type UpdateLexicalResponse, type CreditsResponse, type CreateDatasourceResponse, type GetDatasourceResponse, type ListDatasourcesResponse, type UpdateDatasourceResponse, type CreateSecretRequest, type CreateSecretResponse, type GetSecretResponse, type ListSecretsResponse, type UpdateSecretRequest, type UpdateSecretResponse, type SpaceJSON, type NotebookJSON, type LexicalJSON, type RuntimeSnapshotJSON, HealthCheck, type HealthCheckJSON, type LoginRequest, type LoginResponse, type UserMeResponse, type MembershipsResponse, type WhoAmIResponse, type HealthzPingResponse, AuthenticationManager, type IUser, type IBaseUser, type ICell, type IDatasource, type IDatasourceVariant, type ICredits, type ICreditsReservation, type ISpaceItem, type ISurvey, type ISpace, type IBaseSpace, type IAnySpace, type ISpaceVariant, type IBaseTeam, type IAnyTeam, type IOrganization, type IAnyOrganization, type IBaseOrganization, type IRuntimeModel, type IRuntimePod, type IRuntimeType, type IRuntimeLocation, type IRuntimeCapabilities, type IRuntimeSnapshot, type IDatalayerEnvironment, type IResources, type ISnippet, type IRole, type IAssignment, type IContact, type ICourse, type IOrganizationMember, type IPage, type PageTagName, type PageTheme, type PageVariant, type ISecret, type ISecretVariant, type SecretData, type SecretJSON, type DatasourceData, type DatasourceJSON, type DatasourceType, type CreateDatasourceRequest, type UpdateDatasourceRequest, Datasource, type IIAMToken, type IIAMTokenVariant, type IDocument, type IBaseDocument, type IEnvironment, type IExercise, type ICode, type IHelp, type IInvite, type ILesson, type INotebook, type IBaseNotebook, type ISchool, type ITeam, type TeamMember, type IUserOnboarding, type IClient, type IOnboardingPosition, type IOnboardingTours, type ITour, type ITourStatus, type IUserSettings, type IDataset, type IUsage, type IItem, type IItemType, type Member, type Profile, type SpaceMember, type IContactEvent, type IContactIAMProvider, type IStudentItem, type Instructor, type IStudent, type IDean, type IUserEvent, type IIAMProviderLinked, type IContent, type AuthResult, type TokenValidationResult, type AuthOptions, type TokenStorage, type IRuntimeOptions, type IMultiServiceManager, type IRemoteServicesManager, type IEnvironmentsManager, type IRemoteRuntimesManager, type NavigationLinkProps, type IDatalayerCoreConfig, type IRuntimesConfiguration, type IIAMProviderName, } from './client';
|
|
14
|
+
export { DatalayerClient, type DatalayerClientConfig, type ClientHandlers, User, Runtime, Environment, Snapshot, Space, Project, Notebook, LexicalDTO, Secret, Credits, Item, type RuntimeJSON, type EnvironmentJSON, type UserJSON, type RuntimeData, type EnvironmentData, type UserData, type SpaceData, type SpaceItem, type NotebookData, type LexicalData, type RuntimeSnapshotData, type CreditsInfo, type CreditReservation, type CreateRuntimeRequest, type CreateRuntimeResponse, type ListRuntimesResponse, type ListEnvironmentsResponse, type CreateRuntimeSnapshotRequest, type CreateRuntimeSnapshotResponse, type GetRuntimeSnapshotResponse, type ListRuntimeSnapshotsResponse, type CreateSpaceRequest, type CreateSpaceResponse, type SpacesForUserResponse, type CollaborationSessionResponse, type DeleteSpaceItemResponse, type GetSpaceItemResponse, type GetSpaceItemsResponse, type CreateNotebookRequest, type CreateNotebookResponse, type GetNotebookResponse, type UpdateNotebookRequest, type UpdateNotebookResponse, type CreateLexicalRequest, type CreateLexicalResponse, type GetLexicalResponse, type UpdateLexicalRequest, type UpdateLexicalResponse, type CreditsResponse, type CreateDatasourceResponse, type GetDatasourceResponse, type ListDatasourcesResponse, type UpdateDatasourceResponse, type CreateSecretRequest, type CreateSecretResponse, type GetSecretResponse, type ListSecretsResponse, type UpdateSecretRequest, type UpdateSecretResponse, type SpaceJSON, type ProjectJSON, type ProjectDefaultItems, type UpdateSpaceRequest, type GetSpaceResponse, type UpdateSpaceResponse, type DeleteSpaceResponse, type GetSpaceDefaultItemsResponse, type GetSpacesByTypeResponse, type NotebookJSON, type LexicalJSON, type RuntimeSnapshotJSON, HealthCheck, type HealthCheckJSON, type LoginRequest, type LoginResponse, type UserMeResponse, type MembershipsResponse, type WhoAmIResponse, type HealthzPingResponse, AuthenticationManager, type IUser, type IBaseUser, type ICell, type IDatasource, type IDatasourceVariant, type ICredits, type ICreditsReservation, type ISpaceItem, type ISurvey, type ISpace, type IBaseSpace, type IAnySpace, type ISpaceVariant, type IBaseTeam, type IAnyTeam, type IOrganization, type IAnyOrganization, type IBaseOrganization, type IRuntimeModel, type IRuntimePod, type IRuntimeType, type IRuntimeLocation, type IRuntimeCapabilities, type IRuntimeSnapshot, type IDatalayerEnvironment, type IResources, type ISnippet, type IRole, type IAssignment, type IContact, type ICourse, type IOrganizationMember, type IPage, type PageTagName, type PageTheme, type PageVariant, type ISecret, type ISecretVariant, type SecretData, type SecretJSON, type DatasourceData, type DatasourceJSON, type DatasourceType, type CreateDatasourceRequest, type UpdateDatasourceRequest, Datasource, type IIAMToken, type IIAMTokenVariant, type IDocument, type IBaseDocument, type IEnvironment, type IExercise, type ICode, type IHelp, type IInvite, type ILesson, type INotebook, type IBaseNotebook, type ISchool, type ITeam, type TeamMember, type IUserOnboarding, type IClient, type IOnboardingPosition, type IOnboardingTours, type ITour, type ITourStatus, type IUserSettings, type IDataset, type IUsage, type IItem, type IItemType, type Member, type Profile, type SpaceMember, type IContactEvent, type IContactIAMProvider, type IStudentItem, type Instructor, type IStudent, type IDean, type IUserEvent, type IIAMProviderLinked, type IContent, type AuthResult, type TokenValidationResult, type AuthOptions, type TokenStorage, type IRuntimeOptions, type IMultiServiceManager, type IRemoteServicesManager, type IEnvironmentsManager, type IRemoteRuntimesManager, type NavigationLinkProps, type IDatalayerCoreConfig, type IRuntimesConfiguration, type IIAMProviderName, } from './client';
|
|
15
15
|
export { getEnvironments, createRuntime, getRuntimes, deleteRuntime, snapshotRuntime, getRuntimeSnapshots, loadRuntimeSnapshot, } from './stateful/runtimes/actions';
|
|
16
16
|
export * from './otel';
|
|
17
17
|
export * from './views';
|
package/lib/index.js
CHANGED
|
@@ -21,7 +21,7 @@ export {
|
|
|
21
21
|
// Export client and config types
|
|
22
22
|
DatalayerClient,
|
|
23
23
|
// Export domain models
|
|
24
|
-
User, Runtime, Environment, Snapshot, Space, Notebook, LexicalDTO, Secret, Credits, Item, HealthCheck,
|
|
24
|
+
User, Runtime, Environment, Snapshot, Space, Project, Notebook, LexicalDTO, Secret, Credits, Item, HealthCheck,
|
|
25
25
|
// Export auth
|
|
26
26
|
AuthenticationManager, Datasource, } from './client/index.js';
|
|
27
27
|
// Export commonly used functions directly for convenience
|
|
@@ -97,7 +97,7 @@ export declare class EnvironmentDTO {
|
|
|
97
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
|
-
/** Unique name identifier for the environment (e.g., 'ai-env', '
|
|
100
|
+
/** Unique name identifier for the environment (e.g., 'ai-env', 'ai-agents-env'). */
|
|
101
101
|
get name(): string;
|
|
102
102
|
/** Credits consumed per hour for this environment. */
|
|
103
103
|
get burningRate(): number;
|
|
@@ -34,7 +34,7 @@ export class EnvironmentDTO {
|
|
|
34
34
|
get title() {
|
|
35
35
|
return this._data.title;
|
|
36
36
|
}
|
|
37
|
-
/** Unique name identifier for the environment (e.g., 'ai-env', '
|
|
37
|
+
/** Unique name identifier for the environment (e.g., 'ai-env', 'ai-agents-env'). */
|
|
38
38
|
get name() {
|
|
39
39
|
return this._data.name;
|
|
40
40
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project domain model for the Datalayer Client.
|
|
3
|
+
*
|
|
4
|
+
* Projects are spaces with variant='project' that can have attached agents.
|
|
5
|
+
* This is a standalone model (no inheritance from SpaceDTO) to avoid
|
|
6
|
+
* circular dependency issues in the module graph.
|
|
7
|
+
*
|
|
8
|
+
* @module models/ProjectDTO
|
|
9
|
+
*/
|
|
10
|
+
import type { SpaceData } from './SpaceDTO';
|
|
11
|
+
/**
|
|
12
|
+
* Stable public interface for Project data.
|
|
13
|
+
*/
|
|
14
|
+
export interface ProjectJSON {
|
|
15
|
+
uid: string;
|
|
16
|
+
id: string;
|
|
17
|
+
handle: string;
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
variant: string;
|
|
21
|
+
isPublic: boolean;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
attachedAgentPodName: string | null;
|
|
24
|
+
attachedAgentSpecId: string | null;
|
|
25
|
+
attachedAgentGivenName: string | null;
|
|
26
|
+
hasAgent: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Default items (notebook UID and document UID) for a project.
|
|
30
|
+
*/
|
|
31
|
+
export interface ProjectDefaultItems {
|
|
32
|
+
defaultNotebookUid: string | null;
|
|
33
|
+
defaultDocumentUid: string | null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Project domain model wrapping raw space data with project-specific accessors.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const projects = await client.getProjects();
|
|
41
|
+
* const project = projects[0];
|
|
42
|
+
* console.log(project.hasAgent); // false
|
|
43
|
+
* await client.assignAgent(project.uid, 'my-agent-pod');
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare class ProjectDTO {
|
|
47
|
+
private _data;
|
|
48
|
+
private _deleted;
|
|
49
|
+
private _createdAt;
|
|
50
|
+
constructor(data: SpaceData);
|
|
51
|
+
/** Unique identifier for the project. */
|
|
52
|
+
get uid(): string;
|
|
53
|
+
/** Internal numeric/string ID from the backend. Falls back to UID when not present. SDK client methods accept `uid` directly. */
|
|
54
|
+
get id(): string;
|
|
55
|
+
/** URL-friendly handle. */
|
|
56
|
+
get handle(): string;
|
|
57
|
+
/** Project name. */
|
|
58
|
+
get name(): string;
|
|
59
|
+
/** Project description. */
|
|
60
|
+
get description(): string;
|
|
61
|
+
/** Space variant (should be 'project'). */
|
|
62
|
+
get variant(): string;
|
|
63
|
+
/** Whether the project is public. */
|
|
64
|
+
get isPublic(): boolean;
|
|
65
|
+
/** Creation date (stable across calls). */
|
|
66
|
+
get createdAt(): Date;
|
|
67
|
+
/** Attached agent runtime pod name, if any. */
|
|
68
|
+
get attachedAgentPodName(): string | undefined;
|
|
69
|
+
/** Attached agent spec ID (e.g., 'data-acquisition'), if any. */
|
|
70
|
+
get attachedAgentSpecId(): string | undefined;
|
|
71
|
+
/** Human-readable name of the attached agent runtime, if any. */
|
|
72
|
+
get attachedAgentGivenName(): string | undefined;
|
|
73
|
+
/** Whether an agent is currently attached to this project. */
|
|
74
|
+
get hasAgent(): boolean;
|
|
75
|
+
/** Mark this project as deleted. */
|
|
76
|
+
markDeleted(): void;
|
|
77
|
+
/** Whether this project has been deleted. */
|
|
78
|
+
get isDeleted(): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Get project data in camelCase format.
|
|
81
|
+
* @returns Project data with camelCase properties
|
|
82
|
+
*/
|
|
83
|
+
toJSON(): ProjectJSON;
|
|
84
|
+
/** Get raw space data as received from the API. */
|
|
85
|
+
rawData(): SpaceData;
|
|
86
|
+
/** String representation of the project. */
|
|
87
|
+
toString(): string;
|
|
88
|
+
private _checkDeleted;
|
|
89
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Project domain model wrapping raw space data with project-specific accessors.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const projects = await client.getProjects();
|
|
11
|
+
* const project = projects[0];
|
|
12
|
+
* console.log(project.hasAgent); // false
|
|
13
|
+
* await client.assignAgent(project.uid, 'my-agent-pod');
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export class ProjectDTO {
|
|
17
|
+
_data;
|
|
18
|
+
_deleted = false;
|
|
19
|
+
_createdAt;
|
|
20
|
+
constructor(data) {
|
|
21
|
+
this._data = data;
|
|
22
|
+
// Cache creation date at construction to ensure stable value
|
|
23
|
+
this._createdAt = data.creation_ts_dt
|
|
24
|
+
? new Date(data.creation_ts_dt)
|
|
25
|
+
: new Date();
|
|
26
|
+
}
|
|
27
|
+
/** Unique identifier for the project. */
|
|
28
|
+
get uid() {
|
|
29
|
+
this._checkDeleted();
|
|
30
|
+
return this._data.uid;
|
|
31
|
+
}
|
|
32
|
+
/** Internal numeric/string ID from the backend. Falls back to UID when not present. SDK client methods accept `uid` directly. */
|
|
33
|
+
get id() {
|
|
34
|
+
this._checkDeleted();
|
|
35
|
+
return this._data.id ?? this._data.uid;
|
|
36
|
+
}
|
|
37
|
+
/** URL-friendly handle. */
|
|
38
|
+
get handle() {
|
|
39
|
+
this._checkDeleted();
|
|
40
|
+
return this._data.handle_s;
|
|
41
|
+
}
|
|
42
|
+
/** Project name. */
|
|
43
|
+
get name() {
|
|
44
|
+
this._checkDeleted();
|
|
45
|
+
return this._data.name_t;
|
|
46
|
+
}
|
|
47
|
+
/** Project description. */
|
|
48
|
+
get description() {
|
|
49
|
+
this._checkDeleted();
|
|
50
|
+
return this._data.description_t ?? '';
|
|
51
|
+
}
|
|
52
|
+
/** Space variant (should be 'project'). */
|
|
53
|
+
get variant() {
|
|
54
|
+
this._checkDeleted();
|
|
55
|
+
return this._data.variant_s;
|
|
56
|
+
}
|
|
57
|
+
/** Whether the project is public. */
|
|
58
|
+
get isPublic() {
|
|
59
|
+
this._checkDeleted();
|
|
60
|
+
return this._data.public_b ?? false;
|
|
61
|
+
}
|
|
62
|
+
/** Creation date (stable across calls). */
|
|
63
|
+
get createdAt() {
|
|
64
|
+
this._checkDeleted();
|
|
65
|
+
return this._createdAt;
|
|
66
|
+
}
|
|
67
|
+
/** Attached agent runtime pod name, if any. */
|
|
68
|
+
get attachedAgentPodName() {
|
|
69
|
+
this._checkDeleted();
|
|
70
|
+
return this._data.attached_agent_pod_name_s || undefined;
|
|
71
|
+
}
|
|
72
|
+
/** Attached agent spec ID (e.g., 'data-acquisition'), if any. */
|
|
73
|
+
get attachedAgentSpecId() {
|
|
74
|
+
this._checkDeleted();
|
|
75
|
+
return this._data.attached_agent_spec_id_s || undefined;
|
|
76
|
+
}
|
|
77
|
+
/** Human-readable name of the attached agent runtime, if any. */
|
|
78
|
+
get attachedAgentGivenName() {
|
|
79
|
+
this._checkDeleted();
|
|
80
|
+
return this._data.attached_agent_given_name_s || undefined;
|
|
81
|
+
}
|
|
82
|
+
/** Whether an agent is currently attached to this project. */
|
|
83
|
+
get hasAgent() {
|
|
84
|
+
this._checkDeleted();
|
|
85
|
+
return !!this._data.attached_agent_pod_name_s;
|
|
86
|
+
}
|
|
87
|
+
/** Mark this project as deleted. */
|
|
88
|
+
markDeleted() {
|
|
89
|
+
this._deleted = true;
|
|
90
|
+
}
|
|
91
|
+
/** Whether this project has been deleted. */
|
|
92
|
+
get isDeleted() {
|
|
93
|
+
return this._deleted;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get project data in camelCase format.
|
|
97
|
+
* @returns Project data with camelCase properties
|
|
98
|
+
*/
|
|
99
|
+
toJSON() {
|
|
100
|
+
this._checkDeleted();
|
|
101
|
+
return {
|
|
102
|
+
uid: this.uid,
|
|
103
|
+
id: this.id,
|
|
104
|
+
handle: this.handle,
|
|
105
|
+
name: this.name,
|
|
106
|
+
description: this.description,
|
|
107
|
+
variant: this.variant,
|
|
108
|
+
isPublic: this.isPublic,
|
|
109
|
+
createdAt: this.createdAt.toISOString(),
|
|
110
|
+
attachedAgentPodName: this.attachedAgentPodName ?? null,
|
|
111
|
+
attachedAgentSpecId: this.attachedAgentSpecId ?? null,
|
|
112
|
+
attachedAgentGivenName: this.attachedAgentGivenName ?? null,
|
|
113
|
+
hasAgent: this.hasAgent,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/** Get raw space data as received from the API. */
|
|
117
|
+
rawData() {
|
|
118
|
+
this._checkDeleted();
|
|
119
|
+
return this._data;
|
|
120
|
+
}
|
|
121
|
+
/** String representation of the project. */
|
|
122
|
+
toString() {
|
|
123
|
+
this._checkDeleted();
|
|
124
|
+
return `Project(${this._data.uid}, ${this._data.name_t})`;
|
|
125
|
+
}
|
|
126
|
+
_checkDeleted() {
|
|
127
|
+
if (this._deleted) {
|
|
128
|
+
throw new Error(`Project ${this._data.uid} has been deleted and no longer exists`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|