@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.
Files changed (129) hide show
  1. package/lib/App.js +0 -5
  2. package/lib/api/iam/datasources.d.ts +86 -0
  3. package/lib/api/iam/datasources.js +185 -0
  4. package/lib/api/iam/index.d.ts +2 -0
  5. package/lib/api/iam/index.js +2 -0
  6. package/lib/api/iam/secrets.d.ts +85 -0
  7. package/lib/api/iam/secrets.js +196 -0
  8. package/lib/client/auth/storage.js +17 -62
  9. package/lib/client/base.d.ts +3 -0
  10. package/lib/client/base.js +2 -2
  11. package/lib/client/index.d.ts +82 -3
  12. package/lib/client/index.js +5 -1
  13. package/lib/client/mixins/IAMMixin.d.ts +62 -0
  14. package/lib/client/mixins/IAMMixin.js +116 -0
  15. package/lib/collaboration/DatalayerCollaboration.d.ts +1 -2
  16. package/lib/collaboration/DatalayerCollaborationProvider.d.ts +1 -1
  17. package/lib/collaboration/DatalayerCollaborationProvider.js +1 -1
  18. package/lib/components/auth/Login.js +0 -5
  19. package/lib/components/auth/index.js +1 -6
  20. package/lib/components/index.d.ts +0 -1
  21. package/lib/components/index.js +0 -1
  22. package/lib/components/toolbars/AssignmentEditorToolbar.js +9 -7
  23. package/lib/examples/CellExample.js +4 -3
  24. package/lib/examples/NotebookExample.js +2 -7
  25. package/lib/hooks/index.d.ts +0 -2
  26. package/lib/hooks/index.js +0 -2
  27. package/lib/hooks/useBackdrop.d.ts +2 -3
  28. package/lib/hooks/useBackdropJupyterLab.d.ts +2 -2
  29. package/lib/hooks/useCache.d.ts +18 -4
  30. package/lib/hooks/useCache.js +87 -69
  31. package/lib/hooks/useScreenshot.d.ts +2 -3
  32. package/lib/hooks/useWindowSize.d.ts +1 -2
  33. package/lib/index.d.ts +2 -1
  34. package/lib/index.js +6 -2
  35. package/lib/main.js +4 -1
  36. package/lib/models/Datasource.d.ts +170 -0
  37. package/lib/models/Datasource.js +140 -0
  38. package/lib/models/Runtime.d.ts +1 -1
  39. package/lib/models/RuntimeSnapshotDTO.d.ts +1 -1
  40. package/lib/models/RuntimeSnapshotDTO.js +1 -1
  41. package/lib/models/Secret.d.ts +159 -0
  42. package/lib/models/Secret.js +135 -0
  43. package/lib/models/SpaceDTO.d.ts +0 -11
  44. package/lib/models/index.d.ts +0 -1
  45. package/lib/models/index.js +0 -1
  46. package/lib/state/substates/IAMState.d.ts +1 -1
  47. package/lib/state/substates/LayoutState.d.ts +2 -2
  48. package/lib/state/substates/NbformatState.d.ts +1 -1
  49. package/lib/state/substates/index.d.ts +0 -1
  50. package/lib/state/substates/index.js +0 -1
  51. package/lib/utils/File.d.ts +1 -1
  52. package/lib/utils/File.js +1 -1
  53. package/lib/utils/Notebook.d.ts +5 -3
  54. package/lib/utils/Notebook.js +5 -3
  55. package/lib/utils/cli/index.js +0 -5
  56. package/lib/utils/cli/query.js +0 -5
  57. package/lib/views/datasources/DatasourceDetail.d.ts +2 -0
  58. package/lib/views/datasources/DatasourceDetail.js +91 -0
  59. package/lib/views/datasources/DatasourceNew.d.ts +2 -0
  60. package/lib/views/datasources/DatasourceNew.js +118 -0
  61. package/lib/views/datasources/Datasources.d.ts +2 -0
  62. package/lib/views/datasources/Datasources.js +49 -0
  63. package/lib/views/datasources/index.d.ts +3 -0
  64. package/lib/views/datasources/index.js +7 -0
  65. package/lib/views/iam-tokens/IAMTokenEdit.d.ts +2 -0
  66. package/lib/views/iam-tokens/IAMTokenEdit.js +86 -0
  67. package/lib/views/iam-tokens/IAMTokenNew.d.ts +2 -0
  68. package/lib/views/iam-tokens/IAMTokenNew.js +118 -0
  69. package/lib/views/iam-tokens/IAMTokens.d.ts +2 -0
  70. package/lib/views/iam-tokens/IAMTokens.js +53 -0
  71. package/lib/views/iam-tokens/Tokens.d.ts +2 -0
  72. package/lib/views/iam-tokens/Tokens.js +53 -0
  73. package/lib/views/iam-tokens/index.d.ts +3 -0
  74. package/lib/views/iam-tokens/index.js +7 -0
  75. package/lib/views/index.d.ts +1 -0
  76. package/lib/views/secrets/SecretEdit.d.ts +2 -0
  77. package/lib/views/secrets/SecretEdit.js +149 -0
  78. package/lib/views/secrets/SecretNew.d.ts +2 -0
  79. package/lib/views/secrets/SecretNew.js +99 -0
  80. package/lib/views/secrets/Secrets.d.ts +2 -0
  81. package/lib/views/secrets/Secrets.js +48 -0
  82. package/lib/views/secrets/index.d.ts +3 -0
  83. package/lib/views/secrets/index.js +7 -0
  84. package/package.json +15 -16
  85. package/patches/.gitkeep +1 -0
  86. package/patches/@datalayer+jupyter-lexical+1.0.7.patch +5491 -0
  87. package/patches/@datalayer+jupyter-react+2.0.1.patch +2674 -0
  88. package/scripts/apply-patches.sh +44 -0
  89. package/scripts/create-patches.sh +40 -0
  90. package/scripts/fix-esm-imports.cjs +124 -0
  91. package/scripts/sync-jupyter.sh +121 -0
  92. package/lib/components/chat/ChatComponent.d.ts +0 -4
  93. package/lib/components/chat/ChatComponent.js +0 -143
  94. package/lib/components/chat/MessagePart.d.ts +0 -11
  95. package/lib/components/chat/MessagePart.js +0 -23
  96. package/lib/components/chat/display/DynamicToolPart.d.ts +0 -6
  97. package/lib/components/chat/display/DynamicToolPart.js +0 -5
  98. package/lib/components/chat/display/ReasoningPart.d.ts +0 -6
  99. package/lib/components/chat/display/ReasoningPart.js +0 -58
  100. package/lib/components/chat/display/TextPart.d.ts +0 -9
  101. package/lib/components/chat/display/TextPart.js +0 -93
  102. package/lib/components/chat/display/ToolPart.d.ts +0 -6
  103. package/lib/components/chat/display/ToolPart.js +0 -148
  104. package/lib/components/chat/display/index.d.ts +0 -4
  105. package/lib/components/chat/display/index.js +0 -13
  106. package/lib/components/chat/handler.d.ts +0 -8
  107. package/lib/components/chat/handler.js +0 -43
  108. package/lib/components/chat/index.d.ts +0 -4
  109. package/lib/components/chat/index.js +0 -13
  110. package/lib/hooks/useAIAgents.d.ts +0 -13
  111. package/lib/hooks/useAIAgents.js +0 -72
  112. package/lib/hooks/useAIJupyterChat.d.ts +0 -36
  113. package/lib/hooks/useAIJupyterChat.js +0 -53
  114. package/lib/hooks/useNotebookAIAgent.d.ts +0 -8
  115. package/lib/hooks/useNotebookAIAgent.js +0 -56
  116. package/lib/models/AIAgent.d.ts +0 -17
  117. package/lib/state/substates/AIAgentState.d.ts +0 -11
  118. package/lib/state/substates/AIAgentState.js +0 -42
  119. package/lib/tools/adapters/agui/AgUIToolAdapter.d.ts +0 -75
  120. package/lib/tools/adapters/agui/AgUIToolAdapter.js +0 -244
  121. package/lib/tools/adapters/agui/index.d.ts +0 -10
  122. package/lib/tools/adapters/agui/index.js +0 -19
  123. package/lib/tools/adapters/agui/lexicalHooks.d.ts +0 -27
  124. package/lib/tools/adapters/agui/lexicalHooks.js +0 -64
  125. package/lib/tools/adapters/agui/notebookHooks.d.ts +0 -27
  126. package/lib/tools/adapters/agui/notebookHooks.js +0 -61
  127. package/lib/tools/index.d.ts +0 -6
  128. package/lib/tools/index.js +0 -18
  129. 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
