All files / server/src/kompassi kompassiProgramItem.ts

98.66% Statements 74/75
50% Branches 2/4
100% Functions 10/10
98.66% Lines 74/75

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159        44x 44x 44x 44x 44x 44x 44x 44x 44x 44x     44x 44x 44x 44x 44x 44x 44x 44x     44x 44x 44x 44x 44x 44x     44x 44x 44x 44x 44x 44x 44x 44x 44x 44x 44x 44x 44x 44x 44x 44x 44x 44x     44x 44x 44x 44x 44x     44x 44x 44x 44x 44x 44x 44x 44x 44x 44x     44x 44x 44x 44x 44x 44x 44x     44x 44x 44x     44x 44x 44x     44x                             44x                                                                 31x     31x                              
import { z } from "zod";
import { config } from "shared/config";
import { safeEnumArray } from "server/utils/zodUtils";
 
export enum KompassiKonstiProgramType {
  TABLETOP_RPG = "tabletoprpg",
  LARP = "larp",
  TOURNAMENT = "tournament",
  WORKSHOP = "workshop",
  EXPERIENCE_POINT = "experiencepoint",
  OTHER = "other",
  FLEAMARKET = "fleamarket",
  ROUNDTABLE_DISCUSSION = "roundtableDiscussion",
  OTHER_GAMING = "othergaming",
}
 
export enum KompassiGamestyle {
  LIGHT = "light",
  RULES_LIGHT = "rules-light",
  STORY_DRIVEN = "story-driven",
  SERIOUS = "serious",
  COMBAT_HEAVY = "combat-heavy",
  RULES_HEAVY = "rules-heavy",
  CHARACTER_DRIVEN = "character-driven",
}
 
export enum KompassiLanguage {
  FINNISH = "fi",
  ENGLISH = "en",
  SWEDISH = "sv",
  LANGUAGE_FREE = "free",
  LANG_FREE = "lang-free",
}
 
export enum KompassiInclusivity {
  COLOR_BLINDNESS = "color-blindness",
  FINGERS = "fingers",
  LOUD_SOUNDS = "loud-sounds",
  PHYSICAL_CONTACT = "physical-contact",
  LONG_PROGRAM = "long-program",
  NOT_AMPLIFIED = "not-amplified",
  NO_RECORDING_OR_SPOKEN_TEXT = "no-recordings-or-spoken-text",
  DARK_LIGHTING = "dark-lighting",
  NO_MOVEMENT = "no-movement",
  NO_TEXT_OF_RECORDING = "no-text-of-recording",
  LONG_TEXTS = "long-texts",
  LOTS_OF_MOVEMENT = "lots-of-movement",
  FLASHING_LIGHTS = "flashing-lights",
  QUICK_REACTIONS = "quick-reactions",
  NO_SUBTITLES = "no-subtitles",
  STRONG_ODOURS = "strong-odours",
  IRRITATING_CHEMICALS = "irritating-chemicals",
}
 
export enum KompassiGrouping {
  BEGINNERS = "beginners",
  LGBT = "lgbt",
  GOH = "goh-program",
  THEME = "dreams",
}
 
export enum KompassiAgeGroup {
  EVERYONE = "everyone",
  ADULTS = "adults",
  TEENS = "teens",
  ONLY_ADULTS = "only-adults",
  KIDS = "kids",
  SMALL_KIDS = "small-kids",
  ADULTS_AND_YOUTH = "adultsnyouth",
  YOUNG_ADULTS = "youngadults",
  FAMILIES = "families",
}
 
export enum KompassiRegistration {
  OTHER = "other",
  NOT_REQUIRED = "not-required",
  KONSTI = "konsti",
  EXPERIENCE_POINT = "experience-point",
  ROPE_LARP_DESK = "ropelarp",
  GAMEPOINT = "gamepoint",
}
 
export enum KompassiBoolean {
  TRUE = "true",
  FALSE = "false",
}
 
export enum KompassiYesNo {
  YES = "yes",
  NO = "no",
}
 
const ScheduleItemSchema = z.object({
  slug: z.string(),
  title: z.string().catch(""),
  startTime: z.iso.datetime({ offset: true }),
  endTime: z.iso.datetime({ offset: true }),
  lengthMinutes: z.number().catch(0),
  location: z.string().catch(""),
  isCancelled: z.boolean().catch(true),
  cachedAnnotations: z.object({
    "konsti:maxAttendance": z.number().catch(0),
  }),
});
 
export type KompassiScheduleItem = z.infer<typeof ScheduleItemSchema>;
 
export const KompassiProgramItemSchema = z.object({
  slug: z.string(),
  title: z.string().catch(""),
  description: z.string().catch(""),
  cachedHosts: z.string().catch(""),
  isCancelled: z.boolean().catch(true),
  cachedDimensions: z.object({
    konsti: safeEnumArray(KompassiKonstiProgramType, "Konsti program type"),
    grouping: safeEnumArray(KompassiGrouping, "grouping"),
    language: safeEnumArray(KompassiLanguage, "language", [
      KompassiLanguage.FINNISH,
    ]),
    ["age-group"]: safeEnumArray(KompassiAgeGroup, "age group"),
    ["game-style"]: safeEnumArray(KompassiGamestyle, "gamestyle"),
    inclusivity: safeEnumArray(KompassiInclusivity, "inclusivity"),
    registration: safeEnumArray(KompassiRegistration, "registration"),
    revolvingdoor: safeEnumArray(KompassiBoolean, "revolving door"),
    room: z.array(z.string()).catch([]),
    ["is-pre-convention-week"]: safeEnumArray(
      KompassiYesNo,
      "is-pre-convention-week",
    ),
    ["uses-gen-ai"]: safeEnumArray(KompassiYesNo, "uses-gen-ai"),
  }),
  cachedAnnotations: z.object({
    "konsti:rpgSystem": z.string().catch(""),
    "ropecon:otherAuthor": z.string().catch(""),
    "konsti:minAttendance": z.number().catch(1),
    "konsti:isPlaceholder": z.boolean().catch(false),
    "ropecon:numCharacters": z.number().catch(0),
    "konsti:workshopFee": z
      .string()
      .transform((val) => {
        Iif (val === "0€") {
          return "";
        }
        return val;
      })
      .catch(""),
    "konsti:entryConditionK16": z.boolean().catch(false),
    "ropecon:contentWarnings": z.string().catch(""),
    "ropecon:accessibilityOther": z.string().catch(""),
    "ropecon:gameSlogan": z.string().catch(""),
    "ropecon:isRevolvingDoor": z.boolean().catch(false),
  }),
  scheduleItems: z
    .array(ScheduleItemSchema)
    .min(config.server().logMissingScheduleItems ? 1 : 0),
});
 
export type KompassiProgramItem = z.infer<typeof KompassiProgramItemSchema>;