UNPKG

cv-dialog-sdk

Version:

Catavolt Dialog Javascript API

201 lines (200 loc) 7.54 kB
import { CatavoltApi } from '../dialog/CatavoltApi'; import { StreamConsumer } from '../io/StreamConsumer'; import { ActionParameters } from './ActionParameters'; import { Attachment } from './Attachment'; import { DialogException } from './DialogException'; import { LargeProperty } from './LargeProperty'; import { Menu } from './Menu'; import { Property } from './Property'; import { PropertyDef } from './PropertyDef'; import { ReadLargePropertyParameters } from './ReadLargePropertyParameters'; import { Record } from './Record'; import { RecordDef } from './RecordDef'; import { Redirection } from './Redirection'; import { ReferringObject } from './ReferringObject'; import { DialogMode, DialogType, ViewMode } from './types'; import { View } from './View'; import { ViewDescriptor } from './ViewDescriptor'; /** * Top-level class, representing a Catavolt 'Dialog' definition. * All Dialogs have a composite {@link View} definition along with a single record * or a list of records. See {@Record} */ export declare abstract class Dialog { static SEARCH_DIALOG_CLASS: string; static BINARY_CHUNK_SIZE: number; private static CHAR_CHUNK_SIZE; readonly availableViews: ViewDescriptor[]; readonly domainClassName: string; readonly children: Dialog[]; readonly description: string; readonly dialogClassName: string; dialogMode: DialogMode; readonly header: View; readonly id: string; recordDef: RecordDef; readonly referringObject: ReferringObject; readonly selectedViewId: string; readonly sessionId: string; readonly tenantId: string; readonly type: DialogType; readonly view: View; readonly viewMode: ViewMode; private _lastRefreshTime; private _catavolt; static isSearchDialog(dialog: any): boolean; readonly catavolt: CatavoltApi; readonly anyChildNeedsRefresh: boolean; destroy(): Promise<void>; /** * Return the error associated with this dialog, if any * @returns {} */ readonly error: DialogException; /** * Find a menu def on this dialog with the given actionId * @param actionId * @returns {Menu} */ findMenuAt(actionId: string): Menu; /** * Get a string representation of this property suitable for 'reading' * * @param {Property} prop * @param {string} propName * @returns {string} */ formatForRead(prop: Property, propName: string): string; /** * Get a string representation of this property suitable for 'writing' * * @param {Property} prop * @param {string} propName * @returns {string} */ formatForWrite(prop: Property, propName: string): string; /** * Returns whether or not this dialog loaded properly * @returns {boolean} */ readonly hasError: boolean; /** * Returns whether or not this Form is destroyed * @returns {boolean} */ readonly isDestroyed: boolean; /** * Returns whether or not the data in this dialog is out of date * @returns {boolean} */ readonly isRefreshNeeded: boolean; readonly isReadViewMode: boolean; /** * Get the last time this dialog's data was refreshed * @returns {Date} */ /** * @param time */ lastRefreshTime: Date; /** * Get the all {@link Menu}'s associated with this dialog * @returns {Array<Menu>} */ readonly menu: Menu; openViewWithId(viewId: string): Promise<Dialog>; openView(targetViewDescriptor: ViewDescriptor): Promise<Dialog>; /** * Get the title of this dialog * @returns {string} */ readonly paneTitle: string; /** * Parses a value to prepare for 'writing' back to the server * @param formattedValue * @param propName * @returns {} */ parseValue(formattedValue: any, propName: string): any; /** * Get the property definition for a property name * @param propName * @returns {PropertyDef} */ propDefAtName(propName: string): PropertyDef; /** * Read all the large property values into memory in this {@link Record} * * @param {string} recordId * @returns {Promise<LargeProperty[]>} */ readLargeProperties(recordId: string): Promise<LargeProperty[]>; /** * Read a large property into memory * * @param {string} propertyName * @param {string} recordId * @returns {Promise<LargeProperty>} */ readLargeProperty(propertyName: string, recordId?: string): Promise<LargeProperty>; /** * Stream the encoded chunks of a large property without retaining them * The streamConsumer will receive Base64 encoded chunks with callbacks. hasMore will * be false with the final chunk. * @param {StreamConsumer} streamConsumer * @param {string} propertyName * @param {string} recordId * @returns {Promise<LargeProperty>} */ streamLargeProperty(streamConsumer: StreamConsumer, propertyName: string, recordId?: string): Promise<LargeProperty>; /** * Get the all {@link ViewDescriptor}'s associated with this Form * @returns {Array<ViewDescriptor>} */ readonly viewDescs: ViewDescriptor[]; initialize(catavolt: CatavoltApi): void; protected invokeMenuActionWithId(actionId: string, actionParams: ActionParameters): Promise<Redirection>; /** * Perform this action associated with the given Menu on this dialog. * The targets array is expected to be an array of object ids. * @param {Menu} menu * @param {ActionParameters} actionParams * @returns {Promise<{actionId: string} | Redirection>} */ protected invokeMenuAction(menu: Menu, actionParams: ActionParameters): Promise<Redirection>; protected updateSettingsWithNewDialogProperties(referringObject: ReferringObject): void; protected abstract getProperty(params: ReadLargePropertyParameters, propertyName?: string): Promise<LargeProperty>; protected writeAttachment(attachment: Attachment): Promise<void>; protected writeAttachments(record: Record): Promise<void[]>; /** * Write all Binary values in this {@link Record} back to the server * * @param {Record} record * @returns {Promise<void[]>} */ protected writeLargeProperties(record: Record): Promise<void[]>; protected writeLargeProperty(propertyName: string, largeProperty: LargeProperty): Promise<void>; /** * @private * @returns {boolean} */ private readonly isAnyChildDestroyed; /** * Read a large property into memory or stream it, if a streamConsumer is provided * @param {string} propertyName * @param {string} recordId * @param {StreamConsumer} streamConsumer * @returns {Promise<LargeProperty>} */ private loadLargeProperty; /** * Read a large property into memory or stream it, if a streamConsumer is provided * The actual service call that retrieves the result is delegate to the 'getPropertyFn' * @param {(params: ReadLargePropertyParameters, propertyName?: string) => Promise<LargeProperty>} getPropertyFn * @param {StreamConsumer} streamConsumer * @param {string} propertyName * @param {string} recordId * @returns {Promise<LargeProperty>} */ static loadLargeProperty(getPropertyFn: (params: ReadLargePropertyParameters, propertyName?: string) => Promise<LargeProperty>, streamConsumer?: StreamConsumer, propertyName?: string, recordId?: string): Promise<LargeProperty>; }