oak-domain/lib/triggers/modi.js

73 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var triggers = [
{
name: '当modi被应用时将相应的operate完成',
entity: 'modi',
action: 'apply',
when: 'after',
fn: function (_a, context, option) {
var operation = _a.operation;
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var filter, modies, modies_1, modies_1_1, modi, targetEntity, id, action, data, filter_1, e_1_1;
var e_1, _b;
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {
case 0:
filter = operation.filter;
return [4 /*yield*/, context.rowStore.select('modi', {
data: {
id: 1,
action: 1,
data: 1,
filter: 1,
targetEntity: 1,
},
filter: filter,
}, context, option)];
case 1:
modies = (_c.sent()).result;
_c.label = 2;
case 2:
_c.trys.push([2, 7, 8, 9]);
modies_1 = tslib_1.__values(modies), modies_1_1 = modies_1.next();
_c.label = 3;
case 3:
if (!!modies_1_1.done) return [3 /*break*/, 6];
modi = modies_1_1.value;
targetEntity = modi.targetEntity, id = modi.id, action = modi.action, data = modi.data, filter_1 = modi.filter;
return [4 /*yield*/, context.rowStore.operate(targetEntity, {
id: id,
action: action,
data: data,
filter: filter_1,
}, context, Object.assign({}, option, {
blockTrigger: true,
}))];
case 4:
_c.sent();
_c.label = 5;
case 5:
modies_1_1 = modies_1.next();
return [3 /*break*/, 3];
case 6: return [3 /*break*/, 9];
case 7:
e_1_1 = _c.sent();
e_1 = { error: e_1_1 };
return [3 /*break*/, 9];
case 8:
try {
if (modies_1_1 && !modies_1_1.done && (_b = modies_1.return)) _b.call(modies_1);
}
finally { if (e_1) throw e_1.error; }
return [7 /*endfinally*/];
case 9: return [2 /*return*/, modies.length];
}
});
});
}
}
];
exports.default = triggers;