@datalayer/core 0.0.19 → 0.0.21
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/App.js +0 -5
- package/lib/api/iam/datasources.d.ts +86 -0
- package/lib/api/iam/datasources.js +185 -0
- package/lib/api/iam/index.d.ts +2 -0
- package/lib/api/iam/index.js +2 -0
- package/lib/api/iam/secrets.d.ts +85 -0
- package/lib/api/iam/secrets.js +196 -0
- package/lib/client/auth/storage.js +17 -62
- package/lib/client/base.d.ts +3 -0
- package/lib/client/base.js +2 -2
- package/lib/client/index.d.ts +82 -3
- package/lib/client/index.js +5 -1
- package/lib/client/mixins/IAMMixin.d.ts +62 -0
- package/lib/client/mixins/IAMMixin.js +116 -0
- package/lib/collaboration/DatalayerCollaboration.d.ts +1 -2
- package/lib/collaboration/DatalayerCollaborationProvider.d.ts +1 -1
- package/lib/collaboration/DatalayerCollaborationProvider.js +1 -1
- package/lib/components/auth/Login.js +0 -5
- package/lib/components/auth/index.js +1 -6
- package/lib/components/index.d.ts +0 -1
- package/lib/components/index.js +0 -1
- package/lib/components/toolbars/AssignmentEditorToolbar.js +9 -7
- package/lib/examples/CellExample.js +4 -3
- package/lib/examples/NotebookExample.js +2 -7
- package/lib/hooks/index.d.ts +0 -2
- package/lib/hooks/index.js +0 -2
- package/lib/hooks/useBackdrop.d.ts +2 -3
- package/lib/hooks/useBackdropJupyterLab.d.ts +2 -2
- package/lib/hooks/useCache.d.ts +18 -4
- package/lib/hooks/useCache.js +87 -69
- package/lib/hooks/useScreenshot.d.ts +2 -3
- package/lib/hooks/useWindowSize.d.ts +1 -2
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -2
- package/lib/main.js +4 -1
- package/lib/models/Datasource.d.ts +170 -0
- package/lib/models/Datasource.js +140 -0
- package/lib/models/Runtime.d.ts +1 -1
- package/lib/models/RuntimeSnapshotDTO.d.ts +1 -1
- package/lib/models/RuntimeSnapshotDTO.js +1 -1
- package/lib/models/Secret.d.ts +159 -0
- package/lib/models/Secret.js +135 -0
- package/lib/models/SpaceDTO.d.ts +0 -11
- package/lib/models/index.d.ts +0 -1
- package/lib/models/index.js +0 -1
- package/lib/state/substates/IAMState.d.ts +1 -1
- package/lib/state/substates/LayoutState.d.ts +2 -2
- package/lib/state/substates/NbformatState.d.ts +1 -1
- package/lib/state/substates/index.d.ts +0 -1
- package/lib/state/substates/index.js +0 -1
- package/lib/utils/File.d.ts +1 -1
- package/lib/utils/File.js +1 -1
- package/lib/utils/Notebook.d.ts +5 -3
- package/lib/utils/Notebook.js +5 -3
- package/lib/utils/cli/index.js +0 -5
- package/lib/utils/cli/query.js +0 -5
- package/lib/views/datasources/DatasourceDetail.d.ts +2 -0
- package/lib/views/datasources/DatasourceDetail.js +91 -0
- package/lib/views/datasources/DatasourceNew.d.ts +2 -0
- package/lib/views/datasources/DatasourceNew.js +118 -0
- package/lib/views/datasources/Datasources.d.ts +2 -0
- package/lib/views/datasources/Datasources.js +49 -0
- package/lib/views/datasources/index.d.ts +3 -0
- package/lib/views/datasources/index.js +7 -0
- package/lib/views/iam-tokens/IAMTokenEdit.d.ts +2 -0
- package/lib/views/iam-tokens/IAMTokenEdit.js +86 -0
- package/lib/views/iam-tokens/IAMTokenNew.d.ts +2 -0
- package/lib/views/iam-tokens/IAMTokenNew.js +118 -0
- package/lib/views/iam-tokens/IAMTokens.d.ts +2 -0
- package/lib/views/iam-tokens/IAMTokens.js +53 -0
- package/lib/views/iam-tokens/Tokens.d.ts +2 -0
- package/lib/views/iam-tokens/Tokens.js +53 -0
- package/lib/views/iam-tokens/index.d.ts +3 -0
- package/lib/views/iam-tokens/index.js +7 -0
- package/lib/views/index.d.ts +1 -0
- package/lib/views/secrets/SecretEdit.d.ts +2 -0
- package/lib/views/secrets/SecretEdit.js +149 -0
- package/lib/views/secrets/SecretNew.d.ts +2 -0
- package/lib/views/secrets/SecretNew.js +99 -0
- package/lib/views/secrets/Secrets.d.ts +2 -0
- package/lib/views/secrets/Secrets.js +48 -0
- package/lib/views/secrets/index.d.ts +3 -0
- package/lib/views/secrets/index.js +7 -0
- package/package.json +15 -16
- package/patches/.gitkeep +1 -0
- package/patches/@datalayer+jupyter-lexical+1.0.7.patch +5491 -0
- package/patches/@datalayer+jupyter-react+2.0.1.patch +2674 -0
- package/scripts/apply-patches.sh +44 -0
- package/scripts/create-patches.sh +40 -0
- package/scripts/fix-esm-imports.cjs +124 -0
- package/scripts/sync-jupyter.sh +121 -0
- package/lib/components/chat/ChatComponent.d.ts +0 -4
- package/lib/components/chat/ChatComponent.js +0 -143
- package/lib/components/chat/MessagePart.d.ts +0 -11
- package/lib/components/chat/MessagePart.js +0 -23
- package/lib/components/chat/display/DynamicToolPart.d.ts +0 -6
- package/lib/components/chat/display/DynamicToolPart.js +0 -5
- package/lib/components/chat/display/ReasoningPart.d.ts +0 -6
- package/lib/components/chat/display/ReasoningPart.js +0 -58
- package/lib/components/chat/display/TextPart.d.ts +0 -9
- package/lib/components/chat/display/TextPart.js +0 -93
- package/lib/components/chat/display/ToolPart.d.ts +0 -6
- package/lib/components/chat/display/ToolPart.js +0 -148
- package/lib/components/chat/display/index.d.ts +0 -4
- package/lib/components/chat/display/index.js +0 -13
- package/lib/components/chat/handler.d.ts +0 -8
- package/lib/components/chat/handler.js +0 -43
- package/lib/components/chat/index.d.ts +0 -4
- package/lib/components/chat/index.js +0 -13
- package/lib/hooks/useAIAgents.d.ts +0 -13
- package/lib/hooks/useAIAgents.js +0 -72
- package/lib/hooks/useAIJupyterChat.d.ts +0 -36
- package/lib/hooks/useAIJupyterChat.js +0 -53
- package/lib/hooks/useNotebookAIAgent.d.ts +0 -8
- package/lib/hooks/useNotebookAIAgent.js +0 -56
- package/lib/models/AIAgent.d.ts +0 -17
- package/lib/state/substates/AIAgentState.d.ts +0 -11
- package/lib/state/substates/AIAgentState.js +0 -42
- package/lib/tools/adapters/agui/AgUIToolAdapter.d.ts +0 -75
- package/lib/tools/adapters/agui/AgUIToolAdapter.js +0 -244
- package/lib/tools/adapters/agui/index.d.ts +0 -10
- package/lib/tools/adapters/agui/index.js +0 -19
- package/lib/tools/adapters/agui/lexicalHooks.d.ts +0 -27
- package/lib/tools/adapters/agui/lexicalHooks.js +0 -64
- package/lib/tools/adapters/agui/notebookHooks.d.ts +0 -27
- package/lib/tools/adapters/agui/notebookHooks.js +0 -61
- package/lib/tools/index.d.ts +0 -6
- package/lib/tools/index.js +0 -18
- package/lib/{models/AIAgent.js → views/index.js} +1 -1
|
@@ -9,3 +9,173 @@ export type IDatasource = {
|
|
|
9
9
|
outputBucket: string;
|
|
10
10
|
};
|
|
11
11
|
export default IDatasource;
|
|
12
|
+
import type { DatalayerClient } from '../client';
|
|
13
|
+
/**
|
|
14
|
+
* Datasource type matching UI and API.
|
|
15
|
+
*/
|
|
16
|
+
export type DatasourceType = 'Amazon Athena' | 'Google BigQuery' | 'Microsoft Sentinel' | 'Splunk';
|
|
17
|
+
/**
|
|
18
|
+
* Raw datasource data from API (snake_case with suffixes).
|
|
19
|
+
*/
|
|
20
|
+
export interface DatasourceData {
|
|
21
|
+
/** Unique identifier (ULID) */
|
|
22
|
+
uid: string;
|
|
23
|
+
/** Datasource type */
|
|
24
|
+
type_s: DatasourceType;
|
|
25
|
+
/** Datasource name */
|
|
26
|
+
name_s: string;
|
|
27
|
+
/** Datasource description */
|
|
28
|
+
description_t: string;
|
|
29
|
+
/** Datasource variant (athena, bigquery, mssentinel, splunk) */
|
|
30
|
+
variant_s?: string;
|
|
31
|
+
/** Optional: Database name (required for Amazon Athena) */
|
|
32
|
+
database_s?: string;
|
|
33
|
+
/** Optional: S3 output bucket (required for Amazon Athena) */
|
|
34
|
+
output_bucket_s?: string;
|
|
35
|
+
/** Creation timestamp */
|
|
36
|
+
created_at?: string;
|
|
37
|
+
/** Last update timestamp */
|
|
38
|
+
updated_at?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Public JSON interface for Datasource (camelCase).
|
|
42
|
+
*/
|
|
43
|
+
export interface DatasourceJSON {
|
|
44
|
+
/** Unique identifier */
|
|
45
|
+
uid: string;
|
|
46
|
+
/** Datasource type */
|
|
47
|
+
type: DatasourceType;
|
|
48
|
+
/** Datasource name */
|
|
49
|
+
name: string;
|
|
50
|
+
/** Datasource description */
|
|
51
|
+
description: string;
|
|
52
|
+
/** Optional: Database name */
|
|
53
|
+
database?: string;
|
|
54
|
+
/** Optional: S3 output bucket */
|
|
55
|
+
outputBucket?: string;
|
|
56
|
+
/** Creation timestamp */
|
|
57
|
+
createdAt?: Date;
|
|
58
|
+
/** Last update timestamp */
|
|
59
|
+
updatedAt?: Date;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Request data for creating a new datasource.
|
|
63
|
+
*/
|
|
64
|
+
export interface CreateDatasourceRequest {
|
|
65
|
+
/** Datasource type */
|
|
66
|
+
type: DatasourceType;
|
|
67
|
+
/** Datasource name (unique identifier) */
|
|
68
|
+
name: string;
|
|
69
|
+
/** Human-readable description */
|
|
70
|
+
description?: string;
|
|
71
|
+
/** Optional: Database name (required for Amazon Athena) */
|
|
72
|
+
database?: string;
|
|
73
|
+
/** Optional: S3 output bucket (required for Amazon Athena) */
|
|
74
|
+
output_bucket?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Request data for updating a datasource.
|
|
78
|
+
*/
|
|
79
|
+
export interface UpdateDatasourceRequest {
|
|
80
|
+
/** Optional: update type */
|
|
81
|
+
type?: DatasourceType;
|
|
82
|
+
/** Optional: update name */
|
|
83
|
+
name?: string;
|
|
84
|
+
/** Optional: update description */
|
|
85
|
+
description?: string;
|
|
86
|
+
/** Optional: update database */
|
|
87
|
+
database?: string;
|
|
88
|
+
/** Optional: update output bucket */
|
|
89
|
+
output_bucket?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Response from creating a datasource.
|
|
93
|
+
*/
|
|
94
|
+
export interface CreateDatasourceResponse {
|
|
95
|
+
success: boolean;
|
|
96
|
+
message: string;
|
|
97
|
+
datasource: DatasourceData;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Response from getting a datasource.
|
|
101
|
+
*/
|
|
102
|
+
export interface GetDatasourceResponse {
|
|
103
|
+
success: boolean;
|
|
104
|
+
message: string;
|
|
105
|
+
datasource: DatasourceData;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Response from listing datasources.
|
|
109
|
+
*/
|
|
110
|
+
export interface ListDatasourcesResponse {
|
|
111
|
+
success: boolean;
|
|
112
|
+
message: string;
|
|
113
|
+
datasources: DatasourceData[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Response from updating a datasource.
|
|
117
|
+
*/
|
|
118
|
+
export interface UpdateDatasourceResponse {
|
|
119
|
+
success: boolean;
|
|
120
|
+
message: string;
|
|
121
|
+
datasource: DatasourceData;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Datasource domain model for the Datalayer SDK.
|
|
125
|
+
* Provides state management and operations for datasources.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const datasource = await sdk.createDatasource({
|
|
130
|
+
* type: 'Amazon Athena',
|
|
131
|
+
* name: 'my-athena-datasource',
|
|
132
|
+
* description: 'Production Athena datasource',
|
|
133
|
+
* database: 'my_database',
|
|
134
|
+
* output_bucket: 's3://my-bucket/output/'
|
|
135
|
+
* });
|
|
136
|
+
*
|
|
137
|
+
* await datasource.update({ description: 'Updated description' });
|
|
138
|
+
* await datasource.delete();
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export declare class DatasourceDTO {
|
|
142
|
+
/** @internal */
|
|
143
|
+
_data: DatasourceData;
|
|
144
|
+
private _sdk;
|
|
145
|
+
private _deleted;
|
|
146
|
+
/**
|
|
147
|
+
* Create a Datasource instance.
|
|
148
|
+
* @param data - Datasource data from API
|
|
149
|
+
* @param sdk - SDK instance
|
|
150
|
+
*/
|
|
151
|
+
constructor(data: DatasourceData, sdk: DatalayerClient);
|
|
152
|
+
private _checkDeleted;
|
|
153
|
+
get uid(): string;
|
|
154
|
+
get type(): DatasourceType;
|
|
155
|
+
get variant(): string | undefined;
|
|
156
|
+
get name(): string;
|
|
157
|
+
get description(): string;
|
|
158
|
+
get database(): string | undefined;
|
|
159
|
+
get outputBucket(): string | undefined;
|
|
160
|
+
get createdAt(): Date | undefined;
|
|
161
|
+
get updatedAt(): Date | undefined;
|
|
162
|
+
/**
|
|
163
|
+
* Update this datasource.
|
|
164
|
+
* @param updates - Fields to update
|
|
165
|
+
* @returns Updated Datasource instance
|
|
166
|
+
*/
|
|
167
|
+
update(updates: UpdateDatasourceRequest): Promise<DatasourceDTO>;
|
|
168
|
+
/**
|
|
169
|
+
* Delete this datasource permanently.
|
|
170
|
+
*/
|
|
171
|
+
delete(): Promise<void>;
|
|
172
|
+
/**
|
|
173
|
+
* Get datasource data in camelCase format.
|
|
174
|
+
*/
|
|
175
|
+
toJSON(): DatasourceJSON;
|
|
176
|
+
/**
|
|
177
|
+
* Get raw datasource data exactly as received from API.
|
|
178
|
+
*/
|
|
179
|
+
rawData(): DatasourceData;
|
|
180
|
+
toString(): string;
|
|
181
|
+
}
|
package/lib/models/Datasource.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// OLD API - Kept for backward compatibility
|
|
7
|
+
// ============================================================================
|
|
5
8
|
export const asDatasource = (s) => {
|
|
6
9
|
return {
|
|
7
10
|
id: s.uid,
|
|
@@ -12,3 +15,140 @@ export const asDatasource = (s) => {
|
|
|
12
15
|
outputBucket: s.output_bucket_s,
|
|
13
16
|
};
|
|
14
17
|
};
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// New API Types and DTO
|
|
20
|
+
// ============================================================================
|
|
21
|
+
import { validateJSON } from '../api/utils/validation';
|
|
22
|
+
/**
|
|
23
|
+
* Datasource domain model for the Datalayer SDK.
|
|
24
|
+
* Provides state management and operations for datasources.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const datasource = await sdk.createDatasource({
|
|
29
|
+
* type: 'Amazon Athena',
|
|
30
|
+
* name: 'my-athena-datasource',
|
|
31
|
+
* description: 'Production Athena datasource',
|
|
32
|
+
* database: 'my_database',
|
|
33
|
+
* output_bucket: 's3://my-bucket/output/'
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* await datasource.update({ description: 'Updated description' });
|
|
37
|
+
* await datasource.delete();
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export class DatasourceDTO {
|
|
41
|
+
/** @internal */
|
|
42
|
+
_data;
|
|
43
|
+
_sdk;
|
|
44
|
+
_deleted = false;
|
|
45
|
+
/**
|
|
46
|
+
* Create a Datasource instance.
|
|
47
|
+
* @param data - Datasource data from API
|
|
48
|
+
* @param sdk - SDK instance
|
|
49
|
+
*/
|
|
50
|
+
constructor(data, sdk) {
|
|
51
|
+
this._data = data;
|
|
52
|
+
this._sdk = sdk;
|
|
53
|
+
}
|
|
54
|
+
// ========================================================================
|
|
55
|
+
// Helper Methods
|
|
56
|
+
// ========================================================================
|
|
57
|
+
_checkDeleted() {
|
|
58
|
+
if (this._deleted) {
|
|
59
|
+
throw new Error(`Datasource ${this._data.name_s} has been deleted and no longer exists`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// ========================================================================
|
|
63
|
+
// Properties
|
|
64
|
+
// ========================================================================
|
|
65
|
+
get uid() {
|
|
66
|
+
this._checkDeleted();
|
|
67
|
+
return this._data.uid;
|
|
68
|
+
}
|
|
69
|
+
get type() {
|
|
70
|
+
this._checkDeleted();
|
|
71
|
+
return this._data.type_s;
|
|
72
|
+
}
|
|
73
|
+
get variant() {
|
|
74
|
+
this._checkDeleted();
|
|
75
|
+
return this._data.variant_s;
|
|
76
|
+
}
|
|
77
|
+
get name() {
|
|
78
|
+
this._checkDeleted();
|
|
79
|
+
return this._data.name_s;
|
|
80
|
+
}
|
|
81
|
+
get description() {
|
|
82
|
+
this._checkDeleted();
|
|
83
|
+
return this._data.description_t;
|
|
84
|
+
}
|
|
85
|
+
get database() {
|
|
86
|
+
this._checkDeleted();
|
|
87
|
+
return this._data.database_s;
|
|
88
|
+
}
|
|
89
|
+
get outputBucket() {
|
|
90
|
+
this._checkDeleted();
|
|
91
|
+
return this._data.output_bucket_s;
|
|
92
|
+
}
|
|
93
|
+
get createdAt() {
|
|
94
|
+
this._checkDeleted();
|
|
95
|
+
return this._data.created_at ? new Date(this._data.created_at) : undefined;
|
|
96
|
+
}
|
|
97
|
+
get updatedAt() {
|
|
98
|
+
this._checkDeleted();
|
|
99
|
+
return this._data.updated_at ? new Date(this._data.updated_at) : undefined;
|
|
100
|
+
}
|
|
101
|
+
// ========================================================================
|
|
102
|
+
// Action Methods
|
|
103
|
+
// ========================================================================
|
|
104
|
+
/**
|
|
105
|
+
* Update this datasource.
|
|
106
|
+
* @param updates - Fields to update
|
|
107
|
+
* @returns Updated Datasource instance
|
|
108
|
+
*/
|
|
109
|
+
async update(updates) {
|
|
110
|
+
this._checkDeleted();
|
|
111
|
+
const updated = await this._sdk.updateDatasource(this.uid, updates);
|
|
112
|
+
return updated;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Delete this datasource permanently.
|
|
116
|
+
*/
|
|
117
|
+
async delete() {
|
|
118
|
+
this._checkDeleted();
|
|
119
|
+
await this._sdk.deleteDatasource(this.uid);
|
|
120
|
+
this._deleted = true;
|
|
121
|
+
}
|
|
122
|
+
// ========================================================================
|
|
123
|
+
// Utility Methods
|
|
124
|
+
// ========================================================================
|
|
125
|
+
/**
|
|
126
|
+
* Get datasource data in camelCase format.
|
|
127
|
+
*/
|
|
128
|
+
toJSON() {
|
|
129
|
+
this._checkDeleted();
|
|
130
|
+
const obj = {
|
|
131
|
+
uid: this.uid,
|
|
132
|
+
type: this.type,
|
|
133
|
+
name: this.name,
|
|
134
|
+
description: this.description,
|
|
135
|
+
database: this.database,
|
|
136
|
+
outputBucket: this.outputBucket,
|
|
137
|
+
createdAt: this.createdAt,
|
|
138
|
+
updatedAt: this.updatedAt,
|
|
139
|
+
};
|
|
140
|
+
validateJSON(obj, 'Datasource');
|
|
141
|
+
return obj;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get raw datasource data exactly as received from API.
|
|
145
|
+
*/
|
|
146
|
+
rawData() {
|
|
147
|
+
this._checkDeleted();
|
|
148
|
+
return this._data;
|
|
149
|
+
}
|
|
150
|
+
toString() {
|
|
151
|
+
this._checkDeleted();
|
|
152
|
+
return `Datasource(${this.name}, ${this.type})`;
|
|
153
|
+
}
|
|
154
|
+
}
|
package/lib/models/Runtime.d.ts
CHANGED
|
@@ -148,7 +148,7 @@ export declare class RuntimeSnapshotDTO {
|
|
|
148
148
|
/**
|
|
149
149
|
* Create a runtime from this snapshot (restore functionality).
|
|
150
150
|
*
|
|
151
|
-
* @param
|
|
151
|
+
* @param minutesLimit - Time limit in minutes for the restored runtime
|
|
152
152
|
* @returns Created Runtime instance
|
|
153
153
|
*/
|
|
154
154
|
restore(minutesLimit: number): Promise<RuntimeDTO>;
|
|
@@ -85,7 +85,7 @@ export class RuntimeSnapshotDTO {
|
|
|
85
85
|
/**
|
|
86
86
|
* Create a runtime from this snapshot (restore functionality).
|
|
87
87
|
*
|
|
88
|
-
* @param
|
|
88
|
+
* @param minutesLimit - Time limit in minutes for the restored runtime
|
|
89
89
|
* @returns Created Runtime instance
|
|
90
90
|
*/
|
|
91
91
|
async restore(minutesLimit) {
|
package/lib/models/Secret.d.ts
CHANGED
|
@@ -8,3 +8,162 @@ export type ISecret = {
|
|
|
8
8
|
value: string;
|
|
9
9
|
};
|
|
10
10
|
export default ISecret;
|
|
11
|
+
import type { DatalayerClient } from '../client';
|
|
12
|
+
/**
|
|
13
|
+
* Raw secret data from API (snake_case with suffixes).
|
|
14
|
+
*/
|
|
15
|
+
export interface SecretData {
|
|
16
|
+
/** Unique identifier (ULID) */
|
|
17
|
+
uid: string;
|
|
18
|
+
/** Secret variant/type */
|
|
19
|
+
variant_s: ISecretVariant;
|
|
20
|
+
/** Secret name */
|
|
21
|
+
name_s: string;
|
|
22
|
+
/** Secret description */
|
|
23
|
+
description_t: string;
|
|
24
|
+
/** Base64-encoded secret value */
|
|
25
|
+
value_s: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Public JSON interface for Secret (camelCase).
|
|
29
|
+
*/
|
|
30
|
+
export interface SecretJSON {
|
|
31
|
+
/** Unique identifier */
|
|
32
|
+
uid: string;
|
|
33
|
+
/** Secret type */
|
|
34
|
+
variant: ISecretVariant;
|
|
35
|
+
/** Secret name */
|
|
36
|
+
name: string;
|
|
37
|
+
/** Secret description */
|
|
38
|
+
description: string;
|
|
39
|
+
/** Decoded secret value (plain text) */
|
|
40
|
+
value: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Request data for creating a new secret.
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export interface CreateSecretRequest {
|
|
47
|
+
/** Secret type/variant (defaults to 'generic' if not provided) */
|
|
48
|
+
variant?: ISecretVariant;
|
|
49
|
+
/** Secret name (unique identifier) */
|
|
50
|
+
name: string;
|
|
51
|
+
/** Human-readable description */
|
|
52
|
+
description?: string;
|
|
53
|
+
/** Plain text value (will be Base64 encoded by SDK) */
|
|
54
|
+
value: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Request data for updating a secret.
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export interface UpdateSecretRequest {
|
|
61
|
+
/** Optional: update variant */
|
|
62
|
+
variant?: ISecretVariant;
|
|
63
|
+
/** Optional: update name */
|
|
64
|
+
name?: string;
|
|
65
|
+
/** Optional: update description */
|
|
66
|
+
description?: string;
|
|
67
|
+
/** Optional: update value (plain text, will be Base64 encoded) */
|
|
68
|
+
value?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Response from creating a secret.
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
export interface CreateSecretResponse {
|
|
75
|
+
success: boolean;
|
|
76
|
+
message: string;
|
|
77
|
+
secret: SecretData;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Response from getting a secret.
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
export interface GetSecretResponse {
|
|
84
|
+
success: boolean;
|
|
85
|
+
message: string;
|
|
86
|
+
secret: SecretData;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Response from listing secrets.
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
export interface ListSecretsResponse {
|
|
93
|
+
success: boolean;
|
|
94
|
+
message: string;
|
|
95
|
+
secrets: SecretData[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Response from updating a secret.
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
export interface UpdateSecretResponse {
|
|
102
|
+
success: boolean;
|
|
103
|
+
message: string;
|
|
104
|
+
secret: SecretData;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Response from deleting a secret.
|
|
108
|
+
*/
|
|
109
|
+
export interface DeleteSecretResponse {
|
|
110
|
+
success: boolean;
|
|
111
|
+
message: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Secret domain model for the Datalayer SDK.
|
|
115
|
+
* Provides state management and operations for user secrets.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const secret = await sdk.createSecret({
|
|
120
|
+
* variant: 'password',
|
|
121
|
+
* name: 'db_password',
|
|
122
|
+
* description: 'Production DB password',
|
|
123
|
+
* value: 'my-secure-password'
|
|
124
|
+
* });
|
|
125
|
+
*
|
|
126
|
+
* await secret.update({ description: 'Updated description' });
|
|
127
|
+
* await secret.delete();
|
|
128
|
+
* ```
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
export declare class SecretDTO {
|
|
132
|
+
/** @internal */
|
|
133
|
+
_data: SecretData;
|
|
134
|
+
private _sdk;
|
|
135
|
+
private _deleted;
|
|
136
|
+
/**
|
|
137
|
+
* Create a Secret instance.
|
|
138
|
+
* @param data - Secret data from API
|
|
139
|
+
* @param sdk - SDK instance
|
|
140
|
+
*/
|
|
141
|
+
constructor(data: SecretData, sdk: DatalayerClient);
|
|
142
|
+
private _checkDeleted;
|
|
143
|
+
private _decodeValue;
|
|
144
|
+
get uid(): string;
|
|
145
|
+
get variant(): ISecretVariant;
|
|
146
|
+
get name(): string;
|
|
147
|
+
get description(): string;
|
|
148
|
+
/** Returns decoded (plain text) secret value */
|
|
149
|
+
get value(): string;
|
|
150
|
+
/**
|
|
151
|
+
* Update this secret.
|
|
152
|
+
* @param updates - Fields to update
|
|
153
|
+
* @returns Updated Secret instance
|
|
154
|
+
*/
|
|
155
|
+
update(updates: UpdateSecretRequest): Promise<SecretDTO>;
|
|
156
|
+
/**
|
|
157
|
+
* Delete this secret permanently.
|
|
158
|
+
*/
|
|
159
|
+
delete(): Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* Get secret data in camelCase format.
|
|
162
|
+
*/
|
|
163
|
+
toJSON(): SecretJSON;
|
|
164
|
+
/**
|
|
165
|
+
* Get raw secret data exactly as received from API.
|
|
166
|
+
*/
|
|
167
|
+
rawData(): SecretData;
|
|
168
|
+
toString(): string;
|
|
169
|
+
}
|
package/lib/models/Secret.js
CHANGED
|
@@ -11,3 +11,138 @@ export const asSecret = (s) => {
|
|
|
11
11
|
value: s.value_s,
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// New API Types and DTO
|
|
16
|
+
// ============================================================================
|
|
17
|
+
import { validateJSON } from '../api/utils/validation';
|
|
18
|
+
/**
|
|
19
|
+
* Secret domain model for the Datalayer SDK.
|
|
20
|
+
* Provides state management and operations for user secrets.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const secret = await sdk.createSecret({
|
|
25
|
+
* variant: 'password',
|
|
26
|
+
* name: 'db_password',
|
|
27
|
+
* description: 'Production DB password',
|
|
28
|
+
* value: 'my-secure-password'
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* await secret.update({ description: 'Updated description' });
|
|
32
|
+
* await secret.delete();
|
|
33
|
+
* ```
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export class SecretDTO {
|
|
37
|
+
/** @internal */
|
|
38
|
+
_data;
|
|
39
|
+
_sdk;
|
|
40
|
+
_deleted = false;
|
|
41
|
+
/**
|
|
42
|
+
* Create a Secret instance.
|
|
43
|
+
* @param data - Secret data from API
|
|
44
|
+
* @param sdk - SDK instance
|
|
45
|
+
*/
|
|
46
|
+
constructor(data, sdk) {
|
|
47
|
+
this._data = data;
|
|
48
|
+
this._sdk = sdk;
|
|
49
|
+
}
|
|
50
|
+
// ========================================================================
|
|
51
|
+
// Helper Methods
|
|
52
|
+
// ========================================================================
|
|
53
|
+
_checkDeleted() {
|
|
54
|
+
if (this._deleted) {
|
|
55
|
+
throw new Error(`Secret ${this._data.name_s} has been deleted and no longer exists`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
_decodeValue(encodedValue) {
|
|
59
|
+
try {
|
|
60
|
+
if (typeof Buffer !== 'undefined') {
|
|
61
|
+
// Node.js environment
|
|
62
|
+
return Buffer.from(encodedValue, 'base64').toString();
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// Browser environment
|
|
66
|
+
return atob(encodedValue);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
console.error('Failed to decode secret value:', error);
|
|
71
|
+
return encodedValue; // Return as-is if decode fails
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// ========================================================================
|
|
75
|
+
// Properties
|
|
76
|
+
// ========================================================================
|
|
77
|
+
get uid() {
|
|
78
|
+
this._checkDeleted();
|
|
79
|
+
return this._data.uid;
|
|
80
|
+
}
|
|
81
|
+
get variant() {
|
|
82
|
+
this._checkDeleted();
|
|
83
|
+
return this._data.variant_s;
|
|
84
|
+
}
|
|
85
|
+
get name() {
|
|
86
|
+
this._checkDeleted();
|
|
87
|
+
return this._data.name_s;
|
|
88
|
+
}
|
|
89
|
+
get description() {
|
|
90
|
+
this._checkDeleted();
|
|
91
|
+
return this._data.description_t;
|
|
92
|
+
}
|
|
93
|
+
/** Returns decoded (plain text) secret value */
|
|
94
|
+
get value() {
|
|
95
|
+
this._checkDeleted();
|
|
96
|
+
return this._decodeValue(this._data.value_s);
|
|
97
|
+
}
|
|
98
|
+
// ========================================================================
|
|
99
|
+
// Action Methods
|
|
100
|
+
// ========================================================================
|
|
101
|
+
/**
|
|
102
|
+
* Update this secret.
|
|
103
|
+
* @param updates - Fields to update
|
|
104
|
+
* @returns Updated Secret instance
|
|
105
|
+
*/
|
|
106
|
+
async update(updates) {
|
|
107
|
+
this._checkDeleted();
|
|
108
|
+
const updated = await this._sdk.updateSecret(this.uid, updates);
|
|
109
|
+
return updated;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Delete this secret permanently.
|
|
113
|
+
*/
|
|
114
|
+
async delete() {
|
|
115
|
+
this._checkDeleted();
|
|
116
|
+
await this._sdk.deleteSecret(this.uid);
|
|
117
|
+
this._deleted = true;
|
|
118
|
+
}
|
|
119
|
+
// ========================================================================
|
|
120
|
+
// Utility Methods
|
|
121
|
+
// ========================================================================
|
|
122
|
+
/**
|
|
123
|
+
* Get secret data in camelCase format.
|
|
124
|
+
*/
|
|
125
|
+
toJSON() {
|
|
126
|
+
this._checkDeleted();
|
|
127
|
+
const obj = {
|
|
128
|
+
uid: this.uid,
|
|
129
|
+
variant: this.variant,
|
|
130
|
+
name: this.name,
|
|
131
|
+
description: this.description,
|
|
132
|
+
value: this.value, // Returns decoded value
|
|
133
|
+
};
|
|
134
|
+
validateJSON(obj, 'Secret');
|
|
135
|
+
return obj;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get raw secret data exactly as received from API.
|
|
139
|
+
*/
|
|
140
|
+
rawData() {
|
|
141
|
+
this._checkDeleted();
|
|
142
|
+
return this._data;
|
|
143
|
+
}
|
|
144
|
+
toString() {
|
|
145
|
+
this._checkDeleted();
|
|
146
|
+
return `Secret(${this.name}, ${this.variant})`;
|
|
147
|
+
}
|
|
148
|
+
}
|
package/lib/models/SpaceDTO.d.ts
CHANGED
|
@@ -202,17 +202,6 @@ export interface GetNotebookResponse {
|
|
|
202
202
|
message: string;
|
|
203
203
|
notebook?: NotebookData;
|
|
204
204
|
}
|
|
205
|
-
/**
|
|
206
|
-
* Request payload for creating a notebook
|
|
207
|
-
* @interface CreateNotebookRequest
|
|
208
|
-
*/
|
|
209
|
-
export interface CreateNotebookRequest {
|
|
210
|
-
spaceId: string;
|
|
211
|
-
notebookType: string;
|
|
212
|
-
name: string;
|
|
213
|
-
description: string;
|
|
214
|
-
file?: File | Blob;
|
|
215
|
-
}
|
|
216
205
|
/**
|
|
217
206
|
* Request payload for updating a notebook
|
|
218
207
|
* @interface UpdateNotebookRequest
|
package/lib/models/index.d.ts
CHANGED
package/lib/models/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import type { ICredits, ICreditsReservation } from '../../models';
|
|
|
4
4
|
* Limit to warn about low credits in milliseconds.
|
|
5
5
|
*/
|
|
6
6
|
export declare const RESERVATION_WARNING_TIME_MS: number;
|
|
7
|
-
type IAMProviderAuthorizationURL = string;
|
|
7
|
+
export type IAMProviderAuthorizationURL = string;
|
|
8
8
|
export type IIAMState = {
|
|
9
9
|
/**
|
|
10
10
|
* User credits
|