@oceanum/oceanumlab 4.6.0

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 (83) hide show
  1. package/LICENSE +29 -0
  2. package/README.md +116 -0
  3. package/lib/DatameshUI.d.ts +5 -0
  4. package/lib/DatameshUI.js +8 -0
  5. package/lib/DatameshUI.js.map +1 -0
  6. package/lib/DatameshWidget.d.ts +59 -0
  7. package/lib/DatameshWidget.js +573 -0
  8. package/lib/DatameshWidget.js.map +1 -0
  9. package/lib/DatasourceItem.d.ts +12 -0
  10. package/lib/DatasourceItem.js +47 -0
  11. package/lib/DatasourceItem.js.map +1 -0
  12. package/lib/aiLoop.d.ts +60 -0
  13. package/lib/aiLoop.js +85 -0
  14. package/lib/aiLoop.js.map +1 -0
  15. package/lib/chatRouter.d.ts +64 -0
  16. package/lib/chatRouter.js +225 -0
  17. package/lib/chatRouter.js.map +1 -0
  18. package/lib/constants.d.ts +14 -0
  19. package/lib/constants.js +15 -0
  20. package/lib/constants.js.map +1 -0
  21. package/lib/conversationPin.d.ts +68 -0
  22. package/lib/conversationPin.js +120 -0
  23. package/lib/conversationPin.js.map +1 -0
  24. package/lib/handler.d.ts +8 -0
  25. package/lib/handler.js +36 -0
  26. package/lib/handler.js.map +1 -0
  27. package/lib/index.d.ts +16 -0
  28. package/lib/index.js +273 -0
  29. package/lib/index.js.map +1 -0
  30. package/lib/kernelHandoff.d.ts +61 -0
  31. package/lib/kernelHandoff.js +236 -0
  32. package/lib/kernelHandoff.js.map +1 -0
  33. package/lib/notebookContext.d.ts +48 -0
  34. package/lib/notebookContext.js +118 -0
  35. package/lib/notebookContext.js.map +1 -0
  36. package/lib/notebookHost.d.ts +6 -0
  37. package/lib/notebookHost.js +72 -0
  38. package/lib/notebookHost.js.map +1 -0
  39. package/lib/notebookRun.d.ts +37 -0
  40. package/lib/notebookRun.js +70 -0
  41. package/lib/notebookRun.js.map +1 -0
  42. package/lib/progress.d.ts +43 -0
  43. package/lib/progress.js +103 -0
  44. package/lib/progress.js.map +1 -0
  45. package/lib/sse.d.ts +26 -0
  46. package/lib/sse.js +112 -0
  47. package/lib/sse.js.map +1 -0
  48. package/package.json +151 -0
  49. package/schema/datamesh-connect.json +35 -0
  50. package/src/DatameshUI.tsx +15 -0
  51. package/src/DatameshWidget.tsx +909 -0
  52. package/src/DatasourceItem.tsx +124 -0
  53. package/src/__tests__/aiLoop.spec.ts +304 -0
  54. package/src/__tests__/chatRouter.spec.ts +315 -0
  55. package/src/__tests__/conversationPin.spec.ts +236 -0
  56. package/src/__tests__/kernelHandoff.spec.ts +106 -0
  57. package/src/__tests__/notebookContext.spec.ts +97 -0
  58. package/src/__tests__/notebookHost.spec.ts +195 -0
  59. package/src/__tests__/notebookRun.spec.ts +95 -0
  60. package/src/__tests__/notebookSnapshot.spec.ts +62 -0
  61. package/src/__tests__/oceanumlab.spec.ts +9 -0
  62. package/src/__tests__/sse.spec.ts +304 -0
  63. package/src/aiLoop.ts +140 -0
  64. package/src/chatRouter.ts +329 -0
  65. package/src/constants.ts +16 -0
  66. package/src/conversationPin.ts +148 -0
  67. package/src/global.d.ts +5 -0
  68. package/src/handler.ts +46 -0
  69. package/src/index.ts +327 -0
  70. package/src/kernelHandoff.ts +284 -0
  71. package/src/notebookContext.ts +144 -0
  72. package/src/notebookHost.ts +97 -0
  73. package/src/notebookRun.ts +104 -0
  74. package/src/progress.ts +121 -0
  75. package/src/sse.ts +127 -0
  76. package/src/svg.d.ts +4 -0
  77. package/style/base.css +5 -0
  78. package/style/icons/oceanum-dark.svg +1 -0
  79. package/style/icons/oceanum-light.svg +1 -0
  80. package/style/icons/oceanum.png +0 -0
  81. package/style/icons/oceanum.svg +1 -0
  82. package/style/index.css +477 -0
  83. package/style/index.js +1 -0
