@sassoftware/vi-api
Version:
Types used in the SAS Visual Investigator API
211 lines (210 loc) • 8.29 kB
TypeScript
import { ControlMetadata } from "../svi-datahub";
import { ControlStates } from "../control/page";
import { ControlAttributeMap, IBaseControlAttribute, IGenericControlAttribute } from "./control-attribute-types";
export declare enum ControlType {
AngularJS = "angularjs",
Angular = "angular",
WebComponent = "webcomponent"
}
export declare enum ControlCategory {
Renderer = "Renderers",
Control = "Fields",
Toolbar = "ToolbarItems",
Home = "Home",
Chart = "Charts",
Panels = "Panels",
Container = "Container"
}
export interface Solution {
label: string;
version?: string;
}
export interface SolutionExtension extends ControlMetadata {
controlAttributes?: SolutionExtensionConfigTypeAttributes;
/** refers to controlAttributes.metadata, populated upon registration */
metadata?: SolutionExtensionMetadata;
/** resolved displayName resource string, populated upon registration */
resolvedDisplayName?: string;
/** resolved description resource string, populated upon registration */
resolvedDescription?: string;
clientApplication?: string;
name: string;
}
export interface HomepageSolutionExtension extends SolutionExtension {
/** When set to true, the solution extension is reused when the homepage is reloaded instead. If unset, or set to
* false, then the control will be destroyed and recreated when the homepage is revisited.
*/
reuse?: boolean;
category: ControlCategory.Home;
}
export interface SolutionExtensionConfigTypeAttributes {
metadata?: SolutionExtensionMetadata;
attributes?: Record<string, SolutionExtensionAttribute>;
}
export type SolutionExtensionAttribute = ControlAttributeMap[keyof ControlAttributeMap] | IBaseControlAttribute | IGenericControlAttribute;
export interface SolutionExtensionMetadata {
iconClass?: string;
useDragHandle?: boolean;
renderAs?: ControlType;
containerRestrictions?: string[];
fullScreenMode?: boolean;
states?: ControlStates;
path?: string;
showInToolbox?: "true" | "false";
mainDocumentOnly?: boolean;
requiredServices?: RequiredResourcesExpression;
}
export type SviDocumentManager = {
key: string;
displayName: string;
onClick: (onFilesAdded: (files: SviLinkedFile[]) => void) => void;
};
export interface SviLinkedFile {
fileName: string;
link: string;
type: string;
content?: string;
size: number;
}
export interface AppConfigBundle<T> {
/** unique bundle name */
name: string;
/** display name I18n resource key */
descriptiveName: string;
/** description I18n resource key */
description: string;
/** ID of the the app config that the bundle belongs to */
appConfigurationId: string;
/** configuration data */
configuration: T;
/** I18n resources to export localizable properties of the configuration data */
resources?: {
[key: string]: string;
};
/** configuration category e.g. category-desktop */
categoryId: string;
/** Visual Investigator version */
viVersion: string;
/** HTTP ETag header value based on the last modified timestamp */
eTag: string;
/** media type schema version */
version: number;
/** creation UTC timestamp string */
creationTimeStamp?: string;
/** last modified UTC timestamp string */
modifiedTimeStamp?: string;
/** name of the assigned solution */
solutionName?: string;
}
/**
* A boolean expression to specify required resources by string identifier.
*/
export type RequiredResourcesExpression = string | RequiredResourcesAndExpression | RequiredResourcesOrExpression;
export type RequiredResourcesOrExpression = {
or: RequiredResourcesExpression[];
and?: never;
};
export type RequiredResourcesAndExpression = {
and: RequiredResourcesExpression[];
or?: never;
};
export interface VersionSummary {
softwareVersionNumber: string;
apiVersionNumber: string;
}
/**
* Configuration-related functionality.
*
* Accessed from the window at `window.sas.vi.config`.
*
* @example window.sas.vi.config.getSolutions();
* @category API
*/
export interface ConfigApi {
/**
* @method
* @description Gets the soft expansion limit of the network nodes.
* @returns A Promise containing the soft expansion limit.
*/
getSoftExpansionLimit(): Promise<number>;
/**
* @method
* @description Gets the hard expansion limit of the network nodes.
* @returns A Promise containing the hard expansion limit.
*/
getHardExpansionLimit(): Promise<number>;
/**
* @method
* @description Gets the registered solutions and their labels and versions.
* @returns The currently registered solutions.
*/
getSolutions(): Map<string, Solution>;
/**
* @method
* @description Registers a new solution and version in the SAS Visual Investigator About dialog box.
* If a solution with that key already exists it will not be overwritten.
* @param key {string} Unique identifier for the solution.
* @param label {string} Localized name of the solution to be displayed.
* @param [version] {string} Version of the solution.
*/
registerSolution(key: string, label: string, version?: string): void;
/**
* @method
* @description Retrieves the registered solution extension with a given name.
* @param name {string} Name of the solution extension.
* @returns A Promise that resolves to the solution extension if the name is found.
*/
getSolutionExtension(name: string): Promise<SolutionExtension | HomepageSolutionExtension | undefined>;
/**
* @method
* @description Registers a solution extension with the application.
* @param config {SolutionExtension} Solution extension configuration.
* @returns A Promise that resolves when the solution has been sent to the cache.
*/
registerSolutionExtension(config: SolutionExtension | HomepageSolutionExtension): Promise<void>;
/**
* @method
* @description Registers a document manager with the application.
* @param config {SviDocumentManager} Document manager configuration.
*/
registerDocumentManager(config: SviDocumentManager): void;
/**
* @method
* @description Register a callback to override the default action when selecting the configuration bundle in the administration application.
* @param bundleName {string} The name of the configuration bundle.
* @param callback {function(): void} A function which should open a view to
* allow the user to modify the given configuration bundle.
*/
registerOpenConfigurationCallback(bundleName: string, callback: () => void): void;
/**
* @method
* @description Send a GET request to retrieve an application configuration bundle.
* @param appConfigId {string} The identifier for the application configuration that the bundle belongs to.
* @param bundleName {string} The name of the configuration bundle.
*/
getAppConfigBundle<T extends object>(appConfigId: string, bundleName: string): Promise<AppConfigBundle<T>>;
/**
* @method
* @description Send a PUT request to save an application configuration bundle.
* @param bundle {AppConfigBundle} The updated application configuration bundle.
* @returns A Promise resolving to the saved configuration bundle.
*/
updateAppConfigBundle<T extends object>(bundle: AppConfigBundle<T>): Promise<AppConfigBundle<T>>;
/**
* @method
* @returns A reference to the HTML element that is the default container for modal dialog boxes to be spawned within the application.
*/
getSharedDialogContainer(): HTMLElement;
/**
* @method
* @description Get the services which are an optional part of the SAS Visual Investigator deployment.
* @returns A map of service identifiers to their enabled status (true or false).
*/
getEnabledOptionalServices(): Record<string, boolean>;
/**
* @method
* @description Gets the current software version number and API version of the application.
* @returns The software version number and the installed version of the API.
*/
getCurrentVersions(): VersionSummary;
}