@archivist-gg/dnd5e 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSES/SRD.md +37 -0
  3. package/README.md +65 -0
  4. package/dist/armor/armor.codec.d.ts +10 -0
  5. package/dist/armor/armor.codec.js +8 -0
  6. package/dist/armor/armor.entity-type.d.ts +2 -0
  7. package/dist/armor/armor.parser.d.ts +3 -0
  8. package/dist/armor/armor.parser.js +7 -0
  9. package/dist/armor/armor.schema.d.ts +25 -0
  10. package/dist/armor/armor.schema.js +6 -0
  11. package/dist/armor/armor.types.d.ts +26 -0
  12. package/dist/armor/armor.types.js +0 -0
  13. package/dist/background/background.codec.d.ts +9 -0
  14. package/dist/background/background.codec.js +11 -0
  15. package/dist/background/background.entity-type.d.ts +2 -0
  16. package/dist/background/background.parser.d.ts +3 -0
  17. package/dist/background/background.parser.js +10 -0
  18. package/dist/background/background.schema.d.ts +74 -0
  19. package/dist/background/background.schema.js +9 -0
  20. package/dist/background/background.types.d.ts +52 -0
  21. package/dist/background/background.types.js +0 -0
  22. package/dist/chunk-24GFQU7T.js +18 -0
  23. package/dist/chunk-3DZ74AKK.js +28 -0
  24. package/dist/chunk-3TM34RSJ.js +23 -0
  25. package/dist/chunk-3TRGRSCH.js +8 -0
  26. package/dist/chunk-4C2KOKLF.js +185 -0
  27. package/dist/chunk-4F6AIZ36.js +19 -0
  28. package/dist/chunk-4SSDYJS2.js +86 -0
  29. package/dist/chunk-4TIJKN6O.js +37 -0
  30. package/dist/chunk-537BHVSH.js +18 -0
  31. package/dist/chunk-5INR4NSL.js +18 -0
  32. package/dist/chunk-5XUXXAQJ.js +30 -0
  33. package/dist/chunk-656QCX4U.js +22 -0
  34. package/dist/chunk-66XXW2Z2.js +133 -0
  35. package/dist/chunk-6NK2MUD3.js +114 -0
  36. package/dist/chunk-6PXE7T7C.js +79 -0
  37. package/dist/chunk-7P65Q426.js +158 -0
  38. package/dist/chunk-A7T5L7SS.js +83 -0
  39. package/dist/chunk-AFKTJXRA.js +39 -0
  40. package/dist/chunk-B7UXKNLD.js +46 -0
  41. package/dist/chunk-BAXWWGFJ.js +45 -0
  42. package/dist/chunk-BH6AMZVY.js +25 -0
  43. package/dist/chunk-CDW7R2QT.js +62 -0
  44. package/dist/chunk-DABBCYTT.js +68 -0
  45. package/dist/chunk-DC74TZNA.js +46 -0
  46. package/dist/chunk-DNAJRMNN.js +68 -0
  47. package/dist/chunk-DRNZJNJP.js +19 -0
  48. package/dist/chunk-FEOB24KP.js +18 -0
  49. package/dist/chunk-FFULAF2P.js +63 -0
  50. package/dist/chunk-FUK7QSN5.js +19 -0
  51. package/dist/chunk-GIOH5JB5.js +19 -0
  52. package/dist/chunk-GJOI2GHP.js +25 -0
  53. package/dist/chunk-GZ46OVGZ.js +31 -0
  54. package/dist/chunk-HCP3GMHS.js +44 -0
  55. package/dist/chunk-IDTDACM6.js +19 -0
  56. package/dist/chunk-IKSMX4TN.js +0 -0
  57. package/dist/chunk-IXZXFFFW.js +269 -0
  58. package/dist/chunk-J2RYSZMQ.js +16 -0
  59. package/dist/chunk-JEYQU3JT.js +36 -0
  60. package/dist/chunk-LSLSG67V.js +31 -0
  61. package/dist/chunk-LWFTHJIE.js +24 -0
  62. package/dist/chunk-MDEJHMKK.js +52 -0
  63. package/dist/chunk-N2JE7BWL.js +81 -0
  64. package/dist/chunk-NAEPSZAM.js +88 -0
  65. package/dist/chunk-NXR3BD2V.js +90 -0
  66. package/dist/chunk-PKC77VZP.js +18 -0
  67. package/dist/chunk-PMADYMUI.js +19 -0
  68. package/dist/chunk-PTXBIDG7.js +63 -0
  69. package/dist/chunk-PZOWBI3B.js +49 -0
  70. package/dist/chunk-QQ5W2AZP.js +515 -0
  71. package/dist/chunk-QS5L5YTJ.js +24 -0
  72. package/dist/chunk-QYZV2MQA.js +97 -0
  73. package/dist/chunk-R2ZV233X.js +233 -0
  74. package/dist/chunk-RAWJTA45.js +271 -0
  75. package/dist/chunk-RSDRMH54.js +18 -0
  76. package/dist/chunk-RVYYKYFL.js +18 -0
  77. package/dist/chunk-SSXBYF3P.js +18 -0
  78. package/dist/chunk-TJCNX6UZ.js +521 -0
  79. package/dist/chunk-TZK36BU7.js +38 -0
  80. package/dist/chunk-UC4FE5X3.js +65 -0
  81. package/dist/chunk-WP2CX2JO.js +235 -0
  82. package/dist/chunk-WYGD2UGN.js +14 -0
  83. package/dist/chunk-XJNECUPT.js +31 -0
  84. package/dist/chunk-XURS6Q6Q.js +127 -0
  85. package/dist/chunk-Y4I74YEG.js +33 -0
  86. package/dist/chunk-Z4TL2V7S.js +18 -0
  87. package/dist/chunk-Z6GXV2GO.js +121 -0
  88. package/dist/chunk-ZLG6FQFB.js +237 -0
  89. package/dist/chunk-ZMR77DDL.js +18 -0
  90. package/dist/class/class.codec.d.ts +10 -0
  91. package/dist/class/class.codec.js +15 -0
  92. package/dist/class/class.entity-type.d.ts +2 -0
  93. package/dist/class/class.parser.d.ts +3 -0
  94. package/dist/class/class.parser.js +14 -0
  95. package/dist/class/class.schema.d.ts +202 -0
  96. package/dist/class/class.schema.js +13 -0
  97. package/dist/class/class.slug.d.ts +11 -0
  98. package/dist/class/class.slug.js +8 -0
  99. package/dist/class/class.types.d.ts +74 -0
  100. package/dist/class/class.types.js +0 -0
  101. package/dist/data-srd/index.generated.d.ts +7 -0
  102. package/dist/data-srd/index.generated.js +146 -0
  103. package/dist/dnd/constants.d.ts +16 -0
  104. package/dist/dnd/constants.js +36 -0
  105. package/dist/dnd/formula-tags.d.ts +16 -0
  106. package/dist/dnd/formula-tags.js +119 -0
  107. package/dist/dnd/math.d.ts +24 -0
  108. package/dist/dnd/math.js +35 -0
  109. package/dist/dnd/prose-tags.d.ts +16 -0
  110. package/dist/dnd/prose-tags.js +18 -0
  111. package/dist/dnd/resource-die.d.ts +6 -0
  112. package/dist/dnd/resource-die.js +17 -0
  113. package/dist/dnd/resource-formula.d.ts +41 -0
  114. package/dist/dnd/resource-formula.js +159 -0
  115. package/dist/dnd/srd-tag-converter.d.ts +44 -0
  116. package/dist/dnd/srd-tag-converter.js +12 -0
  117. package/dist/dnd/tag-grammar.d.ts +19 -0
  118. package/dist/dnd/tag-grammar.js +12 -0
  119. package/dist/encounter/encounter.ai-schema.d.ts +29 -0
  120. package/dist/encounter/encounter.ai-schema.js +8 -0
  121. package/dist/encounter/encounter.entity-type.d.ts +2 -0
  122. package/dist/encounter/encounter.generatable.d.ts +2 -0
  123. package/dist/entities/base-item-resolver.d.ts +21 -0
  124. package/dist/entities/base-item-resolver.js +9 -0
  125. package/dist/entities/slug.d.ts +5 -0
  126. package/dist/entities/slug.js +6 -0
  127. package/dist/feat/feat.codec.d.ts +9 -0
  128. package/dist/feat/feat.codec.js +10 -0
  129. package/dist/feat/feat.entity-type.d.ts +2 -0
  130. package/dist/feat/feat.parser.d.ts +3 -0
  131. package/dist/feat/feat.parser.js +9 -0
  132. package/dist/feat/feat.schema.d.ts +194 -0
  133. package/dist/feat/feat.schema.js +8 -0
  134. package/dist/feat/feat.types.d.ts +42 -0
  135. package/dist/feat/feat.types.js +0 -0
  136. package/dist/index.d.ts +12 -0
  137. package/dist/index.js +139149 -0
  138. package/dist/inline-tag-parser.d.ts +11 -0
  139. package/dist/inline-tag-parser.js +6 -0
  140. package/dist/item/item.actions-map.d.ts +41 -0
  141. package/dist/item/item.actions-map.js +85 -0
  142. package/dist/item/item.ai-schema.d.ts +35 -0
  143. package/dist/item/item.ai-schema.js +6 -0
  144. package/dist/item/item.attunement.d.ts +18 -0
  145. package/dist/item/item.attunement.js +12 -0
  146. package/dist/item/item.bonuses.d.ts +2 -0
  147. package/dist/item/item.bonuses.js +7 -0
  148. package/dist/item/item.codec.d.ts +3 -0
  149. package/dist/item/item.codec.js +8 -0
  150. package/dist/item/item.conditions.d.ts +10 -0
  151. package/dist/item/item.conditions.js +8 -0
  152. package/dist/item/item.conditions.types.d.ts +28 -0
  153. package/dist/item/item.conditions.types.js +0 -0
  154. package/dist/item/item.enrichment.d.ts +4 -0
  155. package/dist/item/item.enrichment.js +9 -0
  156. package/dist/item/item.entity-type.d.ts +2 -0
  157. package/dist/item/item.generatable.d.ts +2 -0
  158. package/dist/item/item.parser.d.ts +3 -0
  159. package/dist/item/item.parser.js +7 -0
  160. package/dist/item/item.schema.d.ts +174 -0
  161. package/dist/item/item.schema.js +8 -0
  162. package/dist/item/item.types.d.ts +108 -0
  163. package/dist/item/item.types.js +0 -0
  164. package/dist/monster/monster.ai-schema.d.ts +67 -0
  165. package/dist/monster/monster.ai-schema.js +6 -0
  166. package/dist/monster/monster.codec.d.ts +13 -0
  167. package/dist/monster/monster.enrichment.d.ts +10 -0
  168. package/dist/monster/monster.enrichment.js +19 -0
  169. package/dist/monster/monster.entity-type.d.ts +2 -0
  170. package/dist/monster/monster.generatable.d.ts +2 -0
  171. package/dist/monster/monster.parser.d.ts +3 -0
  172. package/dist/monster/monster.parser.js +6 -0
  173. package/dist/monster/monster.resolve.d.ts +10 -0
  174. package/dist/monster/monster.types.d.ts +29 -0
  175. package/dist/monster/monster.types.js +1 -0
  176. package/dist/npc/npc.ai-schema.d.ts +6 -0
  177. package/dist/npc/npc.entity-type.d.ts +2 -0
  178. package/dist/npc/npc.generatable.d.ts +2 -0
  179. package/dist/optional-feature/optional-feature.codec.d.ts +14 -0
  180. package/dist/optional-feature/optional-feature.codec.js +11 -0
  181. package/dist/optional-feature/optional-feature.entity-type.d.ts +2 -0
  182. package/dist/optional-feature/optional-feature.parser.d.ts +3 -0
  183. package/dist/optional-feature/optional-feature.parser.js +10 -0
  184. package/dist/optional-feature/optional-feature.schema.d.ts +236 -0
  185. package/dist/optional-feature/optional-feature.schema.js +9 -0
  186. package/dist/pack.d.ts +11 -0
  187. package/dist/pc/conditions.constants.d.ts +3 -0
  188. package/dist/pc/conditions.constants.js +8 -0
  189. package/dist/pc/decision-recognizer.d.ts +4 -0
  190. package/dist/pc/decision-recognizer.js +8 -0
  191. package/dist/pc/pc.conditions.d.ts +3 -0
  192. package/dist/pc/pc.conditions.js +6 -0
  193. package/dist/pc/pc.decision-engine.d.ts +97 -0
  194. package/dist/pc/pc.decision-engine.js +19 -0
  195. package/dist/pc/pc.equipment.d.ts +12 -0
  196. package/dist/pc/pc.equipment.js +15 -0
  197. package/dist/pc/pc.feature-effects.d.ts +95 -0
  198. package/dist/pc/pc.feature-effects.js +9 -0
  199. package/dist/pc/pc.formula-context.d.ts +4 -0
  200. package/dist/pc/pc.formula-context.js +11 -0
  201. package/dist/pc/pc.parser.d.ts +3 -0
  202. package/dist/pc/pc.parser.js +41 -0
  203. package/dist/pc/pc.pools.d.ts +12 -0
  204. package/dist/pc/pc.pools.js +15 -0
  205. package/dist/pc/pc.proficiencies.d.ts +8 -0
  206. package/dist/pc/pc.proficiencies.js +47 -0
  207. package/dist/pc/pc.proficiency-query.d.ts +11 -0
  208. package/dist/pc/pc.proficiency-query.js +17 -0
  209. package/dist/pc/pc.recalc.d.ts +105 -0
  210. package/dist/pc/pc.recalc.js +662 -0
  211. package/dist/pc/pc.resolver.d.ts +34 -0
  212. package/dist/pc/pc.resolver.js +267 -0
  213. package/dist/pc/pc.resource-seed.d.ts +10 -0
  214. package/dist/pc/pc.resource-seed.js +40 -0
  215. package/dist/pc/pc.rest.d.ts +23 -0
  216. package/dist/pc/pc.rest.js +128 -0
  217. package/dist/pc/pc.schema.d.ts +294 -0
  218. package/dist/pc/pc.schema.js +7 -0
  219. package/dist/pc/pc.slotting.d.ts +22 -0
  220. package/dist/pc/pc.slotting.js +20 -0
  221. package/dist/pc/pc.spellcasting.d.ts +56 -0
  222. package/dist/pc/pc.spellcasting.js +16 -0
  223. package/dist/pc/pc.table-column.d.ts +12 -0
  224. package/dist/pc/pc.table-column.js +8 -0
  225. package/dist/pc/pc.types.d.ts +514 -0
  226. package/dist/pc/pc.types.js +0 -0
  227. package/dist/race/race.codec.d.ts +9 -0
  228. package/dist/race/race.codec.js +13 -0
  229. package/dist/race/race.entity-type.d.ts +2 -0
  230. package/dist/race/race.parser.d.ts +3 -0
  231. package/dist/race/race.parser.js +12 -0
  232. package/dist/race/race.schema.d.ts +67 -0
  233. package/dist/race/race.schema.js +11 -0
  234. package/dist/race/race.types.d.ts +44 -0
  235. package/dist/race/race.types.js +0 -0
  236. package/dist/schemas/attack-schema.d.ts +38 -0
  237. package/dist/schemas/choice-schema.d.ts +5 -0
  238. package/dist/schemas/choice-schema.js +7 -0
  239. package/dist/schemas/duration-schema.d.ts +13 -0
  240. package/dist/schemas/duration-schema.js +6 -0
  241. package/dist/schemas/equipment-grant-schema.d.ts +6 -0
  242. package/dist/schemas/equipment-grant-schema.js +12 -0
  243. package/dist/schemas/feature-effect-schema.d.ts +131 -0
  244. package/dist/schemas/feature-effect-schema.js +6 -0
  245. package/dist/schemas/feature-schema.d.ts +2 -0
  246. package/dist/schemas/feature-schema.js +10 -0
  247. package/dist/schemas/index.d.ts +6 -0
  248. package/dist/schemas/resource-schema.d.ts +95 -0
  249. package/dist/schemas/resource-schema.js +12 -0
  250. package/dist/schemas/selection-pool-schema.d.ts +34 -0
  251. package/dist/schemas/selection-pool-schema.js +10 -0
  252. package/dist/spell/spell.access.d.ts +15 -0
  253. package/dist/spell/spell.access.js +25 -0
  254. package/dist/spell/spell.ai-schema.d.ts +24 -0
  255. package/dist/spell/spell.ai-schema.js +6 -0
  256. package/dist/spell/spell.codec.d.ts +3 -0
  257. package/dist/spell/spell.codec.js +8 -0
  258. package/dist/spell/spell.enrichment.d.ts +2 -0
  259. package/dist/spell/spell.enrichment.js +9 -0
  260. package/dist/spell/spell.entity-type.d.ts +2 -0
  261. package/dist/spell/spell.filter.d.ts +15 -0
  262. package/dist/spell/spell.filter.js +87 -0
  263. package/dist/spell/spell.generatable.d.ts +2 -0
  264. package/dist/spell/spell.parser.d.ts +3 -0
  265. package/dist/spell/spell.parser.js +7 -0
  266. package/dist/spell/spell.scaling.d.ts +14 -0
  267. package/dist/spell/spell.scaling.js +28 -0
  268. package/dist/spell/spell.schema.d.ts +31 -0
  269. package/dist/spell/spell.schema.js +6 -0
  270. package/dist/spell/spell.types.d.ts +25 -0
  271. package/dist/spell/spell.types.js +0 -0
  272. package/dist/srd-store.d.ts +53 -0
  273. package/dist/subclass/subclass.codec.d.ts +11 -0
  274. package/dist/subclass/subclass.codec.js +14 -0
  275. package/dist/subclass/subclass.entity-type.d.ts +2 -0
  276. package/dist/subclass/subclass.parser.d.ts +3 -0
  277. package/dist/subclass/subclass.parser.js +13 -0
  278. package/dist/subclass/subclass.schema.d.ts +118 -0
  279. package/dist/subclass/subclass.schema.js +12 -0
  280. package/dist/subclass/subclass.types.d.ts +20 -0
  281. package/dist/subclass/subclass.types.js +0 -0
  282. package/dist/types/abilities.d.ts +8 -0
  283. package/dist/types/abilities.js +0 -0
  284. package/dist/types/ac.d.ts +5 -0
  285. package/dist/types/attack.d.ts +22 -0
  286. package/dist/types/attack.js +0 -0
  287. package/dist/types/casting-option.d.ts +14 -0
  288. package/dist/types/casting-option.js +0 -0
  289. package/dist/types/choice.d.ts +66 -0
  290. package/dist/types/choice.js +6 -0
  291. package/dist/types/edition.d.ts +4 -0
  292. package/dist/types/edition.js +0 -0
  293. package/dist/types/equipment-grant.d.ts +41 -0
  294. package/dist/types/equipment-grant.js +0 -0
  295. package/dist/types/feature-effect.d.ts +79 -0
  296. package/dist/types/feature-effect.js +0 -0
  297. package/dist/types/feature.d.ts +41 -0
  298. package/dist/types/feature.js +0 -0
  299. package/dist/types/formula-context.d.ts +7 -0
  300. package/dist/types/formula-context.js +0 -0
  301. package/dist/types/hp.d.ts +4 -0
  302. package/dist/types/index.d.ts +10 -0
  303. package/dist/types/item-conditions.types.d.ts +63 -0
  304. package/dist/types/item-conditions.types.js +0 -0
  305. package/dist/types/optional-feature.types.d.ts +60 -0
  306. package/dist/types/optional-feature.types.js +0 -0
  307. package/dist/types/resource.d.ts +44 -0
  308. package/dist/types/resource.js +0 -0
  309. package/dist/types/selection-pool.d.ts +37 -0
  310. package/dist/types/selection-pool.js +0 -0
  311. package/dist/types/speed.d.ts +8 -0
  312. package/dist/weapon/weapon.codec.d.ts +12 -0
  313. package/dist/weapon/weapon.codec.js +8 -0
  314. package/dist/weapon/weapon.entity-type.d.ts +2 -0
  315. package/dist/weapon/weapon.parser.d.ts +3 -0
  316. package/dist/weapon/weapon.parser.js +7 -0
  317. package/dist/weapon/weapon.schema.d.ts +34 -0
  318. package/dist/weapon/weapon.schema.js +6 -0
  319. package/dist/weapon/weapon.types.d.ts +36 -0
  320. package/dist/weapon/weapon.types.js +0 -0
  321. package/package.json +32 -0
  322. package/src/data-srd/ATTRIBUTION.md +2 -0
