"use strict";
exports.id = 306;
exports.ids = [306];
exports.modules = {

/***/ 9306:
/***/ ((module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Pf": () => (/* binding */ Schedule),
/* harmony export */   "Zb": () => (/* binding */ Log),
/* harmony export */   "dT": () => (/* binding */ jobToJobFragment),
/* harmony export */   "oI": () => (/* binding */ Job)
/* harmony export */ });
/* unused harmony export Lock */
/* harmony import */ var luxon__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2748);
/* harmony import */ var luxon__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(luxon__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var mongoose__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1185);
/* harmony import */ var mongoose__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(mongoose__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6555);
/* harmony import */ var next_config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4558);
/* harmony import */ var next_config__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(next_config__WEBPACK_IMPORTED_MODULE_3__);
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([uuid__WEBPACK_IMPORTED_MODULE_2__]);
uuid__WEBPACK_IMPORTED_MODULE_2__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];




const { serverRuntimeConfig  } = next_config__WEBPACK_IMPORTED_MODULE_3___default()();
serverRuntimeConfig.mongod().then((mongo)=>{
    mongoose__WEBPACK_IMPORTED_MODULE_1___default().connect(mongo.getUri());
});
const lock = new mongoose__WEBPACK_IMPORTED_MODULE_1__.Schema({
    name: {
        type: String,
        unique: true
    },
    owner: String,
    version: Number,
    expires: {
        type: Date,
        default: ()=>luxon__WEBPACK_IMPORTED_MODULE_0__.DateTime.now().plus({
                seconds: 5
            }).toJSDate()
    }
});
const schedule = new mongoose__WEBPACK_IMPORTED_MODULE_1__.Schema({
    attempt: {
        type: Number,
        default: 0
    },
    next: Date
});
const logs = new mongoose__WEBPACK_IMPORTED_MODULE_1__.Schema({
    createdAt: {
        type: Date,
        default: ()=>Date.now()
    },
    status: String,
    statusCode: Number,
    output: String,
    job: {
        type: mongoose__WEBPACK_IMPORTED_MODULE_1__.Types.ObjectId,
        ref: ()=>Job
    },
    jobId: String,
    v4id: {
        type: String,
        default: ()=>(0,uuid__WEBPACK_IMPORTED_MODULE_2__.v4)()
    }
});
const jobs = new mongoose__WEBPACK_IMPORTED_MODULE_1__.Schema({
    id: mongoose__WEBPACK_IMPORTED_MODULE_1__.Schema.Types.ObjectId,
    v5id: String,
    name: String,
    enabled: {
        type: Boolean,
        default: true
    },
    endpoint: String,
    retries: {
        type: Number,
        default: 5
    },
    runAt: String,
    runEvery: String,
    headers: {
        type: mongoose__WEBPACK_IMPORTED_MODULE_1__.Schema.Types.Map,
        of: String,
        required: false
    },
    body: String,
    createdAt: {
        type: Date,
        default: Date.now
    },
    updatedAt: Date,
    schedule: schedule,
    logs: [
        {
            type: mongoose__WEBPACK_IMPORTED_MODULE_1__.Schema.Types.ObjectId,
            ref: "Log"
        }, 
    ]
});
const Job = (mongoose__WEBPACK_IMPORTED_MODULE_1___default().models.Job) || mongoose__WEBPACK_IMPORTED_MODULE_1___default().model("Job", jobs);
const Log = (mongoose__WEBPACK_IMPORTED_MODULE_1___default().models.Log) || mongoose__WEBPACK_IMPORTED_MODULE_1___default().model("Log", logs);
const Schedule = (mongoose__WEBPACK_IMPORTED_MODULE_1___default().models.Schedule) || mongoose__WEBPACK_IMPORTED_MODULE_1___default().model("Schedule", schedule);
const Lock = (mongoose__WEBPACK_IMPORTED_MODULE_1___default().models.Lock) || mongoose__WEBPACK_IMPORTED_MODULE_1___default().model("Lock", lock);
const jobToJobFragment = (name, job)=>{
    return {
        __typename: "Job",
        name: name,
        endpoint: job.endpoint,
        headers: job.headers,
        enabled: job.enabled === false ? false : true,
        body: job.body,
        retries: job.retries === 0 ? 0 : job.retries ?? 5,
        runAt: job.runAt,
        runEvery: job.runEvery
    };
};

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });

/***/ })

};
;