Files
DiceCloud/app/imports/api/properties/Classes.js

92 lines
2.3 KiB
JavaScript

import SimpleSchema from 'simpl-schema';
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
import createPropertySchema from '/imports/api/properties/subSchemas/createPropertySchema.js';
// Classes are like slots, except they only take class levels and enforce that
// lower levels are taken before higher levels
let ClassSchema = createPropertySchema({
name: {
type: String,
optional: true,
max: STORAGE_LIMITS.name,
},
description: {
type: 'inlineCalculationFieldToCompute',
optional: true,
},
// Only `classLevel`s with the same variable name can fill the class
variableName: {
type: String,
optional: true,
max: STORAGE_LIMITS.variableName,
},
classType: {
type: String,
allowedValues: ['startingClass', 'multiClass'],
defaultValue: 'startingClass',
},
// Same tag format as Slots to match library classLevels against
slotTags: {
type: Array,
defaultValue: [],
maxCount: STORAGE_LIMITS.tagCount,
},
'slotTags.$': {
type: String,
max: STORAGE_LIMITS.tagLength,
},
extraTags: {
type: Array,
defaultValue: [],
maxCount: STORAGE_LIMITS.extraTagsCount,
},
'extraTags.$': {
type: Object,
},
'extraTags.$._id': {
type: String,
regEx: SimpleSchema.RegEx.Id,
autoValue(){
if (!this.isSet) return Random.id();
}
},
'extraTags.$.operation': {
type: String,
allowedValues: ['OR', 'NOT'],
defaultValue: 'OR',
},
'extraTags.$.tags': {
type: Array,
defaultValue: [],
maxCount: STORAGE_LIMITS.tagCount,
},
'extraTags.$.tags.$': {
type: String,
max: STORAGE_LIMITS.tagLength,
},
});
const ComputedOnlyClassSchema = createPropertySchema({
description: {
type: 'inlineCalculationFieldToCompute',
optional: true,
},
level: {
type: SimpleSchema.Integer,
optional: true,
},
missingLevels: {
type: Array,
optional: true,
},
'missingLevels.$': {
type: SimpleSchema.Integer,
},
});
const ComputedClassSchema = new SimpleSchema()
.extend(ClassSchema)
.extend(ComputedOnlyClassSchema);
export { ClassSchema, ComputedOnlyClassSchema, ComputedClassSchema };