///
import { SinonStub } from 'sinon';
import { ShkoOnline } from '../../ShkoOnline';
import alasql from 'alasql';
import { AttributeMetadataSQL, EntityMetadataSQL, OptionSetMetadataSQL } from './SQLQueries';
import { ODataQuery } from '@shko.online/dataverse-odata';
export declare class MetadataDB {
static readonly CanvasLogicalName = "!CanvasApp";
static Collisions: number;
/**
* Setting this to `true` will warn for missing metadata when doing operations.
*/
_warnMissingInit: boolean;
db: {
databaseid: string;
exec: typeof alasql;
};
_newId: SinonStub<[
], string>;
EntityMetadataSQL: EntityMetadataSQL;
OptionSetMetadataSQL: OptionSetMetadataSQL;
AttributeMetadataSQL: AttributeMetadataSQL;
constructor();
createAttribute(entityId: string, attribute: ShkoOnline.AttributeMetadata): void;
/**
* Use this method to initialize the metadata
* @param metadatas
*/
initMetadata(metadatas: ShkoOnline.EntityMetadata[]): void;
private initSingleTable;
/**
* Get the metadata for a specific attribute
* @param entity The target table
* @param attribute The target attribute
*/
getAttributeMetadata(entity: string, attribute: string): ShkoOnline.AttributeMetadata;
/**
* Get the metadata for a table
* @param entity The target table
*/
getTableMetadataByEntitySet(entitySetName: string): ShkoOnline.EntityMetadata;
/**
* Get the metadata for a table
* @param entity The target table
*/
getTableMetadata(entity: string): ShkoOnline.EntityMetadata;
private mapAttributeFromAttributeDB;
/**
* Update or Insert the metadata for a specific column of a table
* @param entity The target table
* @param attributeMetadata The target column
* @returns
*/
upsertAttributeMetadata(entity: string, attributeMetadata: ShkoOnline.AttributeMetadata): void;
/**
* Initialize the in-memory database with the items passed as param
* @param items Object as returned from the Dataverse OData API
*/
initItems(items: {
'@odata.context': string;
value: any[];
}): void;
/**
* Add a new row to the table
* @param entity The target table
* @param item The data
* @param tableMetadata The table metadata
*/
AddRow(entity: string, item: any, tableMetadata?: ShkoOnline.EntityMetadata): any;
/**
* Same as init items but for Pseudo-Table #!CanvasApp
* @param items
*/
initCanvasItems(items: any[]): void;
/**
* Get a row from the table and the relative metadata
* @param entity The target table
* @param id The target row
* @returns
*/
GetRow(entity: string, id?: string): {
row: {
[attribute: string]: any;
};
entityMetadata: ShkoOnline.EntityMetadata;
};
/**
* Delete a row from the in-memory database
* @param entity The target table
* @param id The target row
*/
RemoveRow(entity: string, id: string): void;
/**
* Gets a row from a table and the associated metadata
* @param entity The target table
* @param id The target row
* @returns
*/
GetRowForAPI(entity: string, id?: string): {
row: {
[attribute: string]: any;
};
entityMetadata: ShkoOnline.EntityMetadata;
};
/**
* Get a coulmn value and metadata
* @param entity The target table
* @param attributeName The target column
* @param rowid The target row
* @returns
*/
GetValueAndMetadata(entity: string, attributeName: string, rowid?: string): {
value: TValue;
attributeMetadata: TAttribute;
};
/**
* Get all the rows for a table
* @param entity The target table
* @returns
*/
GetAllRows(entity: string): {
rows: {
[attr: string]: any;
}[];
entityMetadata: ShkoOnline.EntityMetadata;
};
/**
* Update the value stored in a specific column in the in-memory database
* @param value The new value
* @param entity The target table
* @param attribute The target column
* @param row The target row
*/
UpdateValue(value: T, entity: string, attribute: string, rowId?: string): void;
SelectUsingFetchXml(fetchXml: XMLDocument): ComponentFramework.WebApi.Entity[];
SelectUsingOData(tableMetadata: ShkoOnline.EntityMetadata, query: ODataQuery): unknown;
}
//# sourceMappingURL=Metadata.db.d.ts.map