@omnia/fx
Version:
Provide Omnia Fx typings and tooling for clientside Omnia development.
93 lines (92 loc) • 5.17 kB
TypeScript
import { DataSourceProperty, DataSourcePropertyDisplayInformation, GuidValue, PropertyDataSourceId, PropertyDefinition, PropertyValue, PropertyValuePrimitiveConverter, UserIdentity } from "../../../models";
import { OmniaContext } from "../../../contexts";
import { DataSourcePropertyDefinitionHandler } from "./DataSourcePropertyDefinitionHandler";
import { IDataSourcePropertyCreator } from "./DataSourcePropertyProvider";
export declare enum WriteBackStatus {
WrittenOk = 0,
ConversionError = 1,
SaveError = 2,
WritebackUnSupported = 3
}
export type WritebackRequest = {
dataSourceProperty: DataSourceProperty;
propertyValue: PropertyValue;
definitionHandler: DataSourcePropertyDefinitionHandler<PropertyDefinition<any, any, any>, DataSourceProperty, any, any>;
};
export type WritebackResult = {
dataSourceProperty: DataSourceProperty;
writeStatus: WriteBackStatus;
};
export interface IWritebackTrigger {
/**
* Will trigger any pending writebacks
* */
executeWritebacks(): Promise<void>;
}
export interface IChangeUserContextTrigger {
}
export declare class DataSourcePropertiesService {
private propertyDataSourceInstances;
private specificUser;
private serviceContainerContext;
omniaContext: OmniaContext;
private externalWritebackTrigger;
private externalChangeUserContextTrigger;
private isChangeUserContextTrigger;
getDataSources(): Promise<Array<{
sourceId: PropertyDataSourceId;
dataSourceTitle: string;
}>>;
isEqual(dataSourceProperty1: DataSourceProperty, dataSourceProperty2: DataSourceProperty): boolean;
isEqualAsync(dataSourceProperty1: DataSourceProperty, dataSourceProperty2: DataSourceProperty): Promise<boolean>;
getSpecificUser(): UserIdentity;
setSpecificUser(specificUser: UserIdentity): void;
changeUserContext(user: UserIdentity): void;
isChangeUserContext(): boolean;
resetUserContext(): void;
hasExternalWritebackTrigger(): boolean;
addOnBeforeExternalWritebackHandler(writebackPreparationFunc: () => Promise<void>): void;
registerExternalWritebackTrigger(onWriteBackPendingListener: () => void, getExist?: boolean): IWritebackTrigger;
registerExternalChangeUserContextTrigger(onChangeUserContextListener: () => void): IChangeUserContextTrigger;
getProperties(datasourceId: PropertyDataSourceId): Promise<Array<DataSourceProperty>>;
updatePropertyValue(writeRequest: WritebackRequest): Promise<WritebackResult>;
/**
* Getting more than one possible creator for a given data source property means a selection must be made as several converters/creators could be used to create the desired propertydefinition, e.g. using ui component
* Each DataSourcePropertyDefinitionHandler has it own unique id, which can be used to persist the choice of the selection, note a persisted selection could point to a handler no longer provided by the system
* Getting no converters/creators mean this property can not be handled by the system
* */
getPropertyValueCreators(dataSourceProperty: DataSourceProperty): Promise<Array<DataSourcePropertyDefinitionHandler<PropertyDefinition<PropertyValue, any, any>, DataSourceProperty, any, any>>>;
getPropertiesDisplayInformation(dataSourceProperties: Array<DataSourceProperty>): Promise<Array<{
property: DataSourceProperty;
displayInformation: DataSourcePropertyDisplayInformation;
}>>;
getPropertySourceValues(dataSourceProperties: Array<DataSourceProperty>): Promise<Array<{
valueFromSource: any;
dataSourceProperty: DataSourceProperty;
}>>;
getPropertyValuePrimitiveConverter(propertyValueCreator: DataSourcePropertyDefinitionHandler<PropertyDefinition<PropertyValue, any, any>, DataSourceProperty, any, any>): Promise<PropertyValuePrimitiveConverter>;
supportsWriteback(dataSourceProperties: Array<DataSourceProperty>): Promise<Array<{
property: DataSourceProperty;
supportsWriteBack: boolean;
}>>;
/**
* Write back dataSourceProperties based on the values in PropertyValue, the value written to the datasource is the result of the definitionHandler.propertyWriteBackDataCreator.
* */
writeback(writeRequests: Array<WritebackRequest>): Promise<Array<WritebackResult>>;
/**
* Get an interface for a datasource to create properties from string, if not supported null/undefined
* @param dataSourceId
* @returns creator or undefined/null for not supported
*/
getDataSourcePropertyCreator(dataSourceId: GuidValue): Promise<IDataSourcePropertyCreator>;
/**
* Todo add something like this that a datasource can return if it supports creating datasourceproperties, i.e. graph But does this need more than from string, i.e. like separat creator manifest from datasource?
* string is quite basic/ugly but migt not need anthing more now atleast
* return null, not supported else the creator of propertymetadata
* */
private writeBackToDataSource;
private getDataSourceDefinitionHandlers;
private getPropertyDataSourceInstance;
private groupBy;
private makeWriteable;
}