@datalayer/core 0.0.9 → 0.0.11
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/__tests__/shared/cleanup-shared.d.ts +4 -0
- package/lib/__tests__/shared/cleanup-shared.js +228 -0
- package/lib/__tests__/shared/test-config.d.ts +51 -0
- package/lib/__tests__/shared/test-config.js +110 -0
- package/lib/__tests__/shared/test-constants.d.ts +66 -0
- package/lib/__tests__/shared/test-constants.js +79 -0
- package/lib/api/DatalayerApi.d.ts +1 -1
- package/lib/api/DatalayerApi.js +73 -42
- package/lib/api/__tests__/iam.authentication.integration.test.d.ts +1 -0
- package/lib/api/__tests__/iam.authentication.integration.test.js +247 -0
- package/lib/api/__tests__/iam.healthz.integration.test.d.ts +1 -0
- package/lib/api/__tests__/iam.healthz.integration.test.js +63 -0
- package/lib/api/__tests__/iam.profile.integration.test.d.ts +1 -0
- package/lib/api/__tests__/iam.profile.integration.test.js +252 -0
- package/lib/api/__tests__/runtimes.environments.integration.test.d.ts +1 -0
- package/lib/api/__tests__/runtimes.environments.integration.test.js +122 -0
- package/lib/api/__tests__/runtimes.healthz.integration.test.d.ts +1 -0
- package/lib/api/__tests__/runtimes.healthz.integration.test.js +50 -0
- package/lib/api/__tests__/runtimes.integration.test.d.ts +1 -0
- package/lib/api/__tests__/runtimes.integration.test.js +369 -0
- package/lib/api/__tests__/spacer.healthz.integration.test.d.ts +1 -0
- package/lib/api/__tests__/spacer.healthz.integration.test.js +50 -0
- package/lib/api/__tests__/spacer.integration.test.d.ts +1 -0
- package/lib/api/__tests__/spacer.integration.test.js +519 -0
- package/lib/api/constants.d.ts +19 -0
- package/lib/api/constants.js +23 -0
- package/lib/api/iam/__tests__/authentication.unit.test.d.ts +1 -0
- package/lib/api/iam/__tests__/authentication.unit.test.js +63 -0
- package/lib/api/iam/__tests__/healthz.unit.test.d.ts +1 -0
- package/lib/api/iam/__tests__/healthz.unit.test.js +60 -0
- package/lib/api/iam/__tests__/profile.unit.test.d.ts +1 -0
- package/lib/api/iam/__tests__/profile.unit.test.js +57 -0
- package/lib/api/iam/authentication.d.ts +40 -0
- package/lib/api/iam/authentication.js +128 -0
- package/lib/api/iam/healthz.d.ts +15 -0
- package/lib/api/iam/healthz.js +43 -0
- package/lib/api/iam/index.d.ts +12 -0
- package/lib/api/iam/index.js +17 -0
- package/lib/api/iam/profile.d.ts +15 -0
- package/lib/api/iam/profile.js +41 -0
- package/lib/api/index.d.ts +20 -3
- package/lib/api/index.js +22 -3
- package/lib/api/runtimes/__tests__/environments.unit.test.d.ts +1 -0
- package/lib/api/runtimes/__tests__/environments.unit.test.js +77 -0
- package/lib/api/runtimes/__tests__/healthz.unit.test.d.ts +1 -0
- package/lib/api/runtimes/__tests__/healthz.unit.test.js +57 -0
- package/lib/api/runtimes/__tests__/runtimes.unit.test.d.ts +1 -0
- package/lib/api/runtimes/__tests__/runtimes.unit.test.js +139 -0
- package/lib/api/runtimes/__tests__/snapshots.unit.test.d.ts +1 -0
- package/lib/api/runtimes/__tests__/snapshots.unit.test.js +96 -0
- package/lib/api/runtimes/environments.d.ts +9 -0
- package/lib/api/runtimes/environments.js +28 -0
- package/lib/api/runtimes/healthz.d.ts +25 -0
- package/lib/api/runtimes/healthz.js +43 -0
- package/lib/api/runtimes/index.d.ts +10 -5
- package/lib/api/runtimes/index.js +10 -5
- package/lib/api/runtimes/runtimes.d.ts +54 -0
- package/lib/api/runtimes/runtimes.js +169 -0
- package/lib/api/runtimes/snapshots.d.ts +34 -21
- package/lib/api/runtimes/snapshots.js +69 -138
- package/lib/api/spacer/__tests__/healthz.unit.test.d.ts +1 -0
- package/lib/api/spacer/__tests__/healthz.unit.test.js +57 -0
- package/lib/api/spacer/__tests__/items.unit.test.d.ts +1 -0
- package/lib/api/spacer/__tests__/items.unit.test.js +165 -0
- package/lib/api/spacer/__tests__/lexicals.unit.test.d.ts +1 -0
- package/lib/api/spacer/__tests__/lexicals.unit.test.js +323 -0
- package/lib/api/spacer/__tests__/notebooks.unit.test.d.ts +1 -0
- package/lib/api/spacer/__tests__/notebooks.unit.test.js +224 -0
- package/lib/api/spacer/__tests__/users.unit.test.d.ts +1 -0
- package/lib/api/spacer/__tests__/users.unit.test.js +132 -0
- package/lib/api/spacer/healthz.d.ts +25 -0
- package/lib/api/spacer/healthz.js +43 -0
- package/lib/api/spacer/index.d.ts +13 -0
- package/lib/api/spacer/index.js +17 -0
- package/lib/api/spacer/items.d.ts +17 -0
- package/lib/api/spacer/items.js +40 -0
- package/lib/api/spacer/lexicals.d.ts +26 -0
- package/lib/api/spacer/lexicals.js +74 -0
- package/lib/api/spacer/notebooks.d.ts +26 -0
- package/lib/api/spacer/notebooks.js +74 -0
- package/lib/api/spacer/spaces.d.ts +9 -0
- package/lib/api/spacer/spaces.js +29 -0
- package/lib/api/spacer/users.d.ts +9 -0
- package/lib/api/spacer/users.js +28 -0
- package/lib/api/types/iam.d.ts +180 -0
- package/lib/api/types/index.d.ts +32 -0
- package/lib/api/types/index.js +36 -0
- package/lib/api/types/runtimes.d.ts +235 -0
- package/lib/api/types/runtimes.js +5 -0
- package/lib/api/types/spacer.d.ts +271 -0
- package/lib/api/types/spacer.js +5 -0
- package/lib/api/utils/__tests__/validation.test.d.ts +1 -0
- package/lib/api/utils/__tests__/validation.test.js +109 -0
- package/lib/api/utils/validation.d.ts +24 -0
- package/lib/api/utils/validation.js +133 -0
- package/lib/components/display/JupyterDialog.js +4 -8
- package/lib/components/progress/CreditsIndicator.d.ts +1 -1
- package/lib/components/runtimes/RuntimeCellVariablesDialog.js +2 -2
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +1 -1
- package/lib/components/runtimes/RuntimeLauncherDialog.js +5 -2
- package/lib/components/runtimes/RuntimePickerBase.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerBase.js +1 -1
- package/lib/components/runtimes/RuntimePickerCell.js +2 -1
- package/lib/components/runtimes/RuntimePickerNotebook.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerNotebook.js +1 -1
- package/lib/components/runtimes/RuntimeSimplePicker.js +2 -1
- package/lib/components/runtimes/RuntimeTransfer.d.ts +1 -1
- package/lib/components/runtimes/RuntimeUtils.d.ts +1 -1
- package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -1
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +2 -2
- package/lib/components/snippets/SnippetDialog.js +1 -1
- package/lib/components/storage/ContentsBrowser.js +2 -2
- package/lib/components/tables/DataTable.js +2 -1
- package/lib/hooks/useDatalayer.d.ts +1 -1
- package/lib/hooks/useDatalayer.js +1 -1
- package/lib/hooks/useIAM.js +1 -1
- package/lib/hooks/useRuntimes.js +1 -1
- package/lib/index.d.ts +9 -0
- package/lib/index.js +10 -0
- package/lib/sdk/client/__tests__/sdk.health.integration.test.d.ts +1 -0
- package/lib/sdk/client/__tests__/sdk.health.integration.test.js +110 -0
- package/lib/sdk/client/__tests__/sdk.iam.integration.test.d.ts +1 -0
- package/lib/sdk/client/__tests__/sdk.iam.integration.test.js +179 -0
- package/lib/sdk/client/__tests__/sdk.models.integration.test.d.ts +1 -0
- package/lib/sdk/client/__tests__/sdk.models.integration.test.js +376 -0
- package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.d.ts +1 -0
- package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.js +276 -0
- package/lib/sdk/client/__tests__/sdk.spacer.integration.test.d.ts +1 -0
- package/lib/sdk/client/__tests__/sdk.spacer.integration.test.js +361 -0
- package/lib/sdk/client/base.d.ts +88 -0
- package/lib/sdk/client/base.js +112 -0
- package/lib/sdk/client/index.d.ts +192 -0
- package/lib/sdk/client/index.js +128 -0
- package/lib/sdk/client/mixins/HealthMixin.d.ts +100 -0
- package/lib/sdk/client/mixins/HealthMixin.js +133 -0
- package/lib/sdk/client/mixins/IAMMixin.d.ts +59 -0
- package/lib/sdk/client/mixins/IAMMixin.js +83 -0
- package/lib/sdk/client/mixins/RuntimesMixin.d.ts +134 -0
- package/lib/sdk/client/mixins/RuntimesMixin.js +221 -0
- package/lib/sdk/client/mixins/SpacerMixin.d.ts +184 -0
- package/lib/sdk/client/mixins/SpacerMixin.js +278 -0
- package/lib/sdk/client/models/Lexical.d.ts +156 -0
- package/lib/sdk/client/models/Lexical.js +275 -0
- package/lib/sdk/client/models/Notebook.d.ts +174 -0
- package/lib/sdk/client/models/Notebook.js +311 -0
- package/lib/sdk/client/models/Runtime.d.ts +221 -0
- package/lib/sdk/client/models/Runtime.js +341 -0
- package/lib/sdk/client/models/Snapshot.d.ts +156 -0
- package/lib/sdk/client/models/Snapshot.js +244 -0
- package/lib/sdk/client/models/Space.d.ts +182 -0
- package/lib/sdk/client/models/Space.js +276 -0
- package/lib/sdk/client/models/__tests__/Lexical.test.d.ts +1 -0
- package/lib/sdk/client/models/__tests__/Lexical.test.js +288 -0
- package/lib/sdk/client/models/__tests__/Notebook.test.d.ts +1 -0
- package/lib/sdk/client/models/__tests__/Notebook.test.js +206 -0
- package/lib/sdk/client/models/__tests__/Runtime.test.d.ts +1 -0
- package/lib/sdk/client/models/__tests__/Runtime.test.js +133 -0
- package/lib/sdk/client/models/__tests__/Snapshot.test.d.ts +1 -0
- package/lib/sdk/client/models/__tests__/Snapshot.test.js +244 -0
- package/lib/sdk/client/models/__tests__/Space.test.d.ts +1 -0
- package/lib/sdk/client/models/__tests__/Space.test.js +334 -0
- package/lib/sdk/client/models/index.d.ts +30 -0
- package/lib/sdk/client/models/index.js +30 -0
- package/lib/sdk/client/utils/mixins.d.ts +42 -0
- package/lib/sdk/client/utils/mixins.js +47 -0
- package/lib/sdk/index.d.ts +26 -0
- package/lib/sdk/index.js +32 -0
- package/lib/sdk/stateful/index.d.ts +3 -0
- package/lib/sdk/stateful/index.js +7 -0
- package/lib/{api → sdk/stateful}/runtimes/actions.d.ts +1 -1
- package/lib/{api → sdk/stateful}/runtimes/actions.js +3 -3
- package/lib/{api → sdk/stateful}/runtimes/apis.d.ts +1 -1
- package/lib/sdk/stateful/runtimes/apis.js +5 -0
- package/lib/sdk/stateful/runtimes/index.d.ts +5 -0
- package/lib/sdk/stateful/runtimes/index.js +9 -0
- package/lib/sdk/stateful/runtimes/snapshots.d.ts +25 -0
- package/lib/sdk/stateful/runtimes/snapshots.js +150 -0
- package/lib/services/DatalayerServiceManager.js +1 -1
- package/lib/state/substates/IAMState.js +1 -1
- package/lib/state/substates/RuntimesState.d.ts +1 -1
- package/lib/state/substates/RuntimesState.js +1 -1
- package/lib/state/substates/SurveysState.js +1 -1
- package/lib/test-setup.js +1 -0
- package/package.json +19 -9
- /package/lib/api/{runtimes/apis.js → types/iam.js} +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/Python.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/Python.js +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/Snippets.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/Snippets.js +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/index.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/exec/index.js +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/index.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/index.js +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/kernelsHandler.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/jupyter/kernelsHandler.js +0 -0
- /package/lib/{api → sdk/stateful}/runtimes/settings.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/runtimes/settings.js +0 -0
- /package/lib/{api → sdk/stateful}/runtimes/utils.d.ts +0 -0
- /package/lib/{api → sdk/stateful}/runtimes/utils.js +0 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module sdk/client/mixins/SpacerMixin
|
|
7
|
+
* @description Spacer mixin for the Datalayer SDK.
|
|
8
|
+
*
|
|
9
|
+
* This mixin provides intuitive methods for managing workspaces, notebooks,
|
|
10
|
+
* and content that are mixed into the main DatalayerSDK class.
|
|
11
|
+
*/
|
|
12
|
+
import { spaces, notebooks, users, lexicals, items } from '../../../api/spacer';
|
|
13
|
+
import { Notebook } from '../models/Notebook';
|
|
14
|
+
import { Lexical } from '../models/Lexical';
|
|
15
|
+
import { Space } from '../models/Space';
|
|
16
|
+
/**
|
|
17
|
+
* Spacer mixin that provides workspace and content management.
|
|
18
|
+
*
|
|
19
|
+
* This mixin is applied to the DatalayerSDK class to provide clean, intuitive
|
|
20
|
+
* methods for managing spaces, notebooks, and cells.
|
|
21
|
+
*/
|
|
22
|
+
export function SpacerMixin(Base) {
|
|
23
|
+
return class extends Base {
|
|
24
|
+
// ========================================================================
|
|
25
|
+
// User
|
|
26
|
+
// ========================================================================
|
|
27
|
+
/**
|
|
28
|
+
* Get all workspaces for the authenticated user.
|
|
29
|
+
*
|
|
30
|
+
* @returns Promise resolving to array of Space instances
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const mySpaces = await sdk.getMySpaces();
|
|
35
|
+
* console.log('My spaces:', mySpaces.length);
|
|
36
|
+
* for (const space of mySpaces) {
|
|
37
|
+
* const name = await space.getName();
|
|
38
|
+
* console.log(`- ${name} (${space.visibility})`);
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
async getMySpaces() {
|
|
43
|
+
const token = this.getToken();
|
|
44
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
45
|
+
const response = await users.getMySpaces(token, spacerRunUrl);
|
|
46
|
+
return response.spaces.map(s => new Space(s, this));
|
|
47
|
+
}
|
|
48
|
+
// ========================================================================
|
|
49
|
+
// Spaces
|
|
50
|
+
// ========================================================================
|
|
51
|
+
/**
|
|
52
|
+
* Create a new workspace.
|
|
53
|
+
*
|
|
54
|
+
* @param data - Space creation parameters
|
|
55
|
+
* @returns Promise resolving to created Space instance
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const space = await sdk.createSpace({
|
|
60
|
+
* name: 'My Research Project',
|
|
61
|
+
* description: 'Data analysis workspace',
|
|
62
|
+
* variant: 'default',
|
|
63
|
+
* spaceHandle: 'research-project',
|
|
64
|
+
* organizationId: 'org-123',
|
|
65
|
+
* seedSpaceId: 'seed-456',
|
|
66
|
+
* public: false
|
|
67
|
+
* });
|
|
68
|
+
* const name = await space.getName();
|
|
69
|
+
* console.log('Space created:', name);
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
async createSpace(data) {
|
|
73
|
+
const token = this.getToken();
|
|
74
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
75
|
+
const response = await spaces.createSpace(token, data, spacerRunUrl);
|
|
76
|
+
return new Space(response.space, this);
|
|
77
|
+
}
|
|
78
|
+
// ========================================================================
|
|
79
|
+
// Notebooks
|
|
80
|
+
// ========================================================================
|
|
81
|
+
// ========================================================================
|
|
82
|
+
// Helper Functions
|
|
83
|
+
// ========================================================================
|
|
84
|
+
_extractNotebookId(notebookIdOrInstance) {
|
|
85
|
+
return typeof notebookIdOrInstance === 'string'
|
|
86
|
+
? notebookIdOrInstance
|
|
87
|
+
: notebookIdOrInstance.uid;
|
|
88
|
+
}
|
|
89
|
+
_extractLexicalId(lexicalIdOrInstance) {
|
|
90
|
+
return typeof lexicalIdOrInstance === 'string'
|
|
91
|
+
? lexicalIdOrInstance
|
|
92
|
+
: lexicalIdOrInstance.uid;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Create a new notebook.
|
|
96
|
+
*
|
|
97
|
+
* @param data - Notebook creation parameters
|
|
98
|
+
* @returns Promise resolving to created Notebook instance
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const notebook = await sdk.createNotebook({
|
|
103
|
+
* spaceId: 'space-123',
|
|
104
|
+
* name: 'Data Analysis',
|
|
105
|
+
* description: 'Analysis notebook',
|
|
106
|
+
* notebookType: 'jupyter',
|
|
107
|
+
* });
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
async createNotebook(data) {
|
|
111
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
112
|
+
const token = this.getToken();
|
|
113
|
+
const response = await notebooks.createNotebook(token, data, spacerRunUrl);
|
|
114
|
+
return new Notebook(response.notebook, this);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get a notebook by ID or Notebook instance.
|
|
118
|
+
*
|
|
119
|
+
* @param idOrNotebook - Notebook ID (string) or Notebook instance
|
|
120
|
+
* @returns Promise resolving to Notebook instance
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const notebook = await sdk.getNotebook('notebook-123');
|
|
125
|
+
* const refreshed = await sdk.getNotebook(notebook);
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
async getNotebook(idOrNotebook) {
|
|
129
|
+
const notebookId = this._extractNotebookId(idOrNotebook);
|
|
130
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
131
|
+
const token = this.getToken();
|
|
132
|
+
const response = await notebooks.getNotebook(token, notebookId, spacerRunUrl);
|
|
133
|
+
if (!response.notebook) {
|
|
134
|
+
throw new Error(`Notebook with ID '${notebookId}' not found`);
|
|
135
|
+
}
|
|
136
|
+
return new Notebook(response.notebook, this);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Update a notebook.
|
|
140
|
+
*
|
|
141
|
+
* @param idOrNotebook - Notebook ID (string) or Notebook instance
|
|
142
|
+
* @param data - Update data with optional name and/or description
|
|
143
|
+
* @returns Promise resolving to updated Notebook instance
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* const updated = await sdk.updateNotebook('notebook-123', {
|
|
148
|
+
* name: 'Updated Analysis',
|
|
149
|
+
* description: 'Updated description'
|
|
150
|
+
* });
|
|
151
|
+
* const updated2 = await sdk.updateNotebook(notebook, {
|
|
152
|
+
* name: 'Updated Analysis',
|
|
153
|
+
* description: 'Updated description'
|
|
154
|
+
* });
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
async updateNotebook(idOrNotebook, data) {
|
|
158
|
+
const notebookId = this._extractNotebookId(idOrNotebook);
|
|
159
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
160
|
+
const token = this.getToken();
|
|
161
|
+
const response = await notebooks.updateNotebook(token, notebookId, data, spacerRunUrl);
|
|
162
|
+
return new Notebook(response.notebook, this);
|
|
163
|
+
}
|
|
164
|
+
// ========================================================================
|
|
165
|
+
// Lexicals
|
|
166
|
+
// ========================================================================
|
|
167
|
+
/**
|
|
168
|
+
* Create a new lexical document.
|
|
169
|
+
*
|
|
170
|
+
* @param data - Document creation parameters
|
|
171
|
+
* @returns Promise resolving to created Lexical instance
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* const lexical = await sdk.createLexical({
|
|
176
|
+
* spaceId: 'space-123',
|
|
177
|
+
* name: 'Project Documentation',
|
|
178
|
+
* description: 'Main project docs',
|
|
179
|
+
* documentType: 'document',
|
|
180
|
+
* });
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
async createLexical(data) {
|
|
184
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
185
|
+
const token = this.getToken();
|
|
186
|
+
const response = await lexicals.createLexical(token, data, spacerRunUrl);
|
|
187
|
+
return new Lexical(response.document, this);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Get a lexical document by ID or Lexical instance.
|
|
191
|
+
*
|
|
192
|
+
* @param idOrLexical - Document ID (string) or Lexical instance
|
|
193
|
+
* @returns Promise resolving to Lexical instance
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const lexical = await sdk.getLexical('lexical-123');
|
|
198
|
+
* const refreshed = await sdk.getLexical(lexical);
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
async getLexical(idOrLexical) {
|
|
202
|
+
const lexicalId = this._extractLexicalId(idOrLexical);
|
|
203
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
204
|
+
const token = this.getToken();
|
|
205
|
+
const response = await lexicals.getLexical(token, lexicalId, spacerRunUrl);
|
|
206
|
+
if (!response.document) {
|
|
207
|
+
throw new Error(`Lexical document with ID '${lexicalId}' not found`);
|
|
208
|
+
}
|
|
209
|
+
return new Lexical(response.document, this);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Update a lexical document.
|
|
213
|
+
*
|
|
214
|
+
* @param idOrLexical - Document ID (string) or Lexical instance
|
|
215
|
+
* @param data - Update data with optional name and/or description
|
|
216
|
+
* @returns Promise resolving to updated Lexical instance
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* const updated = await sdk.updateLexical('lexical-123', {
|
|
221
|
+
* name: 'Updated Documentation',
|
|
222
|
+
* description: 'Updated description'
|
|
223
|
+
* });
|
|
224
|
+
* const updated2 = await sdk.updateLexical(lexical, {
|
|
225
|
+
* name: 'Updated Documentation',
|
|
226
|
+
* description: 'Updated description'
|
|
227
|
+
* });
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
async updateLexical(idOrLexical, data) {
|
|
231
|
+
const lexicalId = this._extractLexicalId(idOrLexical);
|
|
232
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
233
|
+
const token = this.getToken();
|
|
234
|
+
const response = await lexicals.updateLexical(token, lexicalId, data, spacerRunUrl);
|
|
235
|
+
return new Lexical(response.document, this);
|
|
236
|
+
}
|
|
237
|
+
// ========================================================================
|
|
238
|
+
// Items
|
|
239
|
+
// ========================================================================
|
|
240
|
+
/**
|
|
241
|
+
* Get the items of a space.
|
|
242
|
+
*
|
|
243
|
+
* @param spaceId - Space ID
|
|
244
|
+
* @returns Promise resolving to space items
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* const response = await sdk.getSpaceItems('space-123');
|
|
249
|
+
* console.log('Space items:', response.items.length);
|
|
250
|
+
* response.items.forEach(item => {
|
|
251
|
+
* console.log(`- ${item.name} (${item.type})`);
|
|
252
|
+
* });
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
async getSpaceItems(spaceId) {
|
|
256
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
257
|
+
const token = this.getToken();
|
|
258
|
+
return await items.getSpaceItems(token, spaceId, spacerRunUrl);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Delete an item from a space.
|
|
262
|
+
*
|
|
263
|
+
* @param itemId - Item ID to delete
|
|
264
|
+
* @returns Promise resolving when deletion is complete
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```typescript
|
|
268
|
+
* const response = await sdk.deleteSpaceItem('item-123');
|
|
269
|
+
* console.log('Item deleted:', response.message);
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
async deleteSpaceItem(itemId) {
|
|
273
|
+
const spacerRunUrl = this.getSpacerRunUrl();
|
|
274
|
+
const token = this.getToken();
|
|
275
|
+
return await items.deleteItem(token, itemId, spacerRunUrl);
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/client/models/Lexical
|
|
3
|
+
* @description Lexical domain model for the Datalayer SDK.
|
|
4
|
+
*
|
|
5
|
+
* This model provides a rich, object-oriented interface for working with
|
|
6
|
+
* Lexical documents, including content management and lifecycle operations.
|
|
7
|
+
*/
|
|
8
|
+
import type { Lexical as LexicalData, UpdateLexicalRequest } from '../../../api/types/spacer';
|
|
9
|
+
import type { DatalayerSDK } from '../index';
|
|
10
|
+
/**
|
|
11
|
+
* Lexical domain model that wraps API responses with convenient methods.
|
|
12
|
+
*
|
|
13
|
+
* Provides a rich, object-oriented interface for managing Lexical documents
|
|
14
|
+
* with automatic data refresh and lifecycle operations.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const formData = new FormData();
|
|
19
|
+
* formData.append('spaceId', 'space-123');
|
|
20
|
+
* formData.append('name', 'Project Documentation');
|
|
21
|
+
* const lexical = await sdk.createLexical(formData);
|
|
22
|
+
*
|
|
23
|
+
* // Static properties - instant access
|
|
24
|
+
* console.log(lexical.id);
|
|
25
|
+
* console.log(lexical.spaceId);
|
|
26
|
+
*
|
|
27
|
+
* // Dynamic data - always fresh from API
|
|
28
|
+
* const currentName = await lexical.getName();
|
|
29
|
+
* const content = await lexical.getContent();
|
|
30
|
+
*
|
|
31
|
+
* // Update document
|
|
32
|
+
* const updated = await lexical.update({ name: 'Updated Documentation' });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare class Lexical {
|
|
36
|
+
protected _data: LexicalData;
|
|
37
|
+
private _sdk;
|
|
38
|
+
private _deleted;
|
|
39
|
+
private _freshData;
|
|
40
|
+
private _lastFetch;
|
|
41
|
+
private _cacheTimeout;
|
|
42
|
+
/**
|
|
43
|
+
* Create a Lexical instance.
|
|
44
|
+
*
|
|
45
|
+
* @param data - Raw lexical data from API
|
|
46
|
+
* @param sdk - DatalayerSDK instance for making API calls
|
|
47
|
+
*/
|
|
48
|
+
constructor(data: LexicalData, sdk: DatalayerSDK);
|
|
49
|
+
/**
|
|
50
|
+
* Check if this lexical document has been deleted.
|
|
51
|
+
*/
|
|
52
|
+
get isDeleted(): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Check if this lexical document has been deleted and throw error if so.
|
|
55
|
+
* @throws Error if the document has been deleted
|
|
56
|
+
*/
|
|
57
|
+
private _checkDeleted;
|
|
58
|
+
/**
|
|
59
|
+
* Get fresh data from API with caching to avoid redundant calls.
|
|
60
|
+
* @returns Current LexicalData from API or cache
|
|
61
|
+
*/
|
|
62
|
+
private _getFreshData;
|
|
63
|
+
/**
|
|
64
|
+
* Lexical document ID.
|
|
65
|
+
*/
|
|
66
|
+
get id(): string;
|
|
67
|
+
/**
|
|
68
|
+
* Unique identifier for the document.
|
|
69
|
+
*/
|
|
70
|
+
get uid(): string;
|
|
71
|
+
/**
|
|
72
|
+
* Parent space ID.
|
|
73
|
+
*/
|
|
74
|
+
get spaceId(): string;
|
|
75
|
+
/**
|
|
76
|
+
* Owner user ID.
|
|
77
|
+
*/
|
|
78
|
+
get ownerId(): string;
|
|
79
|
+
/**
|
|
80
|
+
* When the document was created.
|
|
81
|
+
*/
|
|
82
|
+
get createdAt(): Date;
|
|
83
|
+
/**
|
|
84
|
+
* Get the current name of the document.
|
|
85
|
+
*
|
|
86
|
+
* This method fetches fresh data from the API (with caching) and updates
|
|
87
|
+
* the internal data to keep everything in sync.
|
|
88
|
+
*
|
|
89
|
+
* @returns Promise resolving to current document name
|
|
90
|
+
* @throws Error if the document has been deleted
|
|
91
|
+
*/
|
|
92
|
+
getName(): Promise<string>;
|
|
93
|
+
/**
|
|
94
|
+
* Get the document content.
|
|
95
|
+
*
|
|
96
|
+
* @returns Promise resolving to document content
|
|
97
|
+
*/
|
|
98
|
+
getContent(): Promise<any>;
|
|
99
|
+
/**
|
|
100
|
+
* Get when the document was last updated.
|
|
101
|
+
*
|
|
102
|
+
* @returns Promise resolving to last update time
|
|
103
|
+
*/
|
|
104
|
+
getUpdatedAt(): Promise<Date>;
|
|
105
|
+
/**
|
|
106
|
+
* Update the document name and/or description.
|
|
107
|
+
*
|
|
108
|
+
* @param data - Update data containing name and/or description
|
|
109
|
+
* @returns Promise resolving to updated Lexical instance
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const updated = await lexical.update({
|
|
114
|
+
* name: 'Updated Documentation',
|
|
115
|
+
* description: 'Updated document description'
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
update(data: UpdateLexicalRequest): Promise<Lexical>;
|
|
120
|
+
/**
|
|
121
|
+
* Delete this document permanently.
|
|
122
|
+
*
|
|
123
|
+
* After deletion, this object will be marked as deleted and subsequent
|
|
124
|
+
* calls to dynamic methods will throw errors.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* await lexical.delete();
|
|
129
|
+
* console.log('Document deleted');
|
|
130
|
+
* // lexical.getName() will now throw an error
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
delete(): Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Get raw document data object with latest information.
|
|
136
|
+
*
|
|
137
|
+
* This method ensures the returned data includes the most recent information
|
|
138
|
+
* by refreshing from the API before returning.
|
|
139
|
+
*
|
|
140
|
+
* @returns Promise resolving to raw document data
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const latestData = await lexical.toJSON();
|
|
145
|
+
* console.log('Current name:', latestData.name);
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
toJSON(): Promise<LexicalData>;
|
|
149
|
+
/**
|
|
150
|
+
* String representation of the document.
|
|
151
|
+
*
|
|
152
|
+
* @returns String representation for logging/debugging
|
|
153
|
+
*/
|
|
154
|
+
toString(): string;
|
|
155
|
+
}
|
|
156
|
+
export type { LexicalData };
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
import { lexicals } from '../../../api/spacer';
|
|
6
|
+
import { items } from '../../../api/spacer';
|
|
7
|
+
/**
|
|
8
|
+
* Lexical domain model that wraps API responses with convenient methods.
|
|
9
|
+
*
|
|
10
|
+
* Provides a rich, object-oriented interface for managing Lexical documents
|
|
11
|
+
* with automatic data refresh and lifecycle operations.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const formData = new FormData();
|
|
16
|
+
* formData.append('spaceId', 'space-123');
|
|
17
|
+
* formData.append('name', 'Project Documentation');
|
|
18
|
+
* const lexical = await sdk.createLexical(formData);
|
|
19
|
+
*
|
|
20
|
+
* // Static properties - instant access
|
|
21
|
+
* console.log(lexical.id);
|
|
22
|
+
* console.log(lexical.spaceId);
|
|
23
|
+
*
|
|
24
|
+
* // Dynamic data - always fresh from API
|
|
25
|
+
* const currentName = await lexical.getName();
|
|
26
|
+
* const content = await lexical.getContent();
|
|
27
|
+
*
|
|
28
|
+
* // Update document
|
|
29
|
+
* const updated = await lexical.update({ name: 'Updated Documentation' });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export class Lexical {
|
|
33
|
+
_data;
|
|
34
|
+
_sdk;
|
|
35
|
+
_deleted = false;
|
|
36
|
+
_freshData = null;
|
|
37
|
+
_lastFetch = 0;
|
|
38
|
+
_cacheTimeout = 5000; // 5 seconds cache timeout
|
|
39
|
+
/**
|
|
40
|
+
* Create a Lexical instance.
|
|
41
|
+
*
|
|
42
|
+
* @param data - Raw lexical data from API
|
|
43
|
+
* @param sdk - DatalayerSDK instance for making API calls
|
|
44
|
+
*/
|
|
45
|
+
constructor(data, sdk) {
|
|
46
|
+
this._data = data;
|
|
47
|
+
this._sdk = sdk;
|
|
48
|
+
}
|
|
49
|
+
// ========================================================================
|
|
50
|
+
// Deletion State
|
|
51
|
+
// ========================================================================
|
|
52
|
+
/**
|
|
53
|
+
* Check if this lexical document has been deleted.
|
|
54
|
+
*/
|
|
55
|
+
get isDeleted() {
|
|
56
|
+
return this._deleted;
|
|
57
|
+
}
|
|
58
|
+
// ========================================================================
|
|
59
|
+
// Helper Methods
|
|
60
|
+
// ========================================================================
|
|
61
|
+
/**
|
|
62
|
+
* Check if this lexical document has been deleted and throw error if so.
|
|
63
|
+
* @throws Error if the document has been deleted
|
|
64
|
+
*/
|
|
65
|
+
_checkDeleted() {
|
|
66
|
+
if (this._deleted) {
|
|
67
|
+
throw new Error(`Lexical ${this._data.id} has been deleted and no longer exists`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get fresh data from API with caching to avoid redundant calls.
|
|
72
|
+
* @returns Current LexicalData from API or cache
|
|
73
|
+
*/
|
|
74
|
+
async _getFreshData() {
|
|
75
|
+
this._checkDeleted();
|
|
76
|
+
const now = Date.now();
|
|
77
|
+
if (this._freshData && now - this._lastFetch < this._cacheTimeout) {
|
|
78
|
+
// Return cached data if recent enough
|
|
79
|
+
return this._freshData;
|
|
80
|
+
}
|
|
81
|
+
// Fetch fresh data from API
|
|
82
|
+
const token = this._sdk.getToken();
|
|
83
|
+
const spacerRunUrl = this._sdk.getSpacerRunUrl();
|
|
84
|
+
const response = await lexicals.getLexical(token, this.uid, spacerRunUrl);
|
|
85
|
+
if (response.document) {
|
|
86
|
+
this._freshData = response.document;
|
|
87
|
+
this._data = response.document; // Keep internal data up to date
|
|
88
|
+
this._lastFetch = now;
|
|
89
|
+
return this._freshData;
|
|
90
|
+
}
|
|
91
|
+
return this._data; // Fallback to existing data
|
|
92
|
+
}
|
|
93
|
+
// ========================================================================
|
|
94
|
+
// Static Properties (set at creation, never change)
|
|
95
|
+
// ========================================================================
|
|
96
|
+
/**
|
|
97
|
+
* Lexical document ID.
|
|
98
|
+
*/
|
|
99
|
+
get id() {
|
|
100
|
+
this._checkDeleted();
|
|
101
|
+
return this._data.id;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Unique identifier for the document.
|
|
105
|
+
*/
|
|
106
|
+
get uid() {
|
|
107
|
+
this._checkDeleted();
|
|
108
|
+
return this._data.uid;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Parent space ID.
|
|
112
|
+
*/
|
|
113
|
+
get spaceId() {
|
|
114
|
+
this._checkDeleted();
|
|
115
|
+
// Try the direct field first (if API provides it)
|
|
116
|
+
if (this._data.space_id) {
|
|
117
|
+
return this._data.space_id;
|
|
118
|
+
}
|
|
119
|
+
// Extract from s3_path_s if available: "datalayer.app/SPACE_ID/documents/..."
|
|
120
|
+
const s3Path = this._data.s3_path_s;
|
|
121
|
+
if (s3Path && typeof s3Path === 'string') {
|
|
122
|
+
const match = s3Path.match(/^datalayer\.app\/([^/]+)\//);
|
|
123
|
+
if (match) {
|
|
124
|
+
return match[1];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Fallback to empty string if no space ID can be determined
|
|
128
|
+
return '';
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Owner user ID.
|
|
132
|
+
*/
|
|
133
|
+
get ownerId() {
|
|
134
|
+
this._checkDeleted();
|
|
135
|
+
return this._data.owner_id || this._data.creator_uid || '';
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* When the document was created.
|
|
139
|
+
*/
|
|
140
|
+
get createdAt() {
|
|
141
|
+
this._checkDeleted();
|
|
142
|
+
const dateStr = this._data.creation_ts_dt || this._data.created_at;
|
|
143
|
+
if (!dateStr) {
|
|
144
|
+
throw new Error('No creation timestamp available for lexical document');
|
|
145
|
+
}
|
|
146
|
+
return new Date(dateStr);
|
|
147
|
+
}
|
|
148
|
+
// ========================================================================
|
|
149
|
+
// Dynamic Methods (always fetch fresh data and update internal state)
|
|
150
|
+
// ========================================================================
|
|
151
|
+
/**
|
|
152
|
+
* Get the current name of the document.
|
|
153
|
+
*
|
|
154
|
+
* This method fetches fresh data from the API (with caching) and updates
|
|
155
|
+
* the internal data to keep everything in sync.
|
|
156
|
+
*
|
|
157
|
+
* @returns Promise resolving to current document name
|
|
158
|
+
* @throws Error if the document has been deleted
|
|
159
|
+
*/
|
|
160
|
+
async getName() {
|
|
161
|
+
const freshData = await this._getFreshData();
|
|
162
|
+
return freshData.name_t || freshData.name || '';
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Get the document content.
|
|
166
|
+
*
|
|
167
|
+
* @returns Promise resolving to document content
|
|
168
|
+
*/
|
|
169
|
+
async getContent() {
|
|
170
|
+
const freshData = await this._getFreshData();
|
|
171
|
+
// Try to parse model_s if content is not available
|
|
172
|
+
if (!freshData.content && freshData.model_s) {
|
|
173
|
+
try {
|
|
174
|
+
return JSON.parse(freshData.model_s);
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
// Fall back to raw model_s if parsing fails
|
|
178
|
+
return freshData.model_s;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return freshData.content;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get when the document was last updated.
|
|
185
|
+
*
|
|
186
|
+
* @returns Promise resolving to last update time
|
|
187
|
+
*/
|
|
188
|
+
async getUpdatedAt() {
|
|
189
|
+
const freshData = await this._getFreshData();
|
|
190
|
+
const dateStr = freshData.last_update_ts_dt ||
|
|
191
|
+
freshData.updated_at ||
|
|
192
|
+
freshData.creation_ts_dt ||
|
|
193
|
+
freshData.created_at;
|
|
194
|
+
if (!dateStr) {
|
|
195
|
+
throw new Error('No timestamp available for lexical document');
|
|
196
|
+
}
|
|
197
|
+
return new Date(dateStr);
|
|
198
|
+
}
|
|
199
|
+
// ========================================================================
|
|
200
|
+
// Action Methods
|
|
201
|
+
// ========================================================================
|
|
202
|
+
/**
|
|
203
|
+
* Update the document name and/or description.
|
|
204
|
+
*
|
|
205
|
+
* @param data - Update data containing name and/or description
|
|
206
|
+
* @returns Promise resolving to updated Lexical instance
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* const updated = await lexical.update({
|
|
211
|
+
* name: 'Updated Documentation',
|
|
212
|
+
* description: 'Updated document description'
|
|
213
|
+
* });
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
async update(data) {
|
|
217
|
+
this._checkDeleted();
|
|
218
|
+
const token = this._sdk.getToken();
|
|
219
|
+
const spacerRunUrl = this._sdk.getSpacerRunUrl();
|
|
220
|
+
const response = await lexicals.updateLexical(token, this.uid, data, spacerRunUrl);
|
|
221
|
+
return new Lexical(response.document, this._sdk);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Delete this document permanently.
|
|
225
|
+
*
|
|
226
|
+
* After deletion, this object will be marked as deleted and subsequent
|
|
227
|
+
* calls to dynamic methods will throw errors.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* await lexical.delete();
|
|
232
|
+
* console.log('Document deleted');
|
|
233
|
+
* // lexical.getName() will now throw an error
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
async delete() {
|
|
237
|
+
this._checkDeleted();
|
|
238
|
+
const token = this._sdk.getToken();
|
|
239
|
+
const spacerRunUrl = this._sdk.getSpacerRunUrl();
|
|
240
|
+
await items.deleteItem(token, this.uid, spacerRunUrl);
|
|
241
|
+
this._deleted = true;
|
|
242
|
+
}
|
|
243
|
+
// ========================================================================
|
|
244
|
+
// Utility Methods
|
|
245
|
+
// ========================================================================
|
|
246
|
+
/**
|
|
247
|
+
* Get raw document data object with latest information.
|
|
248
|
+
*
|
|
249
|
+
* This method ensures the returned data includes the most recent information
|
|
250
|
+
* by refreshing from the API before returning.
|
|
251
|
+
*
|
|
252
|
+
* @returns Promise resolving to raw document data
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```typescript
|
|
256
|
+
* const latestData = await lexical.toJSON();
|
|
257
|
+
* console.log('Current name:', latestData.name);
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
async toJSON() {
|
|
261
|
+
this._checkDeleted();
|
|
262
|
+
await this.getName(); // This updates internal data
|
|
263
|
+
return this._data;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* String representation of the document.
|
|
267
|
+
*
|
|
268
|
+
* @returns String representation for logging/debugging
|
|
269
|
+
*/
|
|
270
|
+
toString() {
|
|
271
|
+
this._checkDeleted();
|
|
272
|
+
const name = this._data.name_t || this._data.name || 'Unnamed';
|
|
273
|
+
return `Lexical(${this.id}, ${name})`;
|
|
274
|
+
}
|
|
275
|
+
}
|