@malloy-publisher/sdk 0.0.80 → 0.0.82
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/Model/ModelExplorer.d.ts +19 -0
- package/dist/components/Model/index.d.ts +3 -0
- package/dist/components/Model/useModelData.d.ts +8 -0
- 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 +67 -67
- package/dist/index.es.js +9481 -9329
- package/package.json +3 -2
- package/src/components/AnalyzePackageButton.tsx +121 -24
- package/src/components/Model/Model.tsx +19 -110
- package/src/components/Model/ModelExplorer.tsx +138 -0
- package/src/components/Model/SourcesExplorer.tsx +65 -79
- package/src/components/Model/index.ts +3 -0
- package/src/components/Model/useModelData.ts +38 -0
- 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/src/components/styles.ts +0 -3
- 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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { QueryExplorerResult } from './SourcesExplorer';
|
|
1
2
|
interface ModelProps {
|
|
2
3
|
modelPath: string;
|
|
3
4
|
versionId?: string;
|
|
@@ -5,6 +6,7 @@ interface ModelProps {
|
|
|
5
6
|
hideResultIcons?: boolean;
|
|
6
7
|
expandEmbeddings?: boolean;
|
|
7
8
|
hideEmbeddingIcons?: boolean;
|
|
9
|
+
onChange?: (query: QueryExplorerResult) => void;
|
|
8
10
|
}
|
|
9
|
-
export default function Model({ modelPath, expandResults, hideResultIcons, expandEmbeddings, hideEmbeddingIcons, }: ModelProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default function Model({ modelPath, versionId, expandResults, hideResultIcons, expandEmbeddings, hideEmbeddingIcons, onChange, }: ModelProps): import("react/jsx-runtime").JSX.Element;
|
|
10
12
|
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { QueryExplorerResult } from './SourcesExplorer';
|
|
2
|
+
export interface ModelExplorerProps {
|
|
3
|
+
modelPath: string;
|
|
4
|
+
versionId?: string;
|
|
5
|
+
/** Display options forwarded to ModelCell */
|
|
6
|
+
expandResults?: boolean;
|
|
7
|
+
hideResultIcons?: boolean;
|
|
8
|
+
expandEmbeddings?: boolean;
|
|
9
|
+
hideEmbeddingIcons?: boolean;
|
|
10
|
+
/** Callback when the explorer changes (e.g. when a query is selected). */
|
|
11
|
+
onChange?: (query: QueryExplorerResult) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* ModelExplorer renders the main explorer UI for a Malloy model. It shows the
|
|
15
|
+
* selected source (via `SourceExplorerComponent`) along with the list of named
|
|
16
|
+
* queries for that model. This logic was originally embedded inside `Model.tsx`
|
|
17
|
+
* but has been extracted for easier reuse.
|
|
18
|
+
*/
|
|
19
|
+
export declare function ModelExplorer({ modelPath, versionId, expandResults, hideResultIcons, expandEmbeddings, hideEmbeddingIcons, onChange, }: ModelExplorerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { default as Model } from './Model';
|
|
2
|
+
export { ModelExplorer } from './ModelExplorer';
|
|
2
3
|
export { SourcesExplorer } from './SourcesExplorer';
|
|
3
4
|
export { SourceExplorerComponent } from './SourcesExplorer';
|
|
4
5
|
export type { SourceAndPath } from './SourcesExplorer';
|
|
6
|
+
export { useModelData } from './useModelData';
|
|
7
|
+
export type { ModelExplorerProps } from './ModelExplorer';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CompiledModel } from '../../client';
|
|
2
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import { ApiError } from '../ApiErrorDisplay';
|
|
4
|
+
/**
|
|
5
|
+
* Custom hook for fetching model data. Combines usePackage context with
|
|
6
|
+
* useQueryWithApiError to fetch a compiled model.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useModelData(modelPath: string, versionId?: string): UseQueryResult<CompiledModel, ApiError>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PackageContextProps } from '../Package';
|
|
2
|
+
import { WorkbookLocator, WorkbookStorage, Workspace } from './WorkbookStorage';
|
|
3
|
+
export declare class BrowserWorkbookStorage implements WorkbookStorage {
|
|
4
|
+
private makeKey;
|
|
5
|
+
listWorkspaces(context: PackageContextProps, writeableOnly: boolean): Promise<Workspace[]>;
|
|
6
|
+
listWorkbooks(workspace: Workspace, context: PackageContextProps): Promise<WorkbookLocator[]>;
|
|
7
|
+
getWorkbook(context: PackageContextProps, path: WorkbookLocator): Promise<string>;
|
|
8
|
+
deleteWorkbook(context: PackageContextProps, path: WorkbookLocator): Promise<void>;
|
|
9
|
+
saveWorkbook(context: PackageContextProps, path: WorkbookLocator, notebook: string): Promise<void>;
|
|
10
|
+
moveWorkbook(context: PackageContextProps, from: WorkbookLocator, to: WorkbookLocator): Promise<void>;
|
|
11
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SourceAndPath } from '../Model';
|
|
2
2
|
import { QueryExplorerResult } from '../Model/SourcesExplorer';
|
|
3
|
-
import {
|
|
3
|
+
import { WorkbookCellValue } from './WorkbookManager';
|
|
4
4
|
interface EditableMalloyCellProps {
|
|
5
|
-
cell:
|
|
5
|
+
cell: WorkbookCellValue;
|
|
6
6
|
sourceAndPaths: SourceAndPath[];
|
|
7
7
|
onQueryChange: (query: QueryExplorerResult) => void;
|
|
8
8
|
onSourceChange?: (index: number) => void;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { SourceAndPath } from '../Model/SourcesExplorer';
|
|
3
|
-
import {
|
|
3
|
+
import { WorkbookCellValue } from './WorkbookManager';
|
|
4
4
|
interface NotebookCellProps {
|
|
5
|
-
cell:
|
|
5
|
+
cell: WorkbookCellValue;
|
|
6
6
|
expandCodeCell?: boolean;
|
|
7
7
|
expandEmbedding?: boolean;
|
|
8
8
|
hideEmbeddingIcons?: boolean;
|
|
9
9
|
editingMalloy?: boolean;
|
|
10
10
|
editingMarkdown?: boolean;
|
|
11
11
|
sourceAndPaths: SourceAndPath[];
|
|
12
|
-
onCellChange: (cell:
|
|
12
|
+
onCellChange: (cell: WorkbookCellValue) => void;
|
|
13
13
|
onClose: () => void;
|
|
14
14
|
onEdit: () => void;
|
|
15
15
|
onDelete: () => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WorkbookLocator } from './WorkbookStorage';
|
|
2
|
+
interface WorkbookProps {
|
|
3
|
+
workbookPath?: WorkbookLocator;
|
|
4
|
+
expandCodeCells?: boolean;
|
|
5
|
+
expandEmbeddings?: boolean;
|
|
6
|
+
hideEmbeddingIcons?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export default function Workbook({ workbookPath, expandCodeCells, expandEmbeddings, hideEmbeddingIcons, }: WorkbookProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { WorkbookLocator } from './WorkbookStorage';
|
|
3
|
+
interface WorkbookListProps {
|
|
4
|
+
onWorkbookClick: (workbook: WorkbookLocator, event: React.MouseEvent) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function WorkbookList({ onWorkbookClick }: WorkbookListProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { PackageContextProps } from '../Package';
|
|
2
|
+
import { WorkbookLocator, WorkbookStorage } from './WorkbookStorage';
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing the data structure of a Mutable Workbook
|
|
5
|
+
* @interface WorkbookData
|
|
6
|
+
* @property {string[]} models - Array of model paths used in the workbook
|
|
7
|
+
* @property {WorkbookCellValue[]} cells - Array of cells in the workbook
|
|
8
|
+
* @property {WorkbookLocator} workbookPath - Path to the workbook file (relative to project/package)
|
|
9
|
+
*/
|
|
10
|
+
export interface WorkbookData {
|
|
11
|
+
models: string[];
|
|
12
|
+
cells: WorkbookCellValue[];
|
|
13
|
+
workbookPath: WorkbookLocator;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Interface representing a cell in the workbook
|
|
17
|
+
* @interface WorkbookCellValue
|
|
18
|
+
* @property {boolean} isMarkdown - Whether the cell is a markdown cell
|
|
19
|
+
* @property {string} [value] - The content of the cell
|
|
20
|
+
* @property {string} [result] - The result of executing the cell
|
|
21
|
+
* @property {string} [modelPath] - modelPath associated with the query in the cell
|
|
22
|
+
* @property {string} [sourceName] - Name of the source associated with the cell
|
|
23
|
+
* @property {string} [queryInfo] - Information about the query in the cell
|
|
24
|
+
*/
|
|
25
|
+
export interface WorkbookCellValue {
|
|
26
|
+
isMarkdown: boolean;
|
|
27
|
+
value?: string;
|
|
28
|
+
result?: string;
|
|
29
|
+
modelPath?: string;
|
|
30
|
+
sourceName?: string;
|
|
31
|
+
queryInfo?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Class for managing workbook operations
|
|
35
|
+
* @class WorkbookManager
|
|
36
|
+
*/
|
|
37
|
+
export declare class WorkbookManager {
|
|
38
|
+
private workbookData;
|
|
39
|
+
private isSaved;
|
|
40
|
+
private workbookStorage;
|
|
41
|
+
private packageContext;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a new WorkbookManager instance
|
|
44
|
+
* @param {WorkbookStorage} workbookStorage - Storage implementation
|
|
45
|
+
* @param {PackageContextProps} packageContext - Package context for storage
|
|
46
|
+
* @param {WorkbookData} workbookData - Initial workbook data
|
|
47
|
+
*/
|
|
48
|
+
constructor(workbookStorage: WorkbookStorage, packageContext: PackageContextProps, workbookData: WorkbookData);
|
|
49
|
+
/**
|
|
50
|
+
* Gets the current workbook data
|
|
51
|
+
* @returns {WorkbookData} The current workbook data
|
|
52
|
+
*/
|
|
53
|
+
getWorkbookData(): WorkbookData;
|
|
54
|
+
/**
|
|
55
|
+
* Gets the current workbook path
|
|
56
|
+
* @returns {string} The path to the workbook
|
|
57
|
+
*/
|
|
58
|
+
getWorkbookPath(): WorkbookLocator;
|
|
59
|
+
/**
|
|
60
|
+
* Renames the workbook and updates storage
|
|
61
|
+
* @param {string} workbookPath - New path for the workbook
|
|
62
|
+
* @returns {WorkbookManager} The updated WorkbookManager instance
|
|
63
|
+
*/
|
|
64
|
+
renameWorkbook(workbookPath: string): Promise<WorkbookManager>;
|
|
65
|
+
getCells(): WorkbookCellValue[];
|
|
66
|
+
deleteCell(index: number): WorkbookManager;
|
|
67
|
+
insertCell(index: number, cell: WorkbookCellValue): WorkbookManager;
|
|
68
|
+
setCell(index: number, cell: WorkbookCellValue): WorkbookManager;
|
|
69
|
+
setModels(models: string[]): WorkbookManager;
|
|
70
|
+
getModels(): string[];
|
|
71
|
+
updateWorkbookData(workbookData: WorkbookData): WorkbookManager;
|
|
72
|
+
saveWorkbook(): Promise<WorkbookManager>;
|
|
73
|
+
/**
|
|
74
|
+
* Converts the workbook data to a Malloy workbook string.
|
|
75
|
+
* @returns {string} The Malloy workbook string
|
|
76
|
+
*/
|
|
77
|
+
toMalloyWorkbook(): string;
|
|
78
|
+
static newWorkbook(workbookStorage: WorkbookStorage, packageContext: PackageContextProps): WorkbookManager;
|
|
79
|
+
/**
|
|
80
|
+
* Creates a new workbook manager by loading from local storage.
|
|
81
|
+
* Returns an empty instance if the workbook is not found.
|
|
82
|
+
* @param workbookStorage - The storage implementation
|
|
83
|
+
* @param userContext - The user context for storage
|
|
84
|
+
* @param workbookPath - The path to the workbook file (relative to project/package)
|
|
85
|
+
*/
|
|
86
|
+
static loadWorkbook(workbookStorage: WorkbookStorage, packageContext: PackageContextProps, workbookPath: WorkbookLocator): Promise<WorkbookManager>;
|
|
87
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PackageContextProps } from '../Package';
|
|
2
|
+
export interface Workspace {
|
|
3
|
+
name: string;
|
|
4
|
+
writeable: boolean;
|
|
5
|
+
description: string;
|
|
6
|
+
}
|
|
7
|
+
export interface WorkbookLocator {
|
|
8
|
+
path: string;
|
|
9
|
+
workspace: string;
|
|
10
|
+
}
|
|
11
|
+
export interface WorkbookStorage {
|
|
12
|
+
listWorkspaces(context: PackageContextProps, writeableOnly: boolean): Promise<Workspace[]>;
|
|
13
|
+
listWorkbooks(workspace: Workspace, context: PackageContextProps): Promise<WorkbookLocator[]>;
|
|
14
|
+
getWorkbook(context: PackageContextProps, path: WorkbookLocator): Promise<string>;
|
|
15
|
+
deleteWorkbook(context: PackageContextProps, path: WorkbookLocator): Promise<void>;
|
|
16
|
+
saveWorkbook(context: PackageContextProps, path: WorkbookLocator, workbook: string): Promise<void>;
|
|
17
|
+
moveWorkbook(context: PackageContextProps, from: WorkbookLocator, to: WorkbookLocator): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { WorkbookStorage } from './WorkbookStorage';
|
|
3
|
+
export interface WorkbookStorageProviderProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
workbookStorage: WorkbookStorage;
|
|
6
|
+
}
|
|
7
|
+
interface WorkbookStorageContextValue {
|
|
8
|
+
workbookStorage: WorkbookStorage;
|
|
9
|
+
}
|
|
10
|
+
export declare function WorkbookStorageProvider({ children, workbookStorage, }: WorkbookStorageProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function useWorkbookStorage(): WorkbookStorageContextValue;
|
|
12
|
+
export {};
|
|
@@ -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';
|
|
@@ -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';
|