import { HttpStep } from '../../HttpStep.js';
export const ReadDataSourceStepKind = 'HttpAction#ReadDataSource';
/**
 * A step similar to `ReadDataStep` but it does not search for a value by the path
 * but returns the whole part of the request / response data (like status code,
 * status message, response headers, response body, request body, etc)
 */
export class ReadDataSourceStep extends HttpStep {
    kind = ReadDataSourceStepKind;
    /**
     * The source of the data.
     */
    source;
    /**
     * The data to read.
     */
    data;
    constructor(sourceOrInit, data) {
        super();
        if (!sourceOrInit) {
            return;
        }
        if (typeof sourceOrInit === 'object') {
            const typed = sourceOrInit;
            this.new(typed);
        }
        else if (typeof sourceOrInit === 'string') {
            this.new({
                kind: ReadDataSourceStepKind,
                source: sourceOrInit,
                data,
                enabled: true,
            });
        }
    }
    new(init) {
        super.new(init);
        this.kind = ReadDataSourceStepKind;
        this.source = init.source;
        this.data = init.data;
    }
    checkValidity() {
        const { source, data } = this;
        return !!source && !!data;
    }
    toJSON() {
        const result = {
            ...super.toJSON(),
            kind: ReadDataSourceStepKind,
        };
        if (this.source) {
            result.source = this.source;
        }
        if (this.data) {
            result.data = this.data;
        }
        return result;
    }
}
//# sourceMappingURL=ReadDataSourceStep.js.map