import { model, Schema } from 'mongoose';
const requiredString = { type: String, required: true };
const nullableString = { type: String, default: null };
const maybeStringArray = { type: [String], default: undefined };
const workCenterSchema = new Schema({
    label: requiredString,
    startStates: maybeStringArray,
    endStates: maybeStringArray,
});
const workItemsConfigSchema = new Schema({
    type: requiredString,
    groupByField: String,
    startStates: maybeStringArray,
    endStates: maybeStringArray,
    rootCause: maybeStringArray,
    devCompletionStates: maybeStringArray,
    ignoreStates: maybeStringArray,
    workCenters: {
        type: [workCenterSchema],
        default: undefined,
    },
});
const filterBySchema = new Schema({
    label: requiredString,
    fields: { type: [String], required: true },
});
const configSchema = new Schema({
    collectionName: nullableString,
    project: nullableString,
    filterWorkItemsBy: {
        type: [filterBySchema],
        default: undefined,
    },
    environments: maybeStringArray,
    templateRepoName: String,
    workItemsConfig: {
        type: [workItemsConfigSchema],
        default: undefined,
    },
}, { timestamps: true });
export const ConfigModel = model('Config', configSchema);
