// (C) 2019-2025 GoodData Corporation
import { uriRef, } from "@gooddata/sdk-model";
/**
 * Factory & builder for insight instances. Keeping it in test infrastructure for now, will see later on
 * whether we should move it to prod code and expose on public API.
 *
 * TODO: this together with the `newInsightDefinition` should be moved into a new test utilities package that
 *  should live under `tools`. neither of these functions/builders make sense in the production code because they
 *  lack the logic that ensures that a correct insight is created. These two things are really useful only for
 *  convenient creation of test fixtures.
 */
export function newInsight(visClassId, modifications = (v) => v) {
    const builder = new InsightBuilder(visClassId);
    return modifications(builder).build();
}
export class InsightBuilder {
    insight;
    constructor(visClassUri) {
        this.insight = {
            visualizationUrl: visClassUri,
            title: "Untitled",
            buckets: [],
            filters: [],
            sorts: [],
            properties: {},
            identifier: "random",
            uri: "random",
            ref: uriRef("random"),
            isLocked: false,
        };
    }
    uri = (uri) => {
        this.insight.uri = uri;
        this.insight.ref = uriRef(uri);
        return this;
    };
    identifier = (identifier) => {
        this.insight.identifier = identifier;
        return this;
    };
    title = (title) => {
        this.insight.title = title;
        return this;
    };
    buckets = (buckets) => {
        this.insight.buckets = buckets;
        return this;
    };
    filters = (filters) => {
        this.insight.filters = filters;
        return this;
    };
    sorts = (sorts) => {
        this.insight.sorts = sorts;
        return this;
    };
    properties = (properties) => {
        this.insight.properties = properties;
        return this;
    };
    isLocked = (isLocked) => {
        this.insight.isLocked = isLocked;
        return this;
    };
    created = (created) => {
        this.insight.created = created;
        return this;
    };
    updated = (updated) => {
        this.insight.updated = updated;
        return this;
    };
    build = () => {
        return {
            insight: this.insight,
        };
    };
}
//# sourceMappingURL=insightBuilder.js.map