2020-07-21 13:20:51 +00:00
|
|
|
/**
|
|
|
|
* API definitions for CustomSection plugins.
|
|
|
|
*/
|
|
|
|
|
2022-02-08 15:23:14 +00:00
|
|
|
export interface ColumnToMap {
|
|
|
|
/**
|
|
|
|
* Column name that Widget expects. Must be a valid JSON property name.
|
|
|
|
*/
|
|
|
|
name: string;
|
|
|
|
/**
|
|
|
|
* Title or short description of a column (used as a label in section mapping).
|
|
|
|
*/
|
|
|
|
title?: string|null,
|
2022-08-26 12:25:34 +00:00
|
|
|
/**
|
|
|
|
* Optional long description of a column (used as a help text in section mapping).
|
|
|
|
*/
|
|
|
|
description?: string|null,
|
2022-02-08 15:23:14 +00:00
|
|
|
/**
|
|
|
|
* Column type, by default ANY.
|
|
|
|
*/
|
|
|
|
type?: string, // GristType, TODO: ts-interface-checker doesn't know how to parse this
|
|
|
|
/**
|
|
|
|
* Mark column as optional all columns are required by default.
|
|
|
|
*/
|
|
|
|
optional?: boolean
|
|
|
|
/**
|
|
|
|
* Allow multiple column assignment, the result will be list of mapped table column names.
|
|
|
|
*/
|
|
|
|
allowMultiple?: boolean,
|
|
|
|
}
|
|
|
|
|
|
|
|
export type ColumnsToMap = (string|ColumnToMap)[];
|
|
|
|
|
2022-01-12 13:30:51 +00:00
|
|
|
/**
|
|
|
|
* Initial message sent by the CustomWidget with initial requirements.
|
|
|
|
*/
|
|
|
|
export interface InteractionOptionsRequest {
|
|
|
|
/**
|
|
|
|
* Required access level. If it wasn't granted already, Grist will prompt user to change the current access
|
|
|
|
* level.
|
|
|
|
*/
|
|
|
|
requiredAccess?: string,
|
|
|
|
/**
|
|
|
|
* Instructs Grist to show additional menu options that will trigger onEditOptions callback, that Widget
|
|
|
|
* can use to show custom options screen.
|
|
|
|
*/
|
|
|
|
hasCustomOptions?: boolean,
|
2022-02-08 15:23:14 +00:00
|
|
|
/**
|
|
|
|
* Tells Grist what columns Custom Widget expects and allows user to map between existing column names
|
|
|
|
* and those requested by Custom Widget.
|
|
|
|
*/
|
|
|
|
columns?: ColumnsToMap,
|
2022-01-12 13:30:51 +00:00
|
|
|
}
|
2020-07-21 13:20:51 +00:00
|
|
|
|
2022-01-12 13:30:51 +00:00
|
|
|
/**
|
|
|
|
* Widget configuration set and approved by Grist, sent as part of ready message.
|
|
|
|
*/
|
2022-02-08 15:23:14 +00:00
|
|
|
export interface InteractionOptions{
|
2022-01-12 13:30:51 +00:00
|
|
|
/**
|
|
|
|
* Granted access level.
|
|
|
|
*/
|
2022-02-08 15:23:14 +00:00
|
|
|
accessLevel: string,
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Current columns mapping between viewFields in section and Custom widget.
|
|
|
|
*/
|
|
|
|
export interface WidgetColumnMap {
|
|
|
|
[key: string]: string|string[]|null
|
2022-01-12 13:30:51 +00:00
|
|
|
}
|
2020-07-21 13:20:51 +00:00
|
|
|
|
|
|
|
export interface CustomSectionAPI {
|
2022-02-08 15:23:14 +00:00
|
|
|
/**
|
|
|
|
* Initial request from a Custom Widget that wants to declare its requirements.
|
|
|
|
*/
|
2022-01-12 13:30:51 +00:00
|
|
|
configure(customOptions: InteractionOptionsRequest): Promise<void>;
|
2022-02-08 15:23:14 +00:00
|
|
|
/**
|
|
|
|
* Returns current widget configuration (if requested through configuration method).
|
|
|
|
*/
|
|
|
|
mappings(): Promise<WidgetColumnMap|null>;
|
2020-07-21 13:20:51 +00:00
|
|
|
}
|