Began the great TypeScript Migration

It's helping a lot to move to the new parenting system
This commit is contained in:
Thaum Rystra
2023-09-28 14:16:34 +02:00
parent 26e4d0bcc7
commit e6963ec865
125 changed files with 607 additions and 389 deletions

View File

@@ -4,18 +4,18 @@ import { ValidatedMethod } from 'meteor/mdg:validated-method';
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
import { assertOwnership } from '/imports/api/creature/creatures/creaturePermissions.js';
import Creatures from '/imports/api/creature/creatures/Creatures.js';
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties';
import CreatureLogs from '/imports/api/creature/log/CreatureLogs.js';
import Experiences from '/imports/api/creature/experience/Experiences.js';
import { removeCreatureWork } from '/imports/api/creature/creatures/methods/removeCreature.js';
import ArchiveCreatureFiles from '/imports/api/creature/archive/ArchiveCreatureFiles.js';
export function getArchiveObj(creatureId){
export function getArchiveObj(creatureId) {
// Build the archive document
const creature = Creatures.findOne(creatureId);
const properties = CreatureProperties.find({'ancestors.id': creatureId}).fetch();
const experiences = Experiences.find({creatureId}).fetch();
const logs = CreatureLogs.find({creatureId}).fetch();
const properties = CreatureProperties.find({ 'ancestors.id': creatureId }).fetch();
const experiences = Experiences.find({ creatureId }).fetch();
const logs = CreatureLogs.find({ creatureId }).fetch();
let archiveCreature = {
meta: {
type: 'DiceCloud V2 Creature Archive',
@@ -31,7 +31,7 @@ export function getArchiveObj(creatureId){
return archiveCreature;
}
export function archiveCreature(creatureId){
export function archiveCreature(creatureId) {
const archive = getArchiveObj(creatureId);
const buffer = Buffer.from(JSON.stringify(archive, null, 2));
ArchiveCreatureFiles.write(buffer, {
@@ -44,7 +44,7 @@ export function archiveCreature(creatureId){
creatureName: archive.creature.name,
},
}, (error) => {
if (error){
if (error) {
throw error;
} else {
removeCreatureWork(creatureId);
@@ -65,9 +65,9 @@ const archiveCreatureToFile = new ValidatedMethod({
numRequests: 10,
timeInterval: 5000,
},
async run({creatureId}) {
async run({ creatureId }) {
assertOwnership(creatureId, this.userId);
if (Meteor.isServer){
if (Meteor.isServer) {
archiveCreature(creatureId, this.userId);
} else {
removeCreatureWork(creatureId);