// (C) 2021-2026 GoodData Corporation
import { idRef } from "@gooddata/sdk-model";
const SupportedCatalogGranularity = [
    "GDC.time.day_in_week",
    "GDC.time.day_in_month",
    "GDC.time.day_in_quarter",
    "GDC.time.day_in_year",
    "GDC.time.week_in_quarter",
    "GDC.time.week_in_year",
    "GDC.time.month_in_quarter",
    "GDC.time.month_in_year",
    "GDC.time.quarter_in_year",
];
export function loadCatalog(ctx, cmd) {
    const { backend, workspace } = ctx;
    const availability = cmd.payload.config?.objectAvailability;
    const metricTypes = backend.capabilities.supportsKpiWidget
        ? ["fact", "measure"]
        : ["measure"];
    const options = {
        excludeTags: (availability?.excludeObjectsWithTags ?? []).map((tag) => idRef(tag)),
        includeTags: (availability?.includeObjectsWithTags ?? []).map((tag) => idRef(tag)),
        types: ["attribute", ...metricTypes, "dateDataset", "attributeHierarchy"],
        includeDateGranularities: SupportedCatalogGranularity,
        loadGroups: false,
    };
    return backend.workspace(workspace).catalog().withOptions(options).load();
}
//# sourceMappingURL=loadCatalog.js.map