Fix TypeScript errors in action engine

This commit is contained in:
Thaum Rystra
2025-05-02 15:38:18 +02:00
parent d42d2a724e
commit ae5a159e58
31 changed files with 198 additions and 93 deletions

View File

@@ -1,8 +1,7 @@
import { ValidatedMethod } from 'meteor/mdg:validated-method';
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties';
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions';
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor';
import { assertDocEditPermission } from '/imports/api/sharing/sharingPermissions';
const updateCreatureProperty = new ValidatedMethod({
name: 'creatureProperties.update',
@@ -11,14 +10,10 @@ const updateCreatureProperty = new ValidatedMethod({
// We cannot change these fields with a simple update
switch (path[0]) {
case 'type':
case 'order':
case 'parent':
case 'ancestors':
case 'root':
case 'left':
case 'right':
case 'parentId':
case 'damage':
throw new Meteor.Error('Permission denied',
'This property can\'t be updated directly');
}
@@ -30,13 +25,12 @@ const updateCreatureProperty = new ValidatedMethod({
},
run({ _id, path, value }) {
// Permission
let property = CreatureProperties.findOne(_id, {
const property = CreatureProperties.findOne(_id, {
fields: { type: 1, root: 1 }
});
let rootCreature = getRootCreatureAncestor(property);
assertEditPermission(rootCreature, this.userId);
assertDocEditPermission(property, this.userId);
let pathString = path.join('.');
const pathString = path.join('.');
let modifier;
// unset empty values
if (value === null || value === undefined) {