@oceanum/oceanumlab 4.7.0 → 4.7.2

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 (81) hide show
  1. package/README.md +102 -11
  2. package/lib/DatameshUI.d.ts +1 -6
  3. package/lib/DatameshUI.js +1 -9
  4. package/lib/DatameshWidget.d.ts +18 -2
  5. package/lib/DatameshWidget.js +80 -12
  6. package/lib/StoredNotebooks.d.ts +20 -0
  7. package/lib/StoredNotebooks.js +112 -0
  8. package/lib/Tabs.d.ts +26 -0
  9. package/lib/Tabs.js +45 -0
  10. package/lib/aiBackend.d.ts +1 -1
  11. package/lib/aiBackend.js +1 -1
  12. package/lib/auth/accountWidget.d.ts +35 -0
  13. package/lib/auth/accountWidget.js +95 -0
  14. package/lib/auth/claims.d.ts +3 -0
  15. package/lib/auth/claims.js +25 -0
  16. package/lib/auth/plugin.d.ts +9 -0
  17. package/lib/auth/plugin.js +126 -0
  18. package/lib/auth/serverAuth.d.ts +79 -0
  19. package/lib/auth/serverAuth.js +254 -0
  20. package/lib/auth/startSignIn.d.ts +11 -0
  21. package/lib/auth/startSignIn.js +16 -0
  22. package/lib/auth/tokens.d.ts +102 -0
  23. package/lib/auth/tokens.js +9 -0
  24. package/lib/chatRouter.d.ts +13 -1
  25. package/lib/chatRouter.js +9 -2
  26. package/lib/constants.d.ts +1 -1
  27. package/lib/constants.js +1 -1
  28. package/lib/datameshUiUrl.d.ts +2 -2
  29. package/lib/datameshUiUrl.js +6 -6
  30. package/lib/index.d.ts +8 -1
  31. package/lib/index.js +58 -17
  32. package/lib/share/client.d.ts +84 -0
  33. package/lib/share/client.js +205 -0
  34. package/lib/share/events.d.ts +7 -0
  35. package/lib/share/events.js +9 -0
  36. package/lib/share/notebook.d.ts +184 -0
  37. package/lib/share/notebook.js +277 -0
  38. package/lib/share/oceanumOnly.d.ts +49 -0
  39. package/lib/share/oceanumOnly.js +90 -0
  40. package/lib/share/plugin.d.ts +21 -0
  41. package/lib/share/plugin.js +883 -0
  42. package/lib/share/widgets.d.ts +25 -0
  43. package/lib/share/widgets.js +154 -0
  44. package/package.json +13 -1
  45. package/schema/datamesh-connect.json +3 -12
  46. package/src/DatameshUI.tsx +1 -10
  47. package/src/DatameshWidget.tsx +143 -19
  48. package/src/StoredNotebooks.tsx +206 -0
  49. package/src/Tabs.tsx +102 -0
  50. package/src/__tests__/DatameshWidget.spec.tsx +33 -20
  51. package/src/__tests__/OceanumPanel.spec.tsx +157 -0
  52. package/src/__tests__/StoredNotebooks.spec.tsx +157 -0
  53. package/src/__tests__/Tabs.spec.tsx +168 -0
  54. package/src/__tests__/aiBackend.spec.ts +5 -6
  55. package/src/__tests__/chatRouter.spec.ts +9 -15
  56. package/src/__tests__/datameshUiUrl.spec.ts +4 -3
  57. package/src/__tests__/oceanumOnly.spec.ts +193 -0
  58. package/src/__tests__/pluginArity.spec.ts +24 -0
  59. package/src/__tests__/serverAuth.spec.ts +277 -0
  60. package/src/__tests__/settingsSchema.spec.ts +73 -0
  61. package/src/__tests__/shareClient.spec.ts +314 -0
  62. package/src/__tests__/shareNotebook.spec.ts +451 -0
  63. package/src/__tests__/sharePlugin.spec.ts +426 -0
  64. package/src/aiBackend.ts +1 -1
  65. package/src/auth/accountWidget.ts +113 -0
  66. package/src/auth/claims.ts +30 -0
  67. package/src/auth/plugin.ts +155 -0
  68. package/src/auth/serverAuth.ts +342 -0
  69. package/src/auth/startSignIn.ts +23 -0
  70. package/src/auth/tokens.ts +111 -0
  71. package/src/chatRouter.ts +8 -4
  72. package/src/constants.ts +1 -1
  73. package/src/datameshUiUrl.ts +6 -6
  74. package/src/index.ts +87 -36
  75. package/src/share/client.ts +288 -0
  76. package/src/share/events.ts +10 -0
  77. package/src/share/notebook.ts +416 -0
  78. package/src/share/oceanumOnly.ts +126 -0
  79. package/src/share/plugin.ts +1096 -0
  80. package/src/share/widgets.ts +217 -0
  81. package/style/index.css +266 -13
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Oceanum-only file management: what a deployment gets when its environment says
3
+ * `fileManagement: 'oceanum'`, as notebook.oceanum.io does.
4
+ *
5
+ * The local drive stays as the working copy underneath, out of sight: the file browser
6
+ * is taken out of the sidebar, the File menu loses the entries that manage local files,
7
+ * and every completed local save is pushed to the spec store, so Ctrl+S, the toolbar
8
+ * button, Save All and autosave all reach Oceanum.
9
+ */
10
+ import type { INotebookTracker, NotebookPanel } from '@jupyterlab/notebook';
11
+ import type { Menu, Widget } from '@lumino/widgets';
12
+ /** The widget id `@jupyterlab/filebrowser-extension:browser` gives the file browser. */
13
+ export declare const FILE_BROWSER_ID = "filebrowser";
14
+ /**
15
+ * File menu entries that manage local files. Save, Save All and Rename stay: saving is
16
+ * routed to Oceanum, and renaming the local file is how a notebook gets its name.
17
+ */
18
+ export declare const LOCAL_FILE_COMMANDS: readonly string[];
19
+ /**
20
+ * Take the file browser out of the sidebar; true if it was there. It is closed, not
21
+ * disposed: other extensions hold it through IDefaultFileBrowser and still use it to
22
+ * open paths.
23
+ */
24
+ export declare function hideFileBrowser(shell: {
25
+ widgets(area: 'left'): Iterable<Widget>;
26
+ }): boolean;
27
+ /**
28
+ * Submenus of local files. "Open Recent" is built by the document manager rather than
29
+ * declared in a schema, and its menu has no id, so it is known by the commands it holds.
30
+ */
31
+ export declare const LOCAL_FILE_SUBMENU_COMMANDS: readonly string[];
32
+ /**
33
+ * Remove the local-file entries from a menu; returns how many went. Idempotent, so it
34
+ * can run every time the menu is about to show: entries arrive from settings schemas as
35
+ * plugins load, not all at once.
36
+ */
37
+ export declare function pruneFileMenu(menu: Menu, commands?: readonly string[]): number;
38
+ /**
39
+ * Prune the menu again every time it opens. Entries arrive from settings schemas as
40
+ * plugins load rather than all at once, and a menu has no "about to show" signal; it
41
+ * is attached to the document each time it opens, which a message hook can watch.
42
+ */
43
+ export declare function pruneBeforeEachOpen(menu: Menu, commands?: readonly string[]): void;
44
+ /**
45
+ * Call `push` after every completed local save of every notebook, open now or later.
46
+ * `push` must guard against its own saves: writing the record link back to the notebook
47
+ * saves it again.
48
+ */
49
+ export declare function routeSaves(tracker: INotebookTracker, push: (panel: NotebookPanel) => Promise<void>): void;
@@ -0,0 +1,90 @@
1
+ import { MessageLoop } from '@lumino/messaging';
2
+ /** The widget id `@jupyterlab/filebrowser-extension:browser` gives the file browser. */
3
+ export const FILE_BROWSER_ID = 'filebrowser';
4
+ /**
5
+ * File menu entries that manage local files. Save, Save All and Rename stay: saving is
6
+ * routed to Oceanum, and renaming the local file is how a notebook gets its name.
7
+ */
8
+ export const LOCAL_FILE_COMMANDS = [
9
+ 'filebrowser:open-path',
10
+ 'filebrowser:open-url',
11
+ 'docmanager:save-as',
12
+ 'docmanager:reload',
13
+ 'docmanager:restore-checkpoint',
14
+ 'docmanager:duplicate',
15
+ 'docmanager:download'
16
+ ];
17
+ /**
18
+ * Take the file browser out of the sidebar; true if it was there. It is closed, not
19
+ * disposed: other extensions hold it through IDefaultFileBrowser and still use it to
20
+ * open paths.
21
+ */
22
+ export function hideFileBrowser(shell) {
23
+ for (const widget of shell.widgets('left')) {
24
+ if (widget.id === FILE_BROWSER_ID) {
25
+ widget.close();
26
+ return true;
27
+ }
28
+ }
29
+ return false;
30
+ }
31
+ /**
32
+ * Submenus of local files. "Open Recent" is built by the document manager rather than
33
+ * declared in a schema, and its menu has no id, so it is known by the commands it holds.
34
+ */
35
+ export const LOCAL_FILE_SUBMENU_COMMANDS = [
36
+ 'docmanager:open-recent',
37
+ 'docmanager:clear-recents'
38
+ ];
39
+ function isLocalSubmenu(item) {
40
+ return (item.type === 'submenu' &&
41
+ !!item.submenu &&
42
+ (item.submenu.title.label === 'Open Recent' ||
43
+ item.submenu.items.some(child => LOCAL_FILE_SUBMENU_COMMANDS.includes(child.command))));
44
+ }
45
+ /**
46
+ * Remove the local-file entries from a menu; returns how many went. Idempotent, so it
47
+ * can run every time the menu is about to show: entries arrive from settings schemas as
48
+ * plugins load, not all at once.
49
+ */
50
+ export function pruneFileMenu(menu, commands = LOCAL_FILE_COMMANDS) {
51
+ let removed = 0;
52
+ for (let i = menu.items.length - 1; i >= 0; i--) {
53
+ const item = menu.items[i];
54
+ if ((item.type === 'command' && commands.includes(item.command)) ||
55
+ isLocalSubmenu(item)) {
56
+ menu.removeItemAt(i);
57
+ removed++;
58
+ }
59
+ }
60
+ return removed;
61
+ }
62
+ /**
63
+ * Prune the menu again every time it opens. Entries arrive from settings schemas as
64
+ * plugins load rather than all at once, and a menu has no "about to show" signal; it
65
+ * is attached to the document each time it opens, which a message hook can watch.
66
+ */
67
+ export function pruneBeforeEachOpen(menu, commands = LOCAL_FILE_COMMANDS) {
68
+ MessageLoop.installMessageHook(menu, (_, message) => {
69
+ if (message.type === 'before-attach') {
70
+ pruneFileMenu(menu, commands);
71
+ }
72
+ return true;
73
+ });
74
+ }
75
+ /**
76
+ * Call `push` after every completed local save of every notebook, open now or later.
77
+ * `push` must guard against its own saves: writing the record link back to the notebook
78
+ * saves it again.
79
+ */
80
+ export function routeSaves(tracker, push) {
81
+ const watch = (panel) => {
82
+ panel.context.saveState.connect((_, state) => {
83
+ if (state === 'completed') {
84
+ void push(panel);
85
+ }
86
+ });
87
+ };
88
+ tracker.forEach(watch);
89
+ tracker.widgetAdded.connect((_, panel) => watch(panel));
90
+ }
@@ -0,0 +1,21 @@
1
+ import { JupyterFrontEndPlugin } from '@jupyterlab/application';
2
+ export declare const CommandIDs: {
3
+ readonly open: "oceanum-share:open";
4
+ readonly save: "oceanum-share:save";
5
+ readonly share: "oceanum-share:share";
6
+ readonly rename: "oceanum-share:rename";
7
+ readonly delete: "oceanum-share:delete";
8
+ };
9
+ export declare const SHARE_PLUGIN_ID = "@oceanum/oceanumlab:share";
10
+ /** The Notebooks tab marks each listed record with this, for its context menu. */
11
+ export declare const SPEC_ID_ATTRIBUTE = "data-spec-id";
12
+ export declare const NOTEBOOK_ITEM_SELECTOR = ".oceanum-notebooks-item[data-spec-id]";
13
+ /**
14
+ * Open, save, share, rename and delete notebooks through the Oceanum spec store.
15
+ *
16
+ * The commands sit in the File menu, the command palette, a notebook's context menu
17
+ * (and its tab's), and the Notebooks tab's rows. They are enabled only while signed in.
18
+ * With `fileManagement: 'oceanum'` in the environment the local drive goes out of
19
+ * sight and every local save is pushed to the store: see `oceanumOnly.ts`.
20
+ */
21
+ export declare const sharePlugin: JupyterFrontEndPlugin<void>;