import ModelAPI from "../../Utils/AnalyticsModelAPI/AnalyticsModelAPI";
import BaseModelTable from "./BaseModelTable";
import AnalyticsBaseModel from "../../../Models/AnalyticsModels/AnalyticsBaseModel/AnalyticsBaseModel";
import NotImplementedException from "../../../Types/Exception/NotImplementedException";
import ObjectID from "../../../Types/ObjectID";
import React from "react";
const AnalyticsModelTable = (props) => {
    const modelAPI = props.modelAPI || ModelAPI;
    return (React.createElement(BaseModelTable, Object.assign({}, props, { callbacks: {
            getJSONFromModel: (item) => {
                return AnalyticsBaseModel.toJSON(item, props.modelType);
            },
            updateById: async (args) => {
                const { id, data } = args;
                await modelAPI.updateById({
                    modelType: props.modelType,
                    id: new ObjectID(id),
                    data: data,
                });
            },
            showCreateEditModal: (_data) => {
                // Analytics database like clickhuse dont support edit operations
                throw new NotImplementedException();
            },
            toJSONArray: (items) => {
                return AnalyticsBaseModel.toJSONArray(items, props.modelType);
            },
            getList: async (data) => {
                return await modelAPI.getList({
                    modelType: data.modelType,
                    query: data.query,
                    groupBy: data.groupBy,
                    limit: data.limit,
                    skip: data.skip,
                    sort: data.sort,
                    select: data.select,
                    requestOptions: data.requestOptions,
                });
            },
            addSlugToSelect: (select) => {
                return select;
            },
            getModelFromJSON: (item) => {
                return AnalyticsBaseModel.fromJSON(item, props.modelType);
            },
            deleteItem: async (item) => {
                await modelAPI.deleteItem({
                    modelType: props.modelType,
                    id: item.id,
                    requestOptions: props.deleteRequestOptions,
                });
            },
        } })));
};
export default AnalyticsModelTable;
//# sourceMappingURL=AnalyticsModelTable.js.map