@datalayer/core 0.0.20 → 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 (46) hide show
  1. package/lib/api/iam/datasources.d.ts +86 -0
  2. package/lib/api/iam/datasources.js +185 -0
  3. package/lib/api/iam/index.d.ts +2 -0
  4. package/lib/api/iam/index.js +2 -0
  5. package/lib/api/iam/secrets.d.ts +85 -0
  6. package/lib/api/iam/secrets.js +196 -0
  7. package/lib/client/auth/storage.js +17 -62
  8. package/lib/client/base.d.ts +3 -0
  9. package/lib/client/base.js +2 -2
  10. package/lib/client/index.d.ts +82 -3
  11. package/lib/client/index.js +5 -1
  12. package/lib/client/mixins/IAMMixin.d.ts +62 -0
  13. package/lib/client/mixins/IAMMixin.js +116 -0
  14. package/lib/collaboration/DatalayerCollaboration.d.ts +1 -2
  15. package/lib/collaboration/DatalayerCollaborationProvider.d.ts +1 -1
  16. package/lib/collaboration/DatalayerCollaborationProvider.js +1 -1
  17. package/lib/hooks/useBackdrop.d.ts +2 -3
  18. package/lib/hooks/useBackdropJupyterLab.d.ts +2 -2
  19. package/lib/hooks/useCache.d.ts +3 -3
  20. package/lib/hooks/useScreenshot.d.ts +2 -3
  21. package/lib/hooks/useWindowSize.d.ts +1 -2
  22. package/lib/index.d.ts +1 -1
  23. package/lib/index.js +3 -1
  24. package/lib/models/Datasource.d.ts +170 -0
  25. package/lib/models/Datasource.js +140 -0
  26. package/lib/models/Runtime.d.ts +1 -1
  27. package/lib/models/RuntimeSnapshotDTO.d.ts +1 -1
  28. package/lib/models/RuntimeSnapshotDTO.js +1 -1
  29. package/lib/models/Secret.d.ts +159 -0
  30. package/lib/models/Secret.js +135 -0
  31. package/lib/models/SpaceDTO.d.ts +0 -11
  32. package/lib/state/substates/IAMState.d.ts +1 -1
  33. package/lib/state/substates/LayoutState.d.ts +2 -2
  34. package/lib/state/substates/NbformatState.d.ts +1 -1
  35. package/lib/utils/File.d.ts +1 -1
  36. package/lib/utils/File.js +1 -1
  37. package/lib/utils/Notebook.d.ts +5 -3
  38. package/lib/utils/Notebook.js +5 -3
  39. package/package.json +7 -5
  40. package/patches/.gitkeep +1 -0
  41. package/patches/@datalayer+jupyter-lexical+1.0.7.patch +5491 -0
  42. package/patches/@datalayer+jupyter-react+2.0.1.patch +2674 -0
  43. package/scripts/apply-patches.sh +44 -0
  44. package/scripts/create-patches.sh +40 -0
  45. package/scripts/fix-esm-imports.cjs +124 -0
  46. package/scripts/sync-jupyter.sh +121 -0
@@ -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
@@ -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
@@ -6,12 +6,12 @@ export type BackdropDisplay = {
6
6
  open: boolean;
7
7
  message?: string | void;
8
8
  };
