import { type DataRecord, DataRecordValue, DictionaryValidationRecordErrorDetails, type SchemaRecordError } from '@overture-stack/lectern-client';
import { type DataDiff, NewSubmittedData, type SubmissionDeleteData, type SubmissionUpdateData, SubmittedData } from '@overture-stack/lyric-data-model/models';
import { DataRecordNested, DataRecordReference, type GroupedDataSubmission, type ViewType } from './types.js';
/**
 * Compares two `DataRecord` objects and returns the differences between them.
 * @param oldRecord The original `DataRecord` object to compare.
 * @param newRecord The new `DataRecord` object to compare against the original.
 * @returns An object of type `DataDiff` containing the differences between `oldRecord` and `newRecord`.
 * 	The differing values are recorded with the `old` object containing the values
 * 	from `oldRecord` and the `new` object containing the corresponding values from `newRecord`.
 */
export declare const computeDataDiff: (oldRecord: DataRecord | null, newRecord: DataRecord | null) => DataDiff;
/**
 * Convert a value into it's View type if it matches.
 * Otherwise it returns `undefined`
 * @param {unknown} value
 * @returns {ViewType | undefined}
 */
export declare const convertToViewType: (value: unknown) => ViewType | undefined;
/**
 * Abstract Error response
 * @param error
 * @returns
 */
export declare const fetchDataErrorResponse: (error: string) => {
    result: [];
    metadata: {
        totalRecords: number;
        errorMessage?: string;
    };
};
/**
 * Returns a list of entity names based on the provided filter options
 *
 * If the `view` flag is set in the `filterOptions` and a `defaultCentricEntity` exists
 * it returns an array containing the `defaultCentricEntity`.
 * Otherwise, it returns the `entityName` from `filterOptions`, if provided.
 *
 * @param filterOptions An object containing the view flag and the entity name array.
 * @param filterOptions.view A flag indicating the type of view to represent the records
 * @param filterOptions.entityName An array of entity names, used if view is not compound.
 * @param defaultCentricEntity The default centric entity name
 * @returns An array of entity names or empty array if no conditions are met.
 */
export declare const getEntityNamesFromFilterOptions: (filterOptions: {
    view: ViewType;
    entityName?: string[];
}, defaultCentricEntity?: string) => string[];
/**
 * Groupd Submitted Data by entityName
 * @param dataArray Array of data to group
 * @returns
 */
export declare const groupByEntityName: (dataArray: SubmittedData[]) => Record<string, SubmittedData[]>;
/**
 * Get all the schema errors grouped by the index of the record
 * @param {SchemaRecordError<DictionaryValidationRecordErrorDetails>[]} schemaValidationErrors
 * @returns
 */
export declare const groupErrorsByIndex: (schemaValidationErrors: SchemaRecordError<DictionaryValidationRecordErrorDetails>[]) => Record<number, DictionaryValidationRecordErrorDetails[]>;
/**
 * Groups `NewSubmittedData` and `SubmittedData` objects by their `entityName` field.
 * @param data An object containing arrays of `NewSubmittedData` and `SubmittedData` objects.
 * @returns An object containing two properties:
 * - `submittedDataByEntityName`: A record where each key is an `entityName` and the value is an array of
 *   `NewSubmittedData` or `SubmittedData` objects associated with that entity.
 * - `schemaDataByEntityName`: A record where each key is an `entityName` and the value is an array of
 *   `DataRecord[]` objects primarily intended for schema validation.
 *
 */
export declare const groupSchemaDataByEntityName: (data: {
    inserts?: NewSubmittedData[];
    submittedData?: SubmittedData[];
}) => GroupedDataSubmission;
/**
 * Receives any object and finds if it contains an specific key
 * @param {object} hasErrorByIndex An object to evaluate
 * @param {number} index An object key
 * @returns
 */
export declare const hasErrorsByIndex: (hasErrorByIndex: object, index: number) => boolean;
/**
 * Transforms an array of `SubmittedData` into a `Record<string, DataRecordReference[]>`,
 * where each key is the `entityName` from the `SubmittedData`, and the value is an array of
 * `DataRecordReference` objects associated with that `entityName`.
 * Edits each record that is marked to be edited on the Submission
 * @param {object} params
 * @param {SubmittedData[] | undefined} params.submittedData An array of `SubmittedData` objects to be transformed.
 * @param {Record<string, SubmissionUpdateData[]>} params.editSubmittedData An Array of `SubmittedData` objects to be updated
 * @param {Rnumber} params.submissionId The ID of the Active Submission
 * @returns {Record<string, DataRecordReference[]>}
 */
export declare const mapAndMergeSubmittedDataToRecordReferences: ({ submittedData, editSubmittedData, submissionId, }: {
    submittedData?: SubmittedData[];
    editSubmittedData?: Record<string, SubmissionUpdateData[]>;
    submissionId: number;
}) => Record<string, DataRecordReference[]>;
/**
 * Merges multiple arrays of `SubmittedData` and ensures uniqueness based on `id`.
 *
 * @param objects An arbitrary number of arrays of `SubmittedData`.
 * @returns
 */
export declare const mergeSubmittedDataAndDeduplicateById: (...objects: SubmittedData[][]) => SubmittedData[];
/**
 * Transforms an array of `SubmittedData` into a `Record<string, SubmissionDeleteData[]>`,
 * where each key is the `entityName` from the `SubmittedData`, and the value is an array of
 * `SubmissionDeleteData` objects associated with that `entityName`.
 * @param submittedData An array of `SubmittedData` objects to be transformed.
 * @returns
 */
export declare const transformmSubmittedDataToSubmissionDeleteData: (submittedData: SubmittedData[]) => Record<string, SubmissionDeleteData[]>;
/**
 * Updates an array of existing Submitted data by applying the corresponding changes from the request update data.
 * Identifies what element in the array to update by it's `systemId`
 * @param submittedData
 * @param editData
 * @returns
 */
export declare const updateSubmittedDataArray: (submittedData: SubmittedData[], editData: SubmissionUpdateData[]) => SubmittedData[];
/**
 * Updates the entity data based on the provided update request.
 * It removes old keys, filters out undefined values from the new data,
 * and merges the new data into the current data
 * @param existingData
 * @param updateRequest
 * @returns
 */
export declare const updateEntityData: (existingData: DataRecord, updateRequest: SubmissionUpdateData) => DataRecord;
/**
 * Helper function to determine if "input" is a DataRecordValue
 * @param input
 * @returns boolean
 */
export declare const isDataRecordValue: (input: DataRecordValue | DataRecordNested | DataRecordNested[]) => input is DataRecordValue;
