@notebook-intelligence/notebook-intelligence 1.2.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.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Call the API extension
3
+ *
4
+ * @param endPoint API REST end point for the extension
5
+ * @param init Initial values for the request
6
+ * @returns The response body interpreted as JSON
7
+ */
8
+ export declare function requestAPI<T>(endPoint?: string, init?: RequestInit): Promise<T>;
package/lib/handler.js ADDED
@@ -0,0 +1,36 @@
1
+ // Copyright (c) Mehmet Bektas <mbektasgh@outlook.com>
2
+ import { URLExt } from '@jupyterlab/coreutils';
3
+ import { ServerConnection } from '@jupyterlab/services';
4
+ /**
5
+ * Call the API extension
6
+ *
7
+ * @param endPoint API REST end point for the extension
8
+ * @param init Initial values for the request
9
+ * @returns The response body interpreted as JSON
10
+ */
11
+ export async function requestAPI(endPoint = '', init = {}) {
12
+ // Make request to Jupyter API
13
+ const settings = ServerConnection.makeSettings();
14
+ const requestUrl = URLExt.join(settings.baseUrl, 'notebook-intelligence', // API Namespace
15
+ endPoint);
16
+ let response;
17
+ try {
18
+ response = await ServerConnection.makeRequest(requestUrl, init, settings);
19
+ }
20
+ catch (error) {
21
+ throw new ServerConnection.NetworkError(error);
22
+ }
23
+ let data = await response.text();
24
+ if (data.length > 0) {
25
+ try {
26
+ data = JSON.parse(data);
27
+ }
28
+ catch (error) {
29
+ console.log('Not a JSON response body.', response);
30
+ }
31
+ }
32
+ if (!response.ok) {
33
+ throw new ServerConnection.ResponseError(response, data.message || data.error || data);
34
+ }
35
+ return data;
36
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { JupyterFrontEndPlugin } from '@jupyterlab/application';
2
+ import { INotebookIntelligence } from './tokens';
3
+ /**
4
+ * Initialization data for the @notebook-intelligence/notebook-intelligence extension.
5
+ */
6
+ declare const plugin: JupyterFrontEndPlugin<INotebookIntelligence>;
7
+ export default plugin;