@@ -0,0 +1,185 @@
1
+ // src/item/item.schema.ts
2
+ import { z } from "zod";
3
+ var tier1Conditions = [
4
+ z.object({ kind: z.literal("no_armor") }),
5
+ z.object({ kind: z.literal("no_shield") }),
6
+ z.object({ kind: z.literal("wielding_two_handed") }),
7
+ z.object({ kind: z.literal("is_class"), value: z.string() }),
8
+ z.object({ kind: z.literal("is_race"), value: z.string() }),
9
+ z.object({ kind: z.literal("is_subclass"), value: z.string() })
10
+ ];
11
+ var tier2Conditions = [
12
+ z.object({ kind: z.literal("vs_creature_type"), value: z.string() }),
13
+ z.object({ kind: z.literal("vs_attack_type"), value: z.enum(["ranged", "melee"]) }),
14
+ z.object({ kind: z.literal("on_attack_type"), value: z.enum(["ranged", "melee"]) }),
15
+ z.object({ kind: z.literal("with_weapon_property"), value: z.string() }),
16
+ z.object({ kind: z.literal("vs_spell_save") })
17
+ ];
18
+ var tier3Conditions = [
19
+ z.object({ kind: z.literal("lighting"), value: z.enum(["dim", "bright", "daylight", "darkness"]) }),
20
+ z.object({ kind: z.literal("underwater") }),
21
+ z.object({ kind: z.literal("movement_state"), value: z.enum(["flying", "swimming", "climbing", "mounted"]) })
22
+ ];
23
+ var tier4Conditions = [
24
+ z.object({ kind: z.literal("has_condition"), value: z.string() }),
25
+ z.object({ kind: z.literal("is_concentrating") }),
26
+ z.object({ kind: z.literal("bloodied") })
27
+ ];
28
+ var rawCondition = z.object({ kind: z.literal("raw"), text: z.string() });
29
+ var conditionSchema = z.lazy(
30
+ () => z.discriminatedUnion("kind", [
31
+ ...tier1Conditions,
32
+ ...tier2Conditions,
33
+ ...tier3Conditions,
34
+ ...tier4Conditions,
35
+ rawCondition,
36
+ z.object({ kind: z.literal("any_of"), conditions: z.array(conditionSchema) })
37
+ ])
38
+ );
39
+ var conditionalBonusSchema = z.object({
40
+ value: z.number().int(),
41
+ when: z.array(conditionSchema)
42
+ });
43
+ var numberOrConditional = z.union([z.number().int(), conditionalBonusSchema]);
44
+ var bonusesSchema = z.object({
45
+ ac: numberOrConditional.optional(),
46
+ weapon_attack: numberOrConditional.optional(),
47
+ weapon_damage: numberOrConditional.optional(),
48
+ spell_attack: numberOrConditional.optional(),
49
+ spell_save_dc: numberOrConditional.optional(),
50
+ saving_throws: numberOrConditional.optional(),
51
+ ability_scores: z.object({
52
+ // partial: each ability is independently optional. z.record(enum, …) in
53
+ // Zod v4 treats every enum key as required, which doesn't match the
54
+ // data (e.g. Amulet of Health only sets `con: 19`).
55
+ static: z.object({
56
+ str: z.number().int().optional(),
57
+ dex: z.number().int().optional(),
58
+ con: z.number().int().optional(),
59
+ int: z.number().int().optional(),
60
+ wis: z.number().int().optional(),
61
+ cha: z.number().int().optional()
62
+ }).optional(),
63
+ bonus: z.object({
64
+ str: numberOrConditional.optional(),
65
+ dex: numberOrConditional.optional(),
66
+ con: numberOrConditional.optional(),
67
+ int: numberOrConditional.optional(),
68
+ wis: numberOrConditional.optional(),
69
+ cha: numberOrConditional.optional()
70
+ }).optional()
71
+ }).optional(),
72
+ speed: z.object({
73
+ walk: numberOrConditional.optional(),
74
+ fly: z.union([numberOrConditional, z.literal("walk")]).optional(),
75
+ swim: numberOrConditional.optional(),
76
+ climb: numberOrConditional.optional()
77
+ }).optional()
78
+ });
79
+ var chargesSchema = z.object({
80
+ max: z.number().int(),
81
+ recharge: z.string().optional(),
82
+ recharge_amount: z.string().optional(),
83
+ destroy_on_empty: z.object({
84
+ roll: z.string(),
85
+ threshold: z.number().int(),
86
+ effect: z.string().optional()
87
+ }).optional()
88
+ });
89
+ var attachedSpellsSchema = z.object({
90
+ charges: z.record(z.string(), z.array(z.string())).optional(),
91
+ daily: z.record(z.string(), z.array(z.string())).optional(),
92
+ will: z.array(z.string()).optional(),
93
+ rest: z.record(z.string(), z.array(z.string())).optional(),
94
+ // `limited` = total uses with no recharge (item often consumed when empty).
95
+ // Distinct from `charges` (cost-per-cast) and `daily` (resets per day).
96
+ // Source canonical pipeline emits this for Necklace of Fireballs, Helm of
97
+ // Brilliance, Candle of Invocation, Efreeti Bottle. Key is total available
98
+ // uses (e.g. "9": ["fireball"] for the necklace's 9 beads).
99
+ limited: z.record(z.string(), z.array(z.string())).optional()
100
+ });
101
+ var attunementTagSchema = z.union([
102
+ z.object({ class: z.string(), subclass: z.string().optional() }),
103
+ // alignment can be a single string OR an array of alignment-letter codes
104
+ // (e.g. ["G"] for good, ["L", "G"] for lawful good).
105
+ z.object({ alignment: z.union([z.string(), z.array(z.string())]) }),
106
+ z.object({ race: z.string() }),
107
+ z.object({ creature_type: z.string() }),
108
+ z.object({ spellcasting: z.boolean() })
109
+ ]);
110
+ var attunementCanonicalSchema = z.object({
111
+ required: z.boolean(),
112
+ restriction: z.string().optional(),
113
+ tags: z.array(attunementTagSchema).optional()
114
+ });
115
+ var grantsSchema = z.object({
116
+ proficiency: z.boolean().optional(),
117
+ languages: z.union([z.boolean(), z.array(z.string())]).optional(),
118
+ senses: z.object({
119
+ darkvision: z.number().optional(),
120
+ tremorsense: z.number().optional(),
121
+ truesight: z.number().optional(),
122
+ blindsight: z.number().optional()
123
+ }).optional()
124
+ });
125
+ var containerSchema = z.object({
126
+ capacity_weight: z.number().optional(),
127
+ weightless: z.boolean().optional(),
128
+ pack_contents: z.array(z.string()).optional()
129
+ });
130
+ var lightSchema = z.object({
131
+ bright_radius: z.number(),
132
+ dim_radius: z.number()
133
+ });
134
+ var itemEntitySchema = z.object({
135
+ name: z.string().min(1),
136
+ slug: z.string().optional(),
137
+ type: z.string().optional(),
138
+ rarity: z.string().optional(),
139
+ base_item: z.string().optional(),
140
+ bonuses: bonusesSchema.optional(),
141
+ resist: z.array(z.string()).optional(),
142
+ immune: z.array(z.string()).optional(),
143
+ vulnerable: z.array(z.string()).optional(),
144
+ condition_immune: z.array(z.string()).optional(),
145
+ charges: z.union([chargesSchema, z.number().int().nonnegative()]).optional(),
146
+ attached_spells: attachedSpellsSchema.optional(),
147
+ attunement: z.union([attunementCanonicalSchema, z.boolean(), z.string()]).optional(),
148
+ grants: grantsSchema.optional(),
149
+ container: containerSchema.optional(),
150
+ light: lightSchema.optional(),
151
+ cursed: z.boolean().optional(),
152
+ sentient: z.boolean().optional(),
153
+ focus: z.union([z.boolean(), z.string()]).optional(),
154
+ tier: z.enum(["major", "minor"]).optional(),
155
+ damage: z.union([
156
+ z.object({
157
+ dice: z.string(),
158
+ type: z.string(),
159
+ versatile_dice: z.string().optional()
160
+ }),
161
+ z.string()
162
+ ]).optional(),
163
+ weapon_category: z.string().optional(),
164
+ armor_category: z.string().optional(),
165
+ weight: z.union([z.number(), z.string()]).optional(),
166
+ cost: z.string().optional(),
167
+ source: z.string().optional(),
168
+ page: z.number().int().optional(),
169
+ edition: z.string().optional(),
170
+ description: z.string().optional(),
171
+ entries: z.array(z.unknown()).optional(),
172
+ effects: z.array(z.unknown()).optional(),
173
+ raw: z.record(z.string(), z.unknown()).optional(),
174
+ // Legacy fields preserved
175
+ damage_dice: z.string().optional(),
176
+ damage_type: z.string().optional(),
177
+ properties: z.array(z.string()).optional(),
178
+ recharge: z.string().optional(),
179
+ curse: z.boolean().optional()
180
+ });
181
+
182
+ export {
183
+ conditionSchema,
184
+ itemEntitySchema
185
+ };
@@ -0,0 +1,19 @@
1
+ import {
2
+ optionalFeatureEntitySchema
3
+ } from "./chunk-MDEJHMKK.js";
4
+
5
+ // src/optional-feature/optional-feature.parser.ts
6
+ import { parseYaml } from "@archivist-gg/core";
7
+ function parseOptionalFeature(source) {
8
+ const raw = parseYaml(source, ["name", "slug", "feature_type"]);
9
+ if (!raw.success) return raw;
10
+ const result = optionalFeatureEntitySchema.safeParse({ edition: "2014", ...raw.data });
11
+ if (!result.success) {
12
+ return { success: false, error: `optional-feature schema validation failed: ${result.error.message}` };
13
+ }
14
+ return { success: true, data: result.data };
15
+ }
16
+
17
+ export {
18
+ parseOptionalFeature
19
+ };
@@ -0,0 +1,86 @@
1
+ import {
2
+ itemEntitySchema
3
+ } from "./chunk-4C2KOKLF.js";
4
+
5
+ // src/item/item.parser.ts
6
+ import { parseYaml } from "@archivist-gg/core";
7
+ var KNOWN_KEYS = /* @__PURE__ */ new Set([
8
+ "name",
9
+ "slug",
10
+ "type",
11
+ "rarity",
12
+ "base_item",
13
+ "bonuses",
14
+ "resist",
15
+ "immune",
16
+ "vulnerable",
17
+ "condition_immune",
18
+ "charges",
19
+ "attached_spells",
20
+ "attunement",
21
+ "grants",
22
+ "container",
23
+ "light",
24
+ "cursed",
25
+ "sentient",
26
+ "focus",
27
+ "tier",
28
+ "damage",
29
+ "weapon_category",
30
+ "armor_category",
31
+ "weight",
32
+ "cost",
33
+ "source",
34
+ "page",
35
+ "edition",
36
+ "description",
37
+ "entries",
38
+ "effects",
39
+ "raw",
40
+ // Legacy fields kept (removed in Slice 7 after grep verifies no consumer)
41
+ "damage_dice",
42
+ "damage_type",
43
+ "properties",
44
+ "recharge",
45
+ "curse"
46
+ ]);
47
+ function migrateAttunement(raw) {
48
+ const legacy = raw.requires_attunement;
49
+ if (raw.attunement === void 0 && typeof legacy === "boolean") {
50
+ raw.attunement = { required: legacy };
51
+ }
52
+ if (legacy !== void 0) {
53
+ delete raw.requires_attunement;
54
+ }
55
+ const v = raw.attunement;
56
+ if (v === void 0 || v === null) return;
57
+ if (typeof v === "object" && !Array.isArray(v)) return;
58
+ if (typeof v === "boolean") {
59
+ raw.attunement = { required: v };
60
+ } else if (typeof v === "string") {
61
+ raw.attunement = { required: true, restriction: v };
62
+ }
63
+ }
64
+ function parseItem(source) {
65
+ var _a;
66
+ const raw = parseYaml(source, ["name"]);
67
+ if (!raw.success) return raw;
68
+ migrateAttunement(raw.data);
69
+ const result = itemEntitySchema.safeParse(raw.data);
70
+ if (!result.success) {
71
+ return { success: false, error: `item schema validation failed: ${result.error.message}` };
72
+ }
73
+ const entity = result.data;
74
+ const extras = {};
75
+ for (const [k, v] of Object.entries(raw.data)) {
76
+ if (!KNOWN_KEYS.has(k)) extras[k] = v;
77
+ }
78
+ if (Object.keys(extras).length > 0) {
79
+ entity.raw = { ...(_a = entity.raw) != null ? _a : {}, ...extras };
80
+ }
81
+ return { success: true, data: entity };
82
+ }
83
+
84
+ export {
85
+ parseItem
86
+ };
@@ -0,0 +1,37 @@
1
+ // src/schemas/selection-pool-schema.ts
2
+ import { z } from "zod";
3
+ var wikilinkRegex = /^\[\[[^[\]]+\]\]$/;
4
+ var selectionPoolSchema = z.object({
5
+ id: z.string().min(1),
6
+ label: z.string().min(1),
7
+ source: z.object({
8
+ entity_type: z.literal("optional-feature"),
9
+ where: z.object({
10
+ feature_type: z.string().min(1),
11
+ available_to: z.literal("self")
12
+ })
13
+ }),
14
+ count: z.object({ column: z.string().min(1) }),
15
+ replaceable: z.boolean().optional()
16
+ });
17
+ var poolGrantSchema = z.object({
18
+ pool: z.string().min(1),
19
+ grants: z.array(z.object({
20
+ feature: z.string().regex(wikilinkRegex),
21
+ at_level: z.number().int().positive()
22
+ }))
23
+ });
24
+ var tabDeclSchema = z.object({
25
+ id: z.string().min(1),
26
+ label: z.string().min(1),
27
+ renders: z.object({
28
+ pool: z.string().min(1),
29
+ layout: z.enum(["spell-like", "blocks"]).optional()
30
+ })
31
+ });
32
+
33
+ export {
34
+ selectionPoolSchema,
35
+ poolGrantSchema,
36
+ tabDeclSchema
37
+ };
@@ -0,0 +1,18 @@
1
+ import {
2
+ parseItem
3
+ } from "./chunk-4SSDYJS2.js";
4
+
5
+ // src/item/item.codec.ts
6
+ import yaml from "js-yaml";
7
+ var itemCodec = {
8
+ parse(doc) {
9
+ return parseItem(doc.body);
10
+ },
11
+ serialize(item) {
12
+ return yaml.dump(item, { lineWidth: -1, sortKeys: false });
13
+ }
14
+ };
15
+
16
+ export {
17
+ itemCodec
18
+ };
@@ -0,0 +1,18 @@
1
+ import {
2
+ parseWeapon
3
+ } from "./chunk-6NK2MUD3.js";
4
+
5
+ // src/weapon/weapon.codec.ts
6
+ import yaml from "js-yaml";
7
+ var weaponCodec = {
8
+ parse(doc) {
9
+ return parseWeapon(doc.body);
10
+ },
11
+ serialize(entity) {
12
+ return yaml.dump(entity, { lineWidth: -1, sortKeys: false });
13
+ }
14
+ };
15
+
16
+ export {
17
+ weaponCodec
18
+ };
@@ -0,0 +1,30 @@
1
+ // src/pc/pc.table-column.ts
2
+ function readTableColumn(table, level, keys) {
3
+ var _a;
4
+ const cols = (_a = table == null ? void 0 : table[level]) == null ? void 0 : _a.columns;
5
+ if (!cols) return null;
6
+ for (const k of keys) {
7
+ const raw = cols[k];
8
+ if (raw === void 0 || raw === null) continue;
9
+ const n = typeof raw === "number" ? raw : parseInt(String(raw), 10);
10
+ if (!Number.isNaN(n)) return n;
11
+ }
12
+ return null;
13
+ }
14
+ function numericColumnsAt(table, level) {
15
+ var _a;
16
+ const out = {};
17
+ const cols = (_a = table == null ? void 0 : table[level]) == null ? void 0 : _a.columns;
18
+ if (!cols) return out;
19
+ for (const [k, raw] of Object.entries(cols)) {
20
+ if (raw === void 0 || raw === null) continue;
21
+ const n = typeof raw === "number" ? raw : parseInt(String(raw), 10);
22
+ if (!Number.isNaN(n)) out[k] = n;
23
+ }
24
+ return out;
25
+ }
26
+
27
+ export {
28
+ readTableColumn,
29
+ numericColumnsAt
30
+ };
@@ -0,0 +1,22 @@
1
+ // src/spell/spell.ai-schema.ts
2
+ import { z } from "zod";
3
+ var spellInputSchema = z.object({
4
+ name: z.string().describe("Spell name"),
5
+ level: z.number().min(0).max(9).describe("Spell level (0 for cantrips)"),
6
+ school: z.enum(["abjuration", "conjuration", "divination", "enchantment", "evocation", "illusion", "necromancy", "transmutation"]),
7
+ casting_time: z.string().describe('e.g., "1 action", "1 bonus action"'),
8
+ range: z.string().describe('e.g., "Touch", "120 feet", "Self"'),
9
+ components: z.string().describe('e.g., "V, S", "V, S, M (diamond worth 100 gp)"'),
10
+ duration: z.string().describe('e.g., "Instantaneous", "Concentration, up to 1 minute"'),
11
+ description: z.array(z.string()).describe(
12
+ "Spell description paragraphs. Use inline formula tags for damage and save DCs: `damage:DICE` for damage rolls (e.g. `damage:8d6`), `dc:ABILITY` for save DCs (e.g. `dc:WIS`). Valid abilities: STR, DEX, CON, INT, WIS, CHA."
13
+ ),
14
+ at_higher_levels: z.array(z.string()).optional(),
15
+ classes: z.array(z.string()).optional(),
16
+ ritual: z.boolean().optional(),
17
+ concentration: z.boolean().optional()
18
+ });
19
+
20
+ export {
21
+ spellInputSchema
22
+ };
@@ -0,0 +1,133 @@
1
+ import {
2
+ convertDescToTags,
3
+ detectSpellcastingAbility
4
+ } from "./chunk-RAWJTA45.js";
5
+ import {
6
+ abilityModifier
7
+ } from "./chunk-NAEPSZAM.js";
8
+
9
+ // src/monster/monster.enrichment.ts
10
+ import { toStringSafe } from "@archivist-gg/core";
11
+ var CR_TO_XP = {
12
+ "0": 10,
13
+ "1/8": 25,
14
+ "1/4": 50,
15
+ "1/2": 100,
16
+ "1": 200,
17
+ "2": 450,
18
+ "3": 700,
19
+ "4": 1100,
20
+ "5": 1800,
21
+ "6": 2300,
22
+ "7": 2900,
23
+ "8": 3900,
24
+ "9": 5e3,
25
+ "10": 5900,
26
+ "11": 7200,
27
+ "12": 8400,
28
+ "13": 1e4,
29
+ "14": 11500,
30
+ "15": 13e3,
31
+ "16": 15e3,
32
+ "17": 18e3,
33
+ "18": 2e4,
34
+ "19": 22e3,
35
+ "20": 25e3,
36
+ "21": 33e3,
37
+ "22": 41e3,
38
+ "23": 5e4,
39
+ "24": 62e3,
40
+ "25": 75e3,
41
+ "26": 9e4,
42
+ "27": 105e3,
43
+ "28": 12e4,
44
+ "29": 135e3,
45
+ "30": 155e3
46
+ };
47
+ function parseCR(cr) {
48
+ if (!cr) return 0;
49
+ if (cr.includes("/")) {
50
+ const [num, denom] = cr.split("/").map(Number);
51
+ return num / denom;
52
+ }
53
+ return Number(cr) || 0;
54
+ }
55
+ function getChallengeRatingXP(cr) {
56
+ var _a;
57
+ return (_a = CR_TO_XP[cr]) != null ? _a : 0;
58
+ }
59
+ function getProficiencyBonus(cr) {
60
+ const v = parseCR(cr);
61
+ if (v < 5) return 2;
62
+ if (v < 9) return 3;
63
+ if (v < 13) return 4;
64
+ if (v < 17) return 5;
65
+ if (v < 21) return 6;
66
+ if (v < 25) return 7;
67
+ if (v < 29) return 8;
68
+ return 9;
69
+ }
70
+ function enrichMonster(raw) {
71
+ var _a, _b, _c;
72
+ const cr = toStringSafe((_a = raw.cr) != null ? _a : "0");
73
+ const abilities = raw.abilities;
74
+ const wisdomMod = abilities ? abilityModifier(abilities.wis) : 0;
75
+ const passivePerception = (_b = raw.passive_perception) != null ? _b : 10 + wisdomMod;
76
+ const languages = ((_c = raw.languages) == null ? void 0 : _c.length) ? raw.languages : ["---"];
77
+ const enriched = {
78
+ ...raw,
79
+ cr,
80
+ xp: getChallengeRatingXP(cr),
81
+ proficiency_bonus: getProficiencyBonus(cr),
82
+ passive_perception: passivePerception,
83
+ languages
84
+ };
85
+ convertMonsterEntries(enriched, cr);
86
+ return enriched;
87
+ }
88
+ var MONSTER_SECTIONS = [
89
+ ["traits", "trait"],
90
+ ["actions", "action"],
91
+ ["reactions", "reaction"],
92
+ ["legendary_actions", "legendary"]
93
+ ];
94
+ function convertMonsterEntries(monster, cr) {
95
+ var _a;
96
+ const abilities = monster.abilities;
97
+ if (!abilities) return;
98
+ const profBonus = getProficiencyBonus(cr);
99
+ const spellAbility = detectSpellcastingAbility(
100
+ ((_a = monster.traits) != null ? _a : []).map((f) => {
101
+ var _a2;
102
+ return { name: f.name, entries: (_a2 = f.entries) != null ? _a2 : [] };
103
+ })
104
+ );
105
+ for (const [key, category] of MONSTER_SECTIONS) {
106
+ const features = monster[key];
107
+ if (!Array.isArray(features)) continue;
108
+ for (const feature of features) {
109
+ const f = feature;
110
+ if (!Array.isArray(f.entries)) continue;
111
+ f.entries = f.entries.map((desc) => {
112
+ var _a2;
113
+ if (/\{@\w+/.test(desc)) return desc;
114
+ return convertDescToTags(desc, {
115
+ abilities,
116
+ profBonus,
117
+ actionName: (_a2 = f.name) != null ? _a2 : "",
118
+ actionCategory: category,
119
+ spellAbility
120
+ });
121
+ });
122
+ }
123
+ }
124
+ }
125
+
126
+ export {
127
+ CR_TO_XP,
128
+ parseCR,
129
+ getChallengeRatingXP,
130
+ getProficiencyBonus,
131
+ enrichMonster,
132
+ convertMonsterEntries
133
+ };
@@ -0,0 +1,114 @@
1
+ import {
2
+ weaponEntitySchema
3
+ } from "./chunk-AFKTJXRA.js";
4
+
5
+ // src/weapon/weapon.parser.ts
6
+ import { parseYaml } from "@archivist-gg/core";
7
+ var KNOWN_KEYS = /* @__PURE__ */ new Set([
8
+ "name",
9
+ "slug",
10
+ "category",
11
+ "damage",
12
+ "properties",
13
+ "range",
14
+ "reload",
15
+ "mastery",
16
+ "type_tags",
17
+ "ammo_type",
18
+ "weight",
19
+ "cost",
20
+ "source",
21
+ "page",
22
+ "edition",
23
+ "entries",
24
+ "raw"
25
+ ]);
26
+ var FLAG_PROPERTIES = /* @__PURE__ */ new Set([
27
+ "finesse",
28
+ "light",
29
+ "heavy",
30
+ "two_handed",
31
+ "reach",
32
+ "special",
33
+ "thrown",
34
+ "ammunition",
35
+ "versatile",
36
+ "loading"
37
+ ]);
38
+ var VERSATILE_RE = /^versatile\s*\(\s*(\d+d\d+)\s*\)$/i;
39
+ var THROWN_RE = /^thrown\s*\(\s*range\s+(\d+)\s*\/\s*(\d+)\s*\)$/i;
40
+ var AMMUNITION_RE = /^ammunition\s*\(\s*range\s+(\d+)\s*\/\s*(\d+)\s*\)$/i;
41
+ function extractFromPropertyStrings(input) {
42
+ const out = { properties: [], unparsed: [] };
43
+ if (!Array.isArray(input)) return out;
44
+ for (const raw of input) {
45
+ if (typeof raw !== "string") {
46
+ out.properties.push(raw);
47
+ continue;
48
+ }
49
+ const lower = raw.toLowerCase().trim();
50
+ if (FLAG_PROPERTIES.has(lower)) {
51
+ out.properties.push(lower);
52
+ continue;
53
+ }
54
+ const v = lower.match(VERSATILE_RE);
55
+ if (v) {
56
+ out.properties.push("versatile");
57
+ out.versatile_dice = v[1];
58
+ continue;
59
+ }
60
+ const t = lower.match(THROWN_RE);
61
+ if (t) {
62
+ out.properties.push("thrown");
63
+ out.range = { normal: Number.parseInt(t[1], 10), long: Number.parseInt(t[2], 10) };
64
+ continue;
65
+ }
66
+ const a = lower.match(AMMUNITION_RE);
67
+ if (a) {
68
+ out.properties.push("ammunition");
69
+ out.range = { normal: Number.parseInt(a[1], 10), long: Number.parseInt(a[2], 10) };
70
+ continue;
71
+ }
72
+ out.unparsed.push(raw);
73
+ }
74
+ return out;
75
+ }
76
+ function parseWeapon(source) {
77
+ var _a, _b;
78
+ const raw = parseYaml(source, ["name", "slug", "category", "damage"]);
79
+ if (!raw.success) return raw;
80
+ const propsInput = raw.data.properties;
81
+ if (Array.isArray(propsInput)) {
82
+ const extracted = extractFromPropertyStrings(propsInput);
83
+ raw.data.properties = extracted.properties;
84
+ if (extracted.versatile_dice && raw.data.damage && typeof raw.data.damage === "object") {
85
+ const dmg = raw.data.damage;
86
+ if (dmg.versatile_dice === void 0) dmg.versatile_dice = extracted.versatile_dice;
87
+ }
88
+ if (extracted.range && raw.data.range === void 0) {
89
+ raw.data.range = extracted.range;
90
+ }
91
+ if (extracted.unparsed.length > 0) {
92
+ const existingRaw = (_a = raw.data.raw) != null ? _a : {};
93
+ existingRaw.unparsed_properties = extracted.unparsed;
94
+ raw.data.raw = existingRaw;
95
+ }
96
+ }
97
+ const result = weaponEntitySchema.safeParse(raw.data);
98
+ if (!result.success) {
99
+ return { success: false, error: `weapon schema validation failed: ${result.error.message}` };
100
+ }
101
+ const entity = result.data;
102
+ const extras = {};
103
+ for (const [k, v] of Object.entries(raw.data)) {
104
+ if (!KNOWN_KEYS.has(k)) extras[k] = v;
105
+ }
106
+ if (Object.keys(extras).length > 0) {
107
+ entity.raw = { ...(_b = entity.raw) != null ? _b : {}, ...extras };
108
+ }
109
+ return { success: true, data: entity };
110
+ }
111
+
112
+ export {
113
+ parseWeapon
114
+ };