9
- type BannerDisplay = {
9
+ export type BannerDisplay = {
10
10
  message: string;
11
11
  variant: BannerDisplayVariant;
12
12
  timestamp?: Date;
13
13
  };
14
- type PortalDisplay = {
14
+ export type PortalDisplay = {
15
15
  portal: ReactPortal;
16
16
  pinned: boolean;
17
17
  };
@@ -1,4 +1,4 @@
1
- type SaveRequest = {
1
+ export type SaveRequest = {
2
2
  counter: number;
3
3
  };
4
4
  export type INbformatState = {
@@ -2,6 +2,6 @@
2
2
  * creates name of file.
3
3
  *
4
4
  * @param {string} extension
5
- * @param {string[]} parts of file name
5
+ * @param {string[]} names parts of file name
6
6
  */
7
7
  export declare const createFileName: (extension?: string, ...names: any[]) => string;
package/lib/utils/File.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * creates name of file.
7
7
  *
8
8
  * @param {string} extension
9
- * @param {string[]} parts of file name
9
+ * @param {string[]} names parts of file name
10
10
  */
11
11
  export const createFileName = (extension = '', ...names) => {
12
12
  if (!extension) {
@@ -2,9 +2,11 @@ import { JupyterLab } from '@jupyterlab/application';
2
2
  /**
3
3
  * Create a notebook
4
4
  *
5
- * @param app JupyterLab application
6
- * @param name Notebook name
7
- * @param url Notebook content URL
5
+ * @param params Configuration object
6
+ * @param params.app JupyterLab application
7
+ * @param params.name Notebook name
8
+ * @param params.url Notebook content URL
9
+ * @param params.options Additional options for notebook creation
8
10
  */
9
11
  export declare const createNotebook: ({ app, name, url, options, }: {
10
12
  app: JupyterLab;
@@ -5,9 +5,11 @@
5
5
  /**
6
6
  * Create a notebook
7
7
  *
8
- * @param app JupyterLab application
9
- * @param name Notebook name
10
- * @param url Notebook content URL
8
+ * @param params Configuration object
9
+ * @param params.app JupyterLab application
10
+ * @param params.name Notebook name
11
+ * @param params.url Notebook content URL
12
+ * @param params.options Additional options for notebook creation
11
13
  */
12
14
  export const createNotebook = async ({ app, name, url, options, }) => {
13
15
  const notebook = await app.commands.execute('notebook:create-new', options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/core",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "type": "module",
5
5
  "workspaces": [
6
6
  ".",
@@ -22,7 +22,9 @@
22
22
  "files": [
23
23
  "lib/**/*.{css,d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
24
24
  "style/**/*.{css,js,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
25
- "schema/*.json"
25
+ "schema/*.json",
26
+ "patches/",
27
+ "scripts/"
26
28
  ],
27
29
  "main": "lib/index.js",
28
30
  "types": "lib/index.d.ts",
@@ -50,7 +52,7 @@
50
52
  "clean:dist": "rimraf dist",
51
53
  "clean:cache": "rimraf node_modules/.vite",
52
54
  "build": "npm run clean && gulp resources-to-lib && tsc -b && vite build",
53
- "build:lib": "npm run clean:lib && gulp resources-to-lib && tsc -b",
55
+ "build:lib": "npm run clean:lib && gulp resources-to-lib && tsc -b && node scripts/fix-esm-imports.cjs",
54
56
  "build:types": "npm run clean:lib && tsc -b",
55
57
  "build:nextjs": "npm run build --workspace=nextjs-notebook-example",
56
58
  "build:examples": "npm run build:nextjs",
@@ -81,6 +83,7 @@
81
83
  "storybook": "storybook dev -p 6006",
82
84
  "build-storybook": "storybook build",
83
85
  "typedoc": "typedoc --options typedoc.json --out docs/docs/typescript_api",
86
+ "docs": "make typedoc && make pydoc && cd docs && npm install && npm run build",
84
87
  "watch:lib": "run-p 'watch:lib:*'",
85
88
  "watch:lib:res": "gulp resources-to-lib-watch",
86
89
  "watch:lib:src": "tsc -b -w",
@@ -89,7 +92,7 @@
89
92
  "examples:vite": "VITE_DATALAYER_RUN_URL=http://localhost:8888 vite --config vite.examples.config.ts",
90
93
  "examples:nextjs": "npm run dev --workspace=nextjs-notebook-example",
91
94
  "jupyter:start": "./dev/sh/start-jupyter-server.sh",
92
- "prepare": "husky",
95
+ "prepare": "husky || true",
93
96
  "postinstall": "bash scripts/apply-patches.sh",
94
97
  "kill": "./dev/sh/kill.sh || true",
95
98
  "sync:jupyter": "bash scripts/sync-jupyter.sh",
@@ -137,7 +140,6 @@
137
140
  "@tailwindcss/vite": "^4.1.13",
138
141
  "@tanstack/react-query": "^5.90.6",
139
142
  "@toon-format/toon": "^1.3.0",
140
- "ai": "^5.0.78",
141
143
  "ansi-to-html": "^0.7.2",
142
144
  "axios": "^1.7.7",
143
145
  "boring-avatars": "^2.0.1",
@@ -0,0 +1 @@
1
+ # Patches directory for patch-package