<commit_before>import _merge = require('lodash.merge');
import _set = require('lodash.set');

import {DefaultSheet, GoogleSheetsSheet} from "./DefaultSheet";
import {HandleRequest, JovoError, ErrorCode} from "jovo-core";


export interface Config extends GoogleSheetsSheet {
}

export class ObjectArraySheet extends DefaultSheet {
    config: Config = {
        enabled: true,
        range: 'A:Z',
    };
    constructor(config?: Config) {
        super(config);
        if (config) {
            this.config = _merge(this.config, config);
        }
    }

    parse(handleRequest: HandleRequest, values: any[]) { // tslint:disable-line
        const entity = this.config.entity || this.config.name;

        if (!entity) {
            throw new JovoError(
                'entity has to be set.',
                ErrorCode.ERR_PLUGIN,
                'jovo-cms-googlesheets',
                'The sheet\'s name has to be defined in your config.js file.',
                undefined,
                'https://www.jovo.tech/docs/cms/google-sheets#configuration'
            );
        }

        const resultArray = [];
        const keys = values[0];
        for (let i = 1; i < values.length; i++) {
            const row: string[] = values[i];
            const obj = {};

            for (let j = 0; j < row.length; j++) {
                const cell: string = row[j];
                _set(obj, `${keys[j]}`, cell);
            }
            resultArray.push(obj);
        }

        handleRequest.app.$cms[entity] = resultArray;
    }
}
<commit_msg>:bug: Add missing default config property<commit_after>import _merge = require('lodash.merge');
import _set = require('lodash.set');

import {DefaultSheet, GoogleSheetsSheet} from "./DefaultSheet";
import {HandleRequest, JovoError, ErrorCode} from "jovo-core";


export interface Config extends GoogleSheetsSheet {
}

export class ObjectArraySheet extends DefaultSheet {
    config: Config = {
        enabled: true,
        name: undefined,
        range: 'A:Z',
    };
    constructor(config?: Config) {
        super(config);
        if (config) {
            this.config = _merge(this.config, config);
        }
    }

    parse(handleRequest: HandleRequest, values: any[]) { // tslint:disable-line
        const entity = this.config.entity || this.config.name;

        if (!entity) {
            throw new JovoError(
                'entity has to be set.',
                ErrorCode.ERR_PLUGIN,
                'jovo-cms-googlesheets',
                'The sheet\'s name has to be defined in your config.js file.',
                undefined,
                'https://www.jovo.tech/docs/cms/google-sheets#configuration'
            );
        }

        const resultArray = [];
        const keys = values[0];
        for (let i = 1; i < values.length; i++) {
            const row: string[] = values[i];
            const obj = {};

            for (let j = 0; j < row.length; j++) {
                const cell: string = row[j];
                _set(obj, `${keys[j]}`, cell);
            }
            resultArray.push(obj);
        }

        handleRequest.app.$cms[entity] = resultArray;
    }
}

{'fraction_non_alphanumeric': 0.12670256572695598, 'fraction_numerical': 0.0019005384859043396, 'mean_word_length': 1.865698729582577, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2013967', 'n_tokens_mistral': 921, 'n_tokens_neox': 876, 'n_words': 227}