"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const types_1 = require("oak-domain/lib/types"); const validator_1 = require("oak-domain/lib/utils/validator"); const version_1 = require("oak-domain/lib/utils/version"); const checkers = [ { type: 'data', action: 'create', entity: 'system', checker: (data) => { const setData = (data) => { if (!data.config) { Object.assign(data, { config: {}, }); } if (!data.super) { Object.assign(data, { super: false, }); } }; if (data instanceof Array) { data.forEach((ele) => { (0, validator_1.checkAttributesNotNull)('system', ele, ['name', 'platformId']); if (ele.oldestVersion && !(0, version_1.isVersion)(ele.oldestVersion)) { throw new types_1.OakInputIllegalException('system', ['oldestVersion'], 'error::illegalVersionData', 'oak-general-business'); } setData(ele); }); } else { (0, validator_1.checkAttributesNotNull)('system', data, ['name', 'platformId']); if (data.oldestVersion && !(0, version_1.isVersion)(data.oldestVersion)) { throw new types_1.OakInputIllegalException('system', ['oldestVersion'], 'error::illegalVersionData', 'oak-general-business'); } setData(data); } return; }, }, { type: 'data', action: 'update', entity: 'system', checker(data) { const { oldestVersion } = data; if (oldestVersion && !(0, version_1.isVersion)(oldestVersion)) { throw new types_1.OakInputIllegalException('system', ['oldestVersion'], 'error::illegalVersionData'); } } } ]; exports.default = checkers;