+ }
@@ -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
+ }
@@ -114,7 +114,7 @@ export interface IRuntimeDesc {
114
114
  /**
115
115
  * Runtime type.
116
116
  *
117
- * TODO refactor with type { RuntimeLocation }
117
+ * TODO refactor with type `IRuntimeLocation`
118
118
  */
119
119
  export type IRuntimeType = 'notebook' | 'cell';
120
120
  /**
@@ -148,7 +148,7 @@ export declare class RuntimeSnapshotDTO {
148
148
  /**
149
149
  * Create a runtime from this snapshot (restore functionality).
150
150
  *
151
- * @param config - Optional runtime configuration to override defaults
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 config - Optional runtime configuration to override defaults
88
+ * @param minutesLimit - Time limit in minutes for the restored runtime
89
89
  * @returns Created Runtime instance
90
90
  */
91
91
  async restore(minutesLimit) {
@@ -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
+ }
@@ -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
+ }
@@ -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
@@ -28,7 +28,6 @@
28
28
  *
29
29
  * @module models
30
30
  */
31
- export * from './AIAgent';
32
31
  export * from './Assignment';
33
32
  export * from './Base';
34
33
  export * from './Cell';
@@ -32,7 +32,6 @@
32
32
  *
33
33
  * @module models
34
34
  */
35
- export * from './AIAgent';
36
35
  export * from './Assignment';
37
36
  export * from './Base';
38
37
  export * from './Cell';
@@ -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