package/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2022, Oceanum
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,116 @@
1
+ # oceanumlab
2
+
3
+ [![Github Actions Status](https://github.com/oceanum-io/oceanumlab/workflows/Build/badge.svg)](https://github.com/oceanum-io/oceanumlab/actions/workflows/build.yml)
4
+ A Jupyterlab extension to interact with the Oceanum.io platform
5
+
6
+ This extension is composed of a Python package named `oceanumlab`
7
+ for the server extension and a NPM package named `oceanumlab`
8
+ for the frontend extension.
9
+
10
+ ## Requirements
11
+
12
+ - JupyterLab >= 4.0
13
+
14
+ ## Install
15
+
16
+ To install the extension, execute:
17
+
18
+ ```bash
19
+ pip install oceanumlab
20
+ ```
21
+
22
+ ## Uninstall
23
+
24
+ To remove the extension, execute:
25
+
26
+ ```bash
27
+ pip uninstall oceanumlab
28
+ ```
29
+
30
+ ## Contributing
31
+
32
+ ### Development install
33
+
34
+ Note: You will need NodeJS to build the extension package.
35
+
36
+ The `jlpm` command is JupyterLab's pinned version of
37
+ [yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use
38
+ `yarn` or `npm` in lieu of `jlpm` below.
39
+
40
+ ```bash
41
+ # Clone the repo to your local environment
42
+ # Change directory to the oceanumlab directory
43
+ # Install package in development mode
44
+ pip install -e "."
45
+ # Link your development version of the extension with JupyterLab
46
+ jupyter labextension develop . --overwrite
47
+ # Rebuild extension Typescript source after making changes
48
+ jlpm build
49
+ ```
50
+
51
+ You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.
52
+
53
+ ```bash
54
+ # Watch the source directory in one terminal, automatically rebuilding when needed
55
+ jlpm watch
56
+ # Run JupyterLab in another terminal
57
+ jupyter lab
58
+ ```
59
+
60
+ With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).
61
+
62
+ By default, the `jlpm build` command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:
63
+
64
+ ```bash
65
+ jupyter lab build --minimize=False
66
+ ```
67
+
68
+ ### Development uninstall
69
+
70
+ ```bash
71
+ pip uninstall oceanumlab
72
+ ```
73
+
74
+ In development mode, you will also need to remove the symlink created by `jupyter labextension develop`
75
+ command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions`
76
+ folder is located. Then you can remove the symlink named `oceanumlab` within that folder.
77
+
78
+ ### Testing the extension
79
+
80
+ #### Server tests
81
+
82
+ This extension is using [Pytest](https://docs.pytest.org/) for Python code testing.
83
+
84
+ Install test dependencies (needed only once):
85
+
86
+ ```sh
87
+ pip install -e ".[test]"
88
+ ```
89
+
90
+ To execute them, run:
91
+
92
+ ```sh
93
+ pytest -vv -r ap --cov oceanumlab
94
+ ```
95
+
96
+ #### Frontend tests
97
+
98
+ This extension is using [Jest](https://jestjs.io/) for JavaScript code testing.
99
+
100
+ To execute them, execute:
101
+
102
+ ```sh
103
+ jlpm
104
+ jlpm test
105
+ ```
106
+
107
+ #### Integration tests
108
+
109
+ This extension uses [Playwright](https://playwright.dev/docs/intro) for the integration tests (aka user level tests).
110
+ More precisely, the JupyterLab helper [Galata](https://github.com/jupyterlab/jupyterlab/tree/master/galata) is used to handle testing the extension in JupyterLab.
111
+
112
+ More information are provided within the [ui-tests](./ui-tests/README.md) README.
113
+
114
+ ### Packaging the extension
115
+
116
+ See [RELEASE](RELEASE.md)
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { ReactWidget } from '@jupyterlab/apputils';
3
+ export declare class DatameshUI extends ReactWidget {
4
+ render(): React.ReactElement;
5
+ }
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { ReactWidget } from '@jupyterlab/apputils';
3
+ export class DatameshUI extends ReactWidget {
4
+ render() {
5
+ return (React.createElement("iframe", { src: `${DATAMESH_UI_SERVICE}`, className: "datamesh-iframe" }));
6
+ }
7
+ }
8
+ //# sourceMappingURL=DatameshUI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatameshUI.js","sourceRoot":"","sources":["../src/DatameshUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAInD,MAAM,OAAO,UAAW,SAAQ,WAAW;IACzC,MAAM;QACJ,OAAO,CACL,gCACE,GAAG,EAAE,GAAG,mBAAmB,EAAE,EAC7B,SAAS,EAAC,iBAAiB,GACnB,CACX,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,59 @@
1
+ import { JupyterFrontEnd } from '@jupyterlab/application';
2
+ import { ReactWidget } from '@jupyterlab/apputils';
3
+ import { LabIcon } from '@jupyterlab/ui-components';
4
+ import { CommandRegistry } from '@lumino/commands';
5
+ import { Signal } from '@lumino/signaling';
6
+ import { Widget } from '@lumino/widgets';
7
+ import React from 'react';
8
+ export interface IDatasource {
9
+ id: string;
10
+ label: string;
11
+ datasource: string;
12
+ description: string;
13
+ variables?: string[];
14
+ geofilter?: Record<string, any>;
15
+ timefilter: any;
16
+ spatialref: string;
17
+ }
18
+ export interface IWorkspaceSpec {
19
+ id: string;
20
+ name: string;
21
+ data: IDatasource[];
22
+ }
23
+ export interface IDatameshWorkspaceProps {
24
+ spec: IWorkspaceSpec;
25
+ openDatameshUI: (args: any) => void;
26
+ getCurrentWidget: () => Widget;
27
+ shell: JupyterFrontEnd.IShell;
28
+ }
29
+ export interface IDatasourceActionButton {
30
+ title: string;
31
+ icon: LabIcon;
32
+ feedback?: string;
33
+ onClick: () => void;
34
+ }
35
+ /**
36
+ * DatameshConnectWidget props.
37
+ */
38
+ export interface IDatameshWidgetProps {
39
+ app: JupyterFrontEnd;
40
+ name: string;
41
+ icon: LabIcon;
42
+ openDatameshUI: any;
43
+ commands: CommandRegistry;
44
+ getCurrentWidget: () => Widget;
45
+ }
46
+ /**
47
+ * A widget for Datamesh Connections.
48
+ */
49
+ export declare class DatameshConnectWidget extends ReactWidget {
50
+ props: IDatameshWidgetProps;
51
+ renderSignal: Signal<this, any>;
52
+ icon: LabIcon;
53
+ openDatameshUI: any;
54
+ datameshWorkspaceSpec: IWorkspaceSpec | null;
55
+ constructor(props: IDatameshWidgetProps);
56
+ receiveIFrameMessage(event: MessageEvent): void;
57
+ renderDisplay(datameshWorkspace: IWorkspaceSpec): React.ReactElement;
58
+ render(): React.ReactElement;
59
+ }