Files
DiceCloud/app/imports/api/properties/Folders.ts
2025-01-12 19:29:26 +02:00

58 lines
1.6 KiB
TypeScript

import SimpleSchema from 'simpl-schema';
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS';
import createPropertySchema from '/imports/api/properties/subSchemas/createPropertySchema';
import type { Expand, InferType } from '/imports/api/utility/TypedSimpleSchema';
// Folders organize a character sheet into a tree, particularly to group things
// like 'race' and 'background'
const FolderSchema = createPropertySchema({
name: {
type: String,
max: STORAGE_LIMITS.name,
optional: true,
},
description: {
type: 'inlineCalculationFieldToCompute' as const,
optional: true,
},
groupStats: {
type: Boolean,
optional: true,
},
hideStatsGroup: {
type: Boolean,
optional: true,
},
tab: {
type: String,
optional: true,
allowedValues: [
'stats', 'features', 'actions', 'spells', 'inventory', 'journal', 'build'
] as const,
},
location: {
type: String,
optional: true,
allowedValues: [
'start', 'events', 'stats', 'skills', 'proficiencies', 'end'
] as const,
},
});
const ComputedOnlyFolderSchema = createPropertySchema({
description: {
type: 'computedOnlyInlineCalculationField' as const,
optional: true,
},
});
const ComputedFolderSchema = new SimpleSchema({})
.extend(FolderSchema)
.extend(ComputedOnlyFolderSchema);
export type Folder = InferType<typeof FolderSchema>;
export type ComputedOnlyFolder = InferType<typeof ComputedOnlyFolderSchema>;
export type ComputedFolder = Expand<InferType<typeof FolderSchema> & InferType<typeof ComputedOnlyFolderSchema>>;
export { FolderSchema, ComputedFolderSchema, ComputedOnlyFolderSchema };