"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const mablApiClientFactory_1 = require("@mablhq-internal/runtime/api/mablApiClientFactory");
const util_1 = require("../../commandUtil/util");
const cliUtil_1 = require("@mablhq-internal/runtime/core/cliUtil");
const list_1 = require("../../commandUtil/list");
exports.command = 'list';
exports.describe = 'List your DataTables';
exports.builder = (0, list_1.getListBuilderOptions)('datatables');
exports.handler = (0, cliUtil_1.failWrapper)(listDataTables);
async function listDataTables(parsed) {
    const output = parsed.output;
    const limit = parsed.limit;
    const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
    const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
    const queryResult = await apiClient.queryDataTables(workspaceId, limit);
    (0, list_1.outputEntities)(queryResult.dataTables ?? [], output);
}
