/** * The basic option to create a WynBI instance. */ export type WynNotebookOption = { /** * The web address of your wyn server. */ baseUrl: string; /** * The access token. the token is generated from the Admin portal. */ token: string; /** * Set the key name used in query parameters, this name is configured in the Wyn config file.\ * If `tokenKey` is not specified, the default value `'token'` is used. * @example * tokenKey: 'tkn', */ tokenKey?: string; /** * Set if the token should be sent in the request header instead of the query parameter. * default value: false * @example * useTokenInHeader: true, */ useTokenInHeader?: boolean; }; /** * The default properties of NotebookDesignerInitOption. */ export type NotebookDesignerDefaults = { /** * The notebook document id. */ docId?: string; /** * The notebook parameters. */ dp?: object | string; /** * The notebook dataset id. */ datasetId?: string; /** * The language of the user interface. */ lng?: string; /** * The notebook theme. */ theme?: string; /** * The setting of notification time. */ notificationTime?: number; /** * Hide all error notifications. */ hideErrors?: boolean; }; /** * The features properties of NotebookDesignerInitOption. */ export type NotebookDesignerFeatures = { /** * Control the visibility of the close button. */ showCloseButton?: boolean; /** * Control the visibility of the toolbar. */ toolbar?: 'show' | 'hide'; /** * Control whether the user can change the binding dataset. */ disableChangeDataset?: boolean; /** * Control the visibility of the data binding panel. */ showDataBindingPanel?: boolean; /** * Control the visibility of the help button. */ showHelpButton?: boolean; /** * Control the visibility of the inspector. */ showInspector?: boolean; /** * Control the visibility of the inspector when open. */ showInspectorWhenOpen?: boolean; /** **Save As** dialog settings */ saveAsDialog?: { /** * Specifies whether it is possible to set categories.\ * By default this feature is **enabled**. * @example * designerOptions.saveAsDialog.canSetCategories = false; */ canSetCategories?: boolean; /** * Specifies whether it is possible to set comment.\ * By default this feature is **enabled**. * @example * designerOptions.saveAsDialog.canSetComment = false; */ canSetComment?: boolean; }; }; /** * The options of initializing a notebook designer. */ export type NotebookDesignerInitOption = { /** * A DOM element used to mount the notebook designer. */ container?: Element; /** * Default options of initializing a notebook designer. */ defaults?: NotebookDesignerDefaults; /** * Features options of initializing a notebook designer. */ features?: NotebookDesignerFeatures; /** * This is a callback function, it will be invoked after the designer mounted. */ onMount?: () => void; /** * This is a callback function, it will be invoked when the designer is closed. */ onClose?: () => void; /** * This is a callback function, it will be invoked when users save a document. */ onSave?: (docName: string, id: string) => void; /** * This is a callback function, it will be invoked after the designer loaded. */ onLoaded?: (docName: string) => void; /** * This is a callback function, it will be invoked when the document has any error message. */ onError?: (errorInfo: object) => void; }; /** * The default properties of NotebookViewerInitOption. */ export type NotebookViewerDefaults = { /** * The notebook document id. */ docId?: string; /** * The notebook parameters. */ dp?: object | string; /** * The notebook dataset id. */ datasetId?: string; /** * The language of the user interface. */ lng?: string; /** * The notebook theme. */ theme?: string; /** * The setting of notification time. */ notificationTime?: number; /** * Hide all error notifications. */ hideErrors?: boolean; }; /** * The features properties of NotebookViewerInitOption. */ export type NotebookViewerFeatures = {}; /** * The options of initializing a notebook viewer. */ export type NotebookViewerInitOption = { /** * A DOM element used to mount the notebook viewer. */ container?: Element; /** * Default options of initializing a notebook viewer. */ defaults?: NotebookViewerDefaults; /** * Features options of initializing a notebook viewer. */ features?: NotebookViewerFeatures; /** * Invoked after the viewer mounted. */ onMount?: () => void; /** * Invoked when the viewer is closed. */ /** * Invoked after the viewer loaded. */ onLoaded?: (docName: string) => void; /** * Invoked when the document has any error message. */ onError?: (errorInfo: object) => void; }; export declare enum Toolbar { Show = "show", Hide = "hide" } /** * The event types for notebook designer. */ export declare const enum DesignerEventType { /** * Notebook designer close event */ Close = "close", /** * Notebook designer loading complete event */ Loaded = "loaded", /** * Notebook designer error event */ Error = "error", /** * Notebook document save complete event */ Saved = "saved", /** * Enter the preview state event */ PreviewEntered = "previewEntered", /** * Exit preview state event */ PreviewExited = "previewExited", /** * Property panel display event */ InspectorShown = "inspectorShown", /** * Property panel hidden event */ InspectorHidden = "inspectorHidden", /** * Data binding panel display event */ DatabindingPanelShown = "databindingPanelShown", /** * Data binding panel hidden event */ DatabindingPanelHidden = "databindingPanelHidden" } /** * The options of saving the current document. */ export type DocumentSaveOption = { /** * Specify a name for the current document. */ name?: string; /** * Add a comment for the current document. */ comment?: string; /** * Specify categories for the current document. */ categories?: Array; /** * Publish the current document when the server enables the draft function. */ shouldPublish?: boolean; }; /** * The options of whether synchronizing the state changes or not. */ export type DocumentSyncOption = { /** * If there are some state changes in the preview, the designer will show the sync dialog. * Use this parameter to synchronize changes to the current document and to control the visibility of the sync dialog. */ syncChanges?: boolean; }; export declare class NotebookDesigner { /** * Initializes a notebook designer instance and returns a promise. * * @param initOption * @returns * * Sample Code * ``` * designer.initialize({ * container: document.querySelector("#notebook"), * defaults: { * datasetId * }, * onLoaded: (docName) => { * document.title = docName; * } * }); * ``` */ initialize(initOption: NotebookDesignerInitOption): Promise; /** * Releases the resources of the notebook designer instance. */ destroy(): void; /** * Shows the inspector panel of the notebook designer. */ showInspector(): void; /** * Hides the inspector panel of the notebook designer. */ hideInspector(): void; /** * Shows the data binding panel of the notebook designer. */ showDataBindingPanel(): void; /** * Hides the data binding panel of the notebook designer. */ hideDataBindingPanel(): void; /** * Switches designer's view mode. If the designer is now in the 'Design' state, * then it will go to the 'Preview' state and vice versa. * * @param option */ togglePreview(option?: DocumentSyncOption): void; /** * Saves the current document. * * @param option * @returns * * Sample Code * ``` * designer.save({ * name: 'xxxxx', * categories: ['xx'], * comment: 'xxxx', * shouldPublish: true * }); * ``` */ save(option?: DocumentSaveOption): Promise; /** * Returns a bool value whether the state of the current document is dirty. * * @returns */ isDocumentDirty(): boolean; /** * Sets the dataset ID for the notebook. * * @param datasetId - The ID of the dataset to bind to the notebook * * Sample Code * ``` * designer.setDatasetId('new-dataset-id'); * ``` */ setDatasetId(datasetId: string): void; /** * Subscribes to a notebook designer event. * * @param eventType * @param eventHandler */ on(eventType: DesignerEventType, eventHandler: (...args: any[]) => void): void; /** * Unsubscribes from a notebook designer event. * * @param eventType * @param eventHandler */ off(eventType: DesignerEventType, eventHandler: (...args: any[]) => void): void; } export declare class NotebookViewer { /** * Initializes a notebook viewer instance and returns a promise. * * @param initOption * @returns * * Sample Code * ``` * viewer.initialize({ * container: document.querySelector("#notebook"), * defaults: { * docId: 'xxxxxx', * }, * onLoaded: (docName) => { * document.title = docName; * } * }); * ``` */ initialize(initOption: NotebookViewerInitOption): Promise; /** * Releases the resources of the notebook viewer instance. */ destroy(): void; /** * Returns the datasets used in the notebook. * * @returns A promise that resolves to an array of datasets */ getDatasets(): Promise>; /** * Sets parameter values for the notebook. * * @param parameters - An object mapping parameter names to their values * * Sample Code * ``` * viewer.setParameterValue({ * 'Parameter1': [['value1', 'value2']], * 'Parameter2': [['value3']] * }); * ``` */ setParameterValue(parameters: { [key: string]: Array; }): void; /** * Requests fullscreen mode for the notebook viewer. */ requestFullScreen(): void; } export type commonConfig = { version?: string; }; export type NotebookDesignerConfig = NotebookDesignerInitOption & Partial & WynNotebookOption & commonConfig; export type NotebookViewerConfig = NotebookViewerInitOption & Partial & WynNotebookOption & commonConfig;