64 lines
2.2 KiB
JavaScript
64 lines
2.2 KiB
JavaScript
"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");
|
|
function checkVersion(data) {
|
|
const { dangerousVersions, warningVersions, soaVersion } = data;
|
|
if (dangerousVersions && dangerousVersions.find(ele => !(0, version_1.isVersion)(ele))) {
|
|
throw new types_1.OakInputIllegalException('application', ['dangerousVersions'], 'error::illegalVersionData');
|
|
}
|
|
if (warningVersions && warningVersions.find(ele => !(0, version_1.isVersion)(ele))) {
|
|
throw new types_1.OakInputIllegalException('application', ['warningVersions'], 'error::illegalVersionData');
|
|
}
|
|
if (soaVersion && !(0, version_1.isVersion)(soaVersion)) {
|
|
throw new types_1.OakInputIllegalException('application', ['soaVersion'], 'error::illegalVersionData');
|
|
}
|
|
}
|
|
const checkers = [
|
|
{
|
|
type: 'data',
|
|
action: 'create',
|
|
entity: 'application',
|
|
checker: (data, context) => {
|
|
const setData = (data) => {
|
|
if (!data.config) {
|
|
Object.assign(data, {
|
|
config: {},
|
|
});
|
|
}
|
|
};
|
|
if (data instanceof Array) {
|
|
data.forEach((ele) => {
|
|
checkVersion(ele);
|
|
(0, validator_1.checkAttributesNotNull)('application', ele, [
|
|
'name',
|
|
'type',
|
|
'systemId',
|
|
]);
|
|
setData(ele);
|
|
});
|
|
}
|
|
else {
|
|
checkVersion(data);
|
|
(0, validator_1.checkAttributesNotNull)('application', data, [
|
|
'name',
|
|
'type',
|
|
'systemId',
|
|
]);
|
|
setData(data);
|
|
}
|
|
return;
|
|
},
|
|
},
|
|
{
|
|
type: 'data',
|
|
action: 'update',
|
|
entity: 'application',
|
|
checker(data) {
|
|
checkVersion(data);
|
|
}
|
|
}
|
|
];
|
|
exports.default = checkers;
|