@malloy-publisher/sdk 0.0.80 → 0.0.81
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.
- package/dist/components/Model/Model.d.ts +3 -1
- package/dist/components/Package/index.d.ts +1 -0
- package/dist/components/Project/index.d.ts +1 -0
- package/dist/components/Workbook/BrowserWorkbookStorage.d.ts +11 -0
- package/dist/components/{MutableNotebook → Workbook}/EditableMalloyCell.d.ts +2 -2
- package/dist/components/{MutableNotebook → Workbook}/MutableCell.d.ts +3 -3
- package/dist/components/Workbook/Workbook.d.ts +9 -0
- package/dist/components/Workbook/WorkbookList.d.ts +7 -0
- package/dist/components/Workbook/WorkbookManager.d.ts +87 -0
- package/dist/components/Workbook/WorkbookStorage.d.ts +18 -0
- package/dist/components/Workbook/WorkbookStorageProvider.d.ts +12 -0
- package/dist/components/Workbook/index.d.ts +7 -0
- package/dist/components/index.d.ts +3 -1
- package/dist/index.cjs.js +62 -62
- package/dist/index.es.js +6466 -6337
- package/package.json +3 -2
- package/src/components/AnalyzePackageButton.tsx +121 -24
- package/src/components/Model/Model.tsx +7 -1
- package/src/components/Package/index.ts +1 -0
- package/src/components/Project/index.ts +1 -0
- package/src/components/Workbook/BrowserWorkbookStorage.ts +100 -0
- package/src/components/{MutableNotebook → Workbook}/EditableMalloyCell.tsx +2 -2
- package/src/components/{MutableNotebook → Workbook}/MutableCell.tsx +3 -3
- package/src/components/{MutableNotebook/MutableNotebook.tsx → Workbook/Workbook.tsx} +81 -57
- package/src/components/Workbook/WorkbookList.tsx +111 -0
- package/src/components/Workbook/WorkbookManager.ts +230 -0
- package/src/components/Workbook/WorkbookStorage.ts +54 -0
- package/src/components/Workbook/WorkbookStorageProvider.tsx +37 -0
- package/src/components/Workbook/index.ts +7 -0
- package/src/components/index.ts +3 -1
- package/dist/components/MutableNotebook/BrowserNotebookStorage.d.ts +0 -9
- package/dist/components/MutableNotebook/MutableNotebook.d.ts +0 -8
- package/dist/components/MutableNotebook/MutableNotebookList.d.ts +0 -6
- package/dist/components/MutableNotebook/NotebookStorage.d.ts +0 -11
- package/dist/components/MutableNotebook/NotebookStorageProvider.d.ts +0 -14
- package/dist/components/MutableNotebook/index.d.ts +0 -5
- package/dist/components/NotebookManager.d.ts +0 -86
- package/src/components/MutableNotebook/BrowserNotebookStorage.ts +0 -58
- package/src/components/MutableNotebook/MutableNotebookList.tsx +0 -69
- package/src/components/MutableNotebook/NotebookStorage.ts +0 -27
- package/src/components/MutableNotebook/NotebookStorageProvider.tsx +0 -43
- package/src/components/MutableNotebook/index.ts +0 -8
- package/src/components/NotebookManager.ts +0 -225
- /package/dist/components/{MutableNotebook → Workbook}/ModelPicker.d.ts +0 -0
- /package/src/components/{MutableNotebook → Workbook}/ModelPicker.tsx +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { PackageContextProps } from "../Package";
|
|
2
|
+
|
|
3
|
+
export interface Workspace {
|
|
4
|
+
name: string;
|
|
5
|
+
writeable: boolean;
|
|
6
|
+
description: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface WorkbookLocator {
|
|
10
|
+
path: string;
|
|
11
|
+
workspace: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface WorkbookStorage {
|
|
15
|
+
// Lists all available workspaces for the context.
|
|
16
|
+
listWorkspaces(
|
|
17
|
+
context: PackageContextProps,
|
|
18
|
+
writeableOnly: boolean,
|
|
19
|
+
): Promise<Workspace[]>;
|
|
20
|
+
|
|
21
|
+
// Lists all available workbooks for the context.
|
|
22
|
+
// Workbooks names are like S3 paths- / denote hierarchical
|
|
23
|
+
// folders, but otherwise folders are not "real" objects
|
|
24
|
+
listWorkbooks(
|
|
25
|
+
workspace: Workspace,
|
|
26
|
+
context: PackageContextProps,
|
|
27
|
+
): Promise<WorkbookLocator[]>;
|
|
28
|
+
|
|
29
|
+
// Returns the workbook at the specific path, throws an exception if no such workbook exists (or cannot be accessed)
|
|
30
|
+
getWorkbook(
|
|
31
|
+
context: PackageContextProps,
|
|
32
|
+
path: WorkbookLocator,
|
|
33
|
+
): Promise<string>;
|
|
34
|
+
|
|
35
|
+
// Deletes the workbook at the specified path, or throws an
|
|
36
|
+
// Exception on failure
|
|
37
|
+
deleteWorkbook(
|
|
38
|
+
context: PackageContextProps,
|
|
39
|
+
path: WorkbookLocator,
|
|
40
|
+
): Promise<void>;
|
|
41
|
+
|
|
42
|
+
saveWorkbook(
|
|
43
|
+
context: PackageContextProps,
|
|
44
|
+
path: WorkbookLocator,
|
|
45
|
+
workbook: string,
|
|
46
|
+
): Promise<void>;
|
|
47
|
+
|
|
48
|
+
// Moves workbook from the "from" path to the "to" path
|
|
49
|
+
moveWorkbook(
|
|
50
|
+
context: PackageContextProps,
|
|
51
|
+
from: WorkbookLocator,
|
|
52
|
+
to: WorkbookLocator,
|
|
53
|
+
): Promise<void>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { createContext, useContext, useMemo } from "react";
|
|
2
|
+
import type { WorkbookStorage } from "./WorkbookStorage";
|
|
3
|
+
|
|
4
|
+
export interface WorkbookStorageProviderProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
workbookStorage: WorkbookStorage;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface WorkbookStorageContextValue {
|
|
10
|
+
workbookStorage: WorkbookStorage;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const WorkbookStorageContext = createContext<
|
|
14
|
+
WorkbookStorageContextValue | undefined
|
|
15
|
+
>(undefined);
|
|
16
|
+
|
|
17
|
+
export function WorkbookStorageProvider({
|
|
18
|
+
children,
|
|
19
|
+
workbookStorage,
|
|
20
|
+
}: WorkbookStorageProviderProps) {
|
|
21
|
+
const value = useMemo(() => ({ workbookStorage }), [workbookStorage]);
|
|
22
|
+
return (
|
|
23
|
+
<WorkbookStorageContext.Provider value={value}>
|
|
24
|
+
{children}
|
|
25
|
+
</WorkbookStorageContext.Provider>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function useWorkbookStorage() {
|
|
30
|
+
const context = useContext(WorkbookStorageContext);
|
|
31
|
+
if (!context) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
"useWorkbookStorage must be used within a WorkbookStorageProvider",
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
return context;
|
|
37
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { WorkbookStorage } from "./WorkbookStorage";
|
|
2
|
+
export { default as Workbook } from "./Workbook";
|
|
3
|
+
export { WorkbookList } from "./WorkbookList";
|
|
4
|
+
export { WorkbookStorageProvider } from "./WorkbookStorageProvider";
|
|
5
|
+
export type { WorkbookLocator, Workspace } from "./WorkbookStorage";
|
|
6
|
+
export { BrowserWorkbookStorage } from "./BrowserWorkbookStorage";
|
|
7
|
+
export { WorkbookManager } from "./WorkbookManager";
|
package/src/components/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./Model";
|
|
2
2
|
export * from "./Notebook";
|
|
3
|
-
export * from "./
|
|
3
|
+
export * from "./Workbook";
|
|
4
4
|
export * from "./Package";
|
|
5
5
|
export * from "./Project";
|
|
6
6
|
export * from "./QueryResult";
|
|
@@ -10,3 +10,5 @@ export { useRouterClickHandler } from "./click_helper";
|
|
|
10
10
|
export { ServerProvider, useServer } from "./ServerProvider";
|
|
11
11
|
export type { ServerContextValue, ServerProviderProps } from "./ServerProvider";
|
|
12
12
|
export { AnalyzePackageButton } from "./AnalyzePackageButton";
|
|
13
|
+
export type { PackageContextProps } from "./Package";
|
|
14
|
+
export type { WorkbookStorage } from "./Workbook";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { NotebookStorage, UserContext } from './NotebookStorage';
|
|
2
|
-
export declare class BrowserNotebookStorage implements NotebookStorage {
|
|
3
|
-
private makeKey;
|
|
4
|
-
listNotebooks(context: UserContext): string[];
|
|
5
|
-
getNotebook(context: UserContext, path: string): string;
|
|
6
|
-
deleteNotebook(context: UserContext, path: string): void;
|
|
7
|
-
saveNotebook(context: UserContext, path: string, notebook: string): void;
|
|
8
|
-
moveNotebook(context: UserContext, from: string, to: string): void;
|
|
9
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
interface MutableNotebookProps {
|
|
2
|
-
notebookPath?: string;
|
|
3
|
-
expandCodeCells?: boolean;
|
|
4
|
-
expandEmbeddings?: boolean;
|
|
5
|
-
hideEmbeddingIcons?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export default function MutableNotebook({ notebookPath, expandCodeCells, expandEmbeddings, hideEmbeddingIcons, }: MutableNotebookProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
interface MutableNotebookListProps {
|
|
3
|
-
onNotebookClick: (notebook: string, event: React.MouseEvent) => void;
|
|
4
|
-
}
|
|
5
|
-
export declare function MutableNotebookList({ onNotebookClick, }: MutableNotebookListProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export interface UserContext {
|
|
2
|
-
project: string;
|
|
3
|
-
package: string;
|
|
4
|
-
}
|
|
5
|
-
export interface NotebookStorage {
|
|
6
|
-
listNotebooks(context: UserContext): string[];
|
|
7
|
-
getNotebook(context: UserContext, path: string): string;
|
|
8
|
-
deleteNotebook(context: UserContext, path: string): void;
|
|
9
|
-
saveNotebook(context: UserContext, path: string, notebook: string): void;
|
|
10
|
-
moveNotebook(context: UserContext, from: string, to: string): void;
|
|
11
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
import { NotebookStorage, UserContext } from './NotebookStorage';
|
|
3
|
-
interface NotebookStorageProviderProps {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
userContext: UserContext;
|
|
6
|
-
notebookStorage: NotebookStorage;
|
|
7
|
-
}
|
|
8
|
-
interface NotebookStorageContextValue {
|
|
9
|
-
notebookStorage: NotebookStorage;
|
|
10
|
-
userContext: UserContext;
|
|
11
|
-
}
|
|
12
|
-
export default function NotebookStorageProvider({ children, userContext, notebookStorage, }: NotebookStorageProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export declare function useNotebookStorage(): NotebookStorageContextValue;
|
|
14
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { BrowserNotebookStorage } from './BrowserNotebookStorage';
|
|
2
|
-
export { default as MutableNotebook } from './MutableNotebook';
|
|
3
|
-
export type { NotebookStorage, UserContext } from './NotebookStorage';
|
|
4
|
-
export { MutableNotebookList } from './MutableNotebookList';
|
|
5
|
-
export { default as NotebookStorageProvider, useNotebookStorage, } from './NotebookStorageProvider';
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { NotebookStorage, UserContext } from './MutableNotebook/NotebookStorage';
|
|
2
|
-
/**
|
|
3
|
-
* Interface representing the data structure of a Mutable Notebook
|
|
4
|
-
* @interface NotebookData
|
|
5
|
-
* @property {string[]} models - Array of model paths used in the notebook
|
|
6
|
-
* @property {NotebookCellValue[]} cells - Array of cells in the notebook
|
|
7
|
-
* @property {string} notebookPath - Path to the notebook file (relative to project/package)
|
|
8
|
-
*/
|
|
9
|
-
export interface NotebookData {
|
|
10
|
-
models: string[];
|
|
11
|
-
cells: NotebookCellValue[];
|
|
12
|
-
notebookPath: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Interface representing a cell in the notebook
|
|
16
|
-
* @interface NotebookCellValue
|
|
17
|
-
* @property {boolean} isMarkdown - Whether the cell is a markdown cell
|
|
18
|
-
* @property {string} [value] - The content of the cell
|
|
19
|
-
* @property {string} [result] - The result of executing the cell
|
|
20
|
-
* @property {string} [modelPath] - modelPath associated with the query in the cell
|
|
21
|
-
* @property {string} [sourceName] - Name of the source associated with the cell
|
|
22
|
-
* @property {string} [queryInfo] - Information about the query in the cell
|
|
23
|
-
*/
|
|
24
|
-
export interface NotebookCellValue {
|
|
25
|
-
isMarkdown: boolean;
|
|
26
|
-
value?: string;
|
|
27
|
-
result?: string;
|
|
28
|
-
modelPath?: string;
|
|
29
|
-
sourceName?: string;
|
|
30
|
-
queryInfo?: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Class for managing notebook operations
|
|
34
|
-
* @class NotebookManager
|
|
35
|
-
*/
|
|
36
|
-
export declare class NotebookManager {
|
|
37
|
-
private notebookData;
|
|
38
|
-
private isSaved;
|
|
39
|
-
private notebookStorage;
|
|
40
|
-
private userContext;
|
|
41
|
-
/**
|
|
42
|
-
* Creates a new NotebookManager instance
|
|
43
|
-
* @param {NotebookStorage} notebookStorage - Storage implementation
|
|
44
|
-
* @param {UserContext} userContext - User context for storage
|
|
45
|
-
* @param {NotebookData} notebookData - Initial notebook data
|
|
46
|
-
*/
|
|
47
|
-
constructor(notebookStorage: NotebookStorage, userContext: UserContext, notebookData: NotebookData);
|
|
48
|
-
/**
|
|
49
|
-
* Gets the current notebook data
|
|
50
|
-
* @returns {NotebookData} The current notebook data
|
|
51
|
-
*/
|
|
52
|
-
getNotebookData(): NotebookData;
|
|
53
|
-
/**
|
|
54
|
-
* Gets the current notebook path
|
|
55
|
-
* @returns {string} The path to the notebook
|
|
56
|
-
*/
|
|
57
|
-
getNotebookPath(): string;
|
|
58
|
-
/**
|
|
59
|
-
* Renames the notebook and updates storage
|
|
60
|
-
* @param {string} notebookPath - New path for the notebook
|
|
61
|
-
* @returns {NotebookManager} The updated NotebookManager instance
|
|
62
|
-
*/
|
|
63
|
-
renameNotebook(notebookPath: string): NotebookManager;
|
|
64
|
-
getCells(): NotebookCellValue[];
|
|
65
|
-
deleteCell(index: number): NotebookManager;
|
|
66
|
-
insertCell(index: number, cell: NotebookCellValue): NotebookManager;
|
|
67
|
-
setCell(index: number, cell: NotebookCellValue): NotebookManager;
|
|
68
|
-
setModels(models: string[]): NotebookManager;
|
|
69
|
-
getModels(): string[];
|
|
70
|
-
updateNotebookData(notebookData: NotebookData): NotebookManager;
|
|
71
|
-
saveNotebook(): NotebookManager;
|
|
72
|
-
/**
|
|
73
|
-
* Converts the notebook data to a Malloy notebook string.
|
|
74
|
-
* @returns {string} The Malloy notebook string
|
|
75
|
-
*/
|
|
76
|
-
toMalloyNotebook(): string;
|
|
77
|
-
static newNotebook(notebookStorage: NotebookStorage, userContext: UserContext): NotebookManager;
|
|
78
|
-
/**
|
|
79
|
-
* Creates a new notebook manager by loading from local storage.
|
|
80
|
-
* Returns an empty instance if the notebook is not found.
|
|
81
|
-
* @param notebookStorage - The storage implementation
|
|
82
|
-
* @param userContext - The user context for storage
|
|
83
|
-
* @param notebookPath - The path to the notebook file (relative to project/package)
|
|
84
|
-
*/
|
|
85
|
-
static loadNotebook(notebookStorage: NotebookStorage, userContext: UserContext, notebookPath: string): NotebookManager;
|
|
86
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { NotebookStorage, UserContext } from "./NotebookStorage";
|
|
2
|
-
|
|
3
|
-
export class BrowserNotebookStorage implements NotebookStorage {
|
|
4
|
-
private makeKey(context: UserContext, path?: string): string {
|
|
5
|
-
let key = `BROWSER_NOTEBOOK_STORAGE__${context.project}/${context.package}`;
|
|
6
|
-
if (path) {
|
|
7
|
-
key += `/${path}`;
|
|
8
|
-
}
|
|
9
|
-
return key;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
listNotebooks(context: UserContext): string[] {
|
|
13
|
-
const prefix = this.makeKey(context);
|
|
14
|
-
const keys: string[] = [];
|
|
15
|
-
for (let i = 0; i < localStorage.length; i++) {
|
|
16
|
-
const key = localStorage.key(i);
|
|
17
|
-
if (key && key.startsWith(prefix + "/")) {
|
|
18
|
-
// Extract the notebook path after the prefix
|
|
19
|
-
const notebookPath = key.substring(prefix.length + 1);
|
|
20
|
-
keys.push(notebookPath);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return keys;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
getNotebook(context: UserContext, path: string): string {
|
|
27
|
-
const key = this.makeKey(context, path);
|
|
28
|
-
const notebook = localStorage.getItem(key);
|
|
29
|
-
if (notebook === null) {
|
|
30
|
-
throw new Error(`Notebook not found at path: ${path}`);
|
|
31
|
-
}
|
|
32
|
-
return notebook;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
deleteNotebook(context: UserContext, path: string): void {
|
|
36
|
-
const key = this.makeKey(context, path);
|
|
37
|
-
if (localStorage.getItem(key) === null) {
|
|
38
|
-
throw new Error(`Notebook not found at path: ${path}`);
|
|
39
|
-
}
|
|
40
|
-
localStorage.removeItem(key);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
saveNotebook(context: UserContext, path: string, notebook: string): void {
|
|
44
|
-
const key = this.makeKey(context, path);
|
|
45
|
-
localStorage.setItem(key, notebook);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
moveNotebook(context: UserContext, from: string, to: string): void {
|
|
49
|
-
const fromKey = this.makeKey(context, from);
|
|
50
|
-
const toKey = this.makeKey(context, to);
|
|
51
|
-
const notebook = localStorage.getItem(fromKey);
|
|
52
|
-
if (notebook === null) {
|
|
53
|
-
throw new Error(`Notebook not found at path: ${from}`);
|
|
54
|
-
}
|
|
55
|
-
localStorage.setItem(toKey, notebook);
|
|
56
|
-
localStorage.removeItem(fromKey);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Box, Divider, List, ListItem, ListItemText } from "@mui/material";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { useNotebookStorage } from "./NotebookStorageProvider";
|
|
4
|
-
|
|
5
|
-
interface MutableNotebookListProps {
|
|
6
|
-
onNotebookClick: (notebook: string, event: React.MouseEvent) => void;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function MutableNotebookList({
|
|
10
|
-
onNotebookClick,
|
|
11
|
-
}: MutableNotebookListProps) {
|
|
12
|
-
const { notebookStorage, userContext } = useNotebookStorage();
|
|
13
|
-
const [notebooks, setNotebooks] = React.useState<string[]>([]);
|
|
14
|
-
|
|
15
|
-
React.useEffect(() => {
|
|
16
|
-
if (notebookStorage && userContext) {
|
|
17
|
-
setNotebooks(notebookStorage.listNotebooks(userContext));
|
|
18
|
-
}
|
|
19
|
-
}, [notebookStorage, userContext]);
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<>
|
|
23
|
-
<Divider />
|
|
24
|
-
<Box
|
|
25
|
-
sx={{
|
|
26
|
-
maxHeight: "300px",
|
|
27
|
-
overflow: "auto",
|
|
28
|
-
"&::-webkit-scrollbar": {
|
|
29
|
-
width: "8px",
|
|
30
|
-
},
|
|
31
|
-
"&::-webkit-scrollbar-track": {
|
|
32
|
-
background: "transparent",
|
|
33
|
-
},
|
|
34
|
-
"&::-webkit-scrollbar-thumb": {
|
|
35
|
-
background: "rgba(0,0,0,0.2)",
|
|
36
|
-
borderRadius: "4px",
|
|
37
|
-
},
|
|
38
|
-
}}
|
|
39
|
-
>
|
|
40
|
-
<List dense>
|
|
41
|
-
{notebooks.length === 0 && (
|
|
42
|
-
<ListItem>
|
|
43
|
-
<ListItemText
|
|
44
|
-
primary="No notebooks found."
|
|
45
|
-
sx={{ textAlign: "center" }}
|
|
46
|
-
/>
|
|
47
|
-
</ListItem>
|
|
48
|
-
)}
|
|
49
|
-
{notebooks.map((notebook) => (
|
|
50
|
-
<ListItem
|
|
51
|
-
key={notebook}
|
|
52
|
-
onClick={(event: React.MouseEvent) =>
|
|
53
|
-
onNotebookClick(notebook, event)
|
|
54
|
-
}
|
|
55
|
-
sx={{
|
|
56
|
-
cursor: "pointer",
|
|
57
|
-
"&:hover": {
|
|
58
|
-
backgroundColor: "action.hover",
|
|
59
|
-
},
|
|
60
|
-
}}
|
|
61
|
-
>
|
|
62
|
-
<ListItemText primary={notebook} />
|
|
63
|
-
</ListItem>
|
|
64
|
-
))}
|
|
65
|
-
</List>
|
|
66
|
-
</Box>
|
|
67
|
-
</>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export interface UserContext {
|
|
2
|
-
// UserContext holds the project & package associated with
|
|
3
|
-
// the notebook. PublisherStorage interfaces will
|
|
4
|
-
// implement this and add data representing configuration,
|
|
5
|
-
// user permissions, and access tokens.
|
|
6
|
-
project: string;
|
|
7
|
-
package: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface NotebookStorage {
|
|
11
|
-
// Lists all available notebooks for the context.
|
|
12
|
-
// Notebooks names are like S3 paths- / denote hierarchical
|
|
13
|
-
// folders, but otherwise folders are not "real" objects
|
|
14
|
-
listNotebooks(context: UserContext): string[];
|
|
15
|
-
|
|
16
|
-
// Returns the notebook at the specific path, throws an exception if no such notebook exists (or cannot be accessed)
|
|
17
|
-
getNotebook(context: UserContext, path: string): string;
|
|
18
|
-
|
|
19
|
-
// Deletes the notebook at the specified path, or throws an
|
|
20
|
-
// Exception on failure
|
|
21
|
-
deleteNotebook(context: UserContext, path: string): void;
|
|
22
|
-
|
|
23
|
-
saveNotebook(context: UserContext, path: string, notebook: string): void;
|
|
24
|
-
|
|
25
|
-
// Moves notebook from the "from" path to the "to" path
|
|
26
|
-
moveNotebook(context: UserContext, from: string, to: string): void;
|
|
27
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useContext, useMemo } from "react";
|
|
2
|
-
import type { NotebookStorage, UserContext } from "./NotebookStorage";
|
|
3
|
-
|
|
4
|
-
interface NotebookStorageProviderProps {
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
userContext: UserContext;
|
|
7
|
-
notebookStorage: NotebookStorage;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface NotebookStorageContextValue {
|
|
11
|
-
notebookStorage: NotebookStorage;
|
|
12
|
-
userContext: UserContext;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const NotebookStorageContext = createContext<
|
|
16
|
-
NotebookStorageContextValue | undefined
|
|
17
|
-
>(undefined);
|
|
18
|
-
|
|
19
|
-
export default function NotebookStorageProvider({
|
|
20
|
-
children,
|
|
21
|
-
userContext,
|
|
22
|
-
notebookStorage,
|
|
23
|
-
}: NotebookStorageProviderProps) {
|
|
24
|
-
const value = useMemo(
|
|
25
|
-
() => ({ notebookStorage, userContext }),
|
|
26
|
-
[notebookStorage, userContext],
|
|
27
|
-
);
|
|
28
|
-
return (
|
|
29
|
-
<NotebookStorageContext.Provider value={value}>
|
|
30
|
-
{children}
|
|
31
|
-
</NotebookStorageContext.Provider>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function useNotebookStorage() {
|
|
36
|
-
const context = useContext(NotebookStorageContext);
|
|
37
|
-
if (!context) {
|
|
38
|
-
throw new Error(
|
|
39
|
-
"useNotebookStorage must be used within a NotebookStorageProvider",
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
return context;
|
|
43
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { BrowserNotebookStorage } from "./BrowserNotebookStorage";
|
|
2
|
-
export { default as MutableNotebook } from "./MutableNotebook";
|
|
3
|
-
export type { NotebookStorage, UserContext } from "./NotebookStorage";
|
|
4
|
-
export { MutableNotebookList } from "./MutableNotebookList";
|
|
5
|
-
export {
|
|
6
|
-
default as NotebookStorageProvider,
|
|
7
|
-
useNotebookStorage,
|
|
8
|
-
} from "./NotebookStorageProvider";
|