@alpaca-software/40kdc-data 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 (155) hide show
  1. package/README.md +78 -0
  2. package/dist/bundle-schemas.d.ts +3 -0
  3. package/dist/bundle-schemas.js +137 -0
  4. package/dist/cli.d.ts +1 -0
  5. package/dist/cli.js +31 -0
  6. package/dist/codegen-data.d.ts +1 -0
  7. package/dist/codegen-data.js +128 -0
  8. package/dist/commands/translate.d.ts +7 -0
  9. package/dist/commands/translate.js +238 -0
  10. package/dist/commands/validate-all.d.ts +3 -0
  11. package/dist/commands/validate-all.js +20 -0
  12. package/dist/commands/validate-core.d.ts +3 -0
  13. package/dist/commands/validate-core.js +12 -0
  14. package/dist/commands/validate-enrichment.d.ts +3 -0
  15. package/dist/commands/validate-enrichment.js +12 -0
  16. package/dist/convert-faction.d.ts +45 -0
  17. package/dist/convert-faction.js +479 -0
  18. package/dist/converters/configs/adepta-sororitas.d.ts +3 -0
  19. package/dist/converters/configs/adepta-sororitas.js +70 -0
  20. package/dist/converters/configs/adeptus-astartes.d.ts +3 -0
  21. package/dist/converters/configs/adeptus-astartes.js +74 -0
  22. package/dist/converters/configs/adeptus-custodes.d.ts +3 -0
  23. package/dist/converters/configs/adeptus-custodes.js +14 -0
  24. package/dist/converters/configs/adeptus-mechanicus.d.ts +3 -0
  25. package/dist/converters/configs/adeptus-mechanicus.js +51 -0
  26. package/dist/converters/configs/aeldari.d.ts +3 -0
  27. package/dist/converters/configs/aeldari.js +79 -0
  28. package/dist/converters/configs/agents-of-the-imperium.d.ts +3 -0
  29. package/dist/converters/configs/agents-of-the-imperium.js +57 -0
  30. package/dist/converters/configs/astra-militarum.d.ts +3 -0
  31. package/dist/converters/configs/astra-militarum.js +80 -0
  32. package/dist/converters/configs/black-templars.d.ts +3 -0
  33. package/dist/converters/configs/black-templars.js +16 -0
  34. package/dist/converters/configs/blood-angels.d.ts +3 -0
  35. package/dist/converters/configs/blood-angels.js +16 -0
  36. package/dist/converters/configs/chaos-daemons.d.ts +3 -0
  37. package/dist/converters/configs/chaos-daemons.js +40 -0
  38. package/dist/converters/configs/chaos-knights.d.ts +3 -0
  39. package/dist/converters/configs/chaos-knights.js +14 -0
  40. package/dist/converters/configs/chaos-space-marines.d.ts +3 -0
  41. package/dist/converters/configs/chaos-space-marines.js +95 -0
  42. package/dist/converters/configs/crimson-fists.d.ts +3 -0
  43. package/dist/converters/configs/crimson-fists.js +16 -0
  44. package/dist/converters/configs/dark-angels.d.ts +3 -0
  45. package/dist/converters/configs/dark-angels.js +16 -0
  46. package/dist/converters/configs/death-guard.d.ts +3 -0
  47. package/dist/converters/configs/death-guard.js +30 -0
  48. package/dist/converters/configs/deathwatch.d.ts +3 -0
  49. package/dist/converters/configs/deathwatch.js +16 -0
  50. package/dist/converters/configs/drukhari.d.ts +3 -0
  51. package/dist/converters/configs/drukhari.js +51 -0
  52. package/dist/converters/configs/emperors-children.d.ts +3 -0
  53. package/dist/converters/configs/emperors-children.js +38 -0
  54. package/dist/converters/configs/genestealer-cults.d.ts +3 -0
  55. package/dist/converters/configs/genestealer-cults.js +36 -0
  56. package/dist/converters/configs/grey-knights.d.ts +3 -0
  57. package/dist/converters/configs/grey-knights.js +39 -0
  58. package/dist/converters/configs/imperial-fists.d.ts +3 -0
  59. package/dist/converters/configs/imperial-fists.js +16 -0
  60. package/dist/converters/configs/imperial-knights.d.ts +3 -0
  61. package/dist/converters/configs/imperial-knights.js +14 -0
  62. package/dist/converters/configs/iron-hands.d.ts +3 -0
  63. package/dist/converters/configs/iron-hands.js +16 -0
  64. package/dist/converters/configs/leagues-of-votann.d.ts +3 -0
  65. package/dist/converters/configs/leagues-of-votann.js +32 -0
  66. package/dist/converters/configs/necrons.d.ts +3 -0
  67. package/dist/converters/configs/necrons.js +19 -0
  68. package/dist/converters/configs/orks.d.ts +3 -0
  69. package/dist/converters/configs/orks.js +71 -0
  70. package/dist/converters/configs/raven-guard.d.ts +3 -0
  71. package/dist/converters/configs/raven-guard.js +16 -0
  72. package/dist/converters/configs/salamanders.d.ts +3 -0
  73. package/dist/converters/configs/salamanders.js +16 -0
  74. package/dist/converters/configs/space-wolves.d.ts +3 -0
  75. package/dist/converters/configs/space-wolves.js +16 -0
  76. package/dist/converters/configs/tau-empire.d.ts +3 -0
  77. package/dist/converters/configs/tau-empire.js +44 -0
  78. package/dist/converters/configs/thousand-sons.d.ts +3 -0
  79. package/dist/converters/configs/thousand-sons.js +30 -0
  80. package/dist/converters/configs/tyranids.d.ts +3 -0
  81. package/dist/converters/configs/tyranids.js +27 -0
  82. package/dist/converters/configs/ultramarines.d.ts +3 -0
  83. package/dist/converters/configs/ultramarines.js +16 -0
  84. package/dist/converters/configs/white-scars.d.ts +3 -0
  85. package/dist/converters/configs/white-scars.js +16 -0
  86. package/dist/converters/configs/world-eaters.d.ts +3 -0
  87. package/dist/converters/configs/world-eaters.js +43 -0
  88. package/dist/converters/faction-config.d.ts +53 -0
  89. package/dist/converters/faction-config.js +22 -0
  90. package/dist/converters/id-generator.d.ts +14 -0
  91. package/dist/converters/id-generator.js +65 -0
  92. package/dist/converters/keyword-filter.d.ts +26 -0
  93. package/dist/converters/keyword-filter.js +78 -0
  94. package/dist/converters/stat-parser.d.ts +22 -0
  95. package/dist/converters/stat-parser.js +84 -0
  96. package/dist/converters/view-selector.d.ts +54 -0
  97. package/dist/converters/view-selector.js +96 -0
  98. package/dist/converters/weapon-dedup.d.ts +60 -0
  99. package/dist/converters/weapon-dedup.js +120 -0
  100. package/dist/data/bundle.generated.d.ts +3 -0
  101. package/dist/data/bundle.generated.js +3 -0
  102. package/dist/data/collection.d.ts +64 -0
  103. package/dist/data/collection.js +118 -0
  104. package/dist/data/dataset.d.ts +50 -0
  105. package/dist/data/dataset.js +134 -0
  106. package/dist/data/entities.d.ts +80 -0
  107. package/dist/data/entities.js +133 -0
  108. package/dist/data/index.d.ts +59 -0
  109. package/dist/data/index.js +57 -0
  110. package/dist/data/normalize.d.ts +29 -0
  111. package/dist/data/normalize.js +37 -0
  112. package/dist/data/types.d.ts +43 -0
  113. package/dist/data/types.js +25 -0
  114. package/dist/generated.d.ts +1084 -0
  115. package/dist/generated.js +2 -0
  116. package/dist/index.d.ts +3 -0
  117. package/dist/index.js +7 -0
  118. package/dist/known-support-10e.d.ts +31 -0
  119. package/dist/known-support-10e.js +113 -0
  120. package/dist/port-10e-faction.d.ts +52 -0
  121. package/dist/port-10e-faction.js +413 -0
  122. package/dist/report.d.ts +3 -0
  123. package/dist/report.js +31 -0
  124. package/dist/schema-loader.d.ts +15 -0
  125. package/dist/schema-loader.js +79 -0
  126. package/dist/validate.d.ts +21 -0
  127. package/dist/validate.js +124 -0
  128. package/package.json +77 -0
  129. package/schemas/$defs/common.schema.json +86 -0
  130. package/schemas/$defs/game-version-ref.schema.json +11 -0
  131. package/schemas/core/deployment-pattern.schema.json +102 -0
  132. package/schemas/core/detachment.schema.json +56 -0
  133. package/schemas/core/enhancement.schema.json +46 -0
  134. package/schemas/core/faction.schema.json +29 -0
  135. package/schemas/core/force-disposition.schema.json +22 -0
  136. package/schemas/core/game-version.schema.json +20 -0
  137. package/schemas/core/leader-attachment.schema.json +18 -0
  138. package/schemas/core/mission-matchup.schema.json +25 -0
  139. package/schemas/core/mission.schema.json +42 -0
  140. package/schemas/core/roster.schema.json +203 -0
  141. package/schemas/core/secondary-card.schema.json +195 -0
  142. package/schemas/core/stratagem.schema.json +58 -0
  143. package/schemas/core/terrain-layout.schema.json +135 -0
  144. package/schemas/core/unit-composition.schema.json +38 -0
  145. package/schemas/core/unit.schema.json +125 -0
  146. package/schemas/core/wargear-option.schema.json +47 -0
  147. package/schemas/core/weapon.schema.json +56 -0
  148. package/schemas/enrichment/ability-dsl/ability.schema.json +60 -0
  149. package/schemas/enrichment/ability-dsl/condition.schema.json +48 -0
  150. package/schemas/enrichment/ability-dsl/effect.schema.json +145 -0
  151. package/schemas/enrichment/ability-dsl/scope.schema.json +12 -0
  152. package/schemas/enrichment/interaction-flag.schema.json +17 -0
  153. package/schemas/enrichment/phase-mapping.schema.json +14 -0
  154. package/schemas/enrichment/resource-pool.schema.json +36 -0
  155. package/schemas/enrichment/timing-flag.schema.json +28 -0
@@ -0,0 +1,57 @@
1
+ /**
2
+ * The linked, typed 40kdc dataset.
3
+ *
4
+ * The default {@link dataset} is built once from the data embedded in this
5
+ * package; the top-level collections below are its accessors, re-exported for
6
+ * the ergonomic one-liner form.
7
+ *
8
+ * @packageDocumentation
9
+ *
10
+ * @example
11
+ * import { units } from "@alpaca-software/40kdc-data";
12
+ *
13
+ * units.find("Kharn")!.abilities
14
+ * .filter(a => a.phases.includes("shooting"))
15
+ * .map(a => a.id); // ["berzerker-frenzy"]
16
+ *
17
+ * @example
18
+ * import { factions } from "@alpaca-software/40kdc-data";
19
+ *
20
+ * factions.find("World Eaters")!.units.length;
21
+ */
22
+ export { Dataset } from "./dataset.js";
23
+ export { Collection } from "./collection.js";
24
+ export { UnitView, AbilityView, WeaponView, FactionView } from "./entities.js";
25
+ export { normalizeName } from "./normalize.js";
26
+ export { emptyRawData } from "./types.js";
27
+ import { Dataset } from "./dataset.js";
28
+ /** The dataset built from this package's embedded data. */
29
+ export const dataset = Dataset.embedded();
30
+ /** All units, linked to their faction, weapons, and abilities. */
31
+ export const units = dataset.units;
32
+ /** All weapons, linked to the units that carry them. */
33
+ export const weapons = dataset.weapons;
34
+ /** All factions, linked to their units, abilities, and weapons. */
35
+ export const factions = dataset.factions;
36
+ /** All abilities, linked to their phases and the units that have them. */
37
+ export const abilities = dataset.abilities;
38
+ /** All detachments. */
39
+ export const detachments = dataset.detachments;
40
+ /** All enhancements. */
41
+ export const enhancements = dataset.enhancements;
42
+ /** All stratagems. */
43
+ export const stratagems = dataset.stratagems;
44
+ /** All wargear options. */
45
+ export const wargearOptions = dataset.wargearOptions;
46
+ /** All missions. */
47
+ export const missions = dataset.missions;
48
+ /** All mission matchups. */
49
+ export const missionMatchups = dataset.missionMatchups;
50
+ /** All secondary mission cards. */
51
+ export const secondaryCards = dataset.secondaryCards;
52
+ /** All deployment patterns. */
53
+ export const deploymentPatterns = dataset.deploymentPatterns;
54
+ /** All force dispositions. */
55
+ export const forceDispositions = dataset.forceDispositions;
56
+ /** All resource pools. */
57
+ export const resourcePools = dataset.resourcePools;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Name normalization for diacritic- and punctuation-insensitive lookup.
3
+ *
4
+ * Warhammer 40,000 is played globally and many entity names carry diacritics or
5
+ * punctuation — "Khârn the Betrayer", "T'au", "Be'lakor". A user typing the
6
+ * plain-ASCII form of a name must still find the entity. Every name comparison
7
+ * in this package routes through {@link normalizeName} so the matching rule is
8
+ * defined in exactly one place; consumers can import it to reproduce the same
9
+ * behaviour in their own search UIs.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ /**
14
+ * Reduce a display name to a canonical lookup key.
15
+ *
16
+ * The transform, in order:
17
+ * 1. Unicode NFD-decompose, then strip combining marks — `Khârn` → `Kharn`.
18
+ * 2. Casefold to lower case.
19
+ * 3. Remove apostrophe and quote variants (`' ’ ‘ \` " “ ”`) — `T'au` → `Tau`.
20
+ * 4. Collapse any run of whitespace or hyphens to a single space, then trim —
21
+ * `Be'lakor` → `belakor`, `the betrayer` → `the betrayer`.
22
+ *
23
+ * The result is intended only for comparison; it is not a display value.
24
+ *
25
+ * @example
26
+ * normalizeName("Khârn the Betrayer"); // "kharn the betrayer"
27
+ * normalizeName("T'au"); // "tau"
28
+ */
29
+ export declare function normalizeName(input: string): string;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Name normalization for diacritic- and punctuation-insensitive lookup.
3
+ *
4
+ * Warhammer 40,000 is played globally and many entity names carry diacritics or
5
+ * punctuation — "Khârn the Betrayer", "T'au", "Be'lakor". A user typing the
6
+ * plain-ASCII form of a name must still find the entity. Every name comparison
7
+ * in this package routes through {@link normalizeName} so the matching rule is
8
+ * defined in exactly one place; consumers can import it to reproduce the same
9
+ * behaviour in their own search UIs.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ /**
14
+ * Reduce a display name to a canonical lookup key.
15
+ *
16
+ * The transform, in order:
17
+ * 1. Unicode NFD-decompose, then strip combining marks — `Khârn` → `Kharn`.
18
+ * 2. Casefold to lower case.
19
+ * 3. Remove apostrophe and quote variants (`' ’ ‘ \` " “ ”`) — `T'au` → `Tau`.
20
+ * 4. Collapse any run of whitespace or hyphens to a single space, then trim —
21
+ * `Be'lakor` → `belakor`, `the betrayer` → `the betrayer`.
22
+ *
23
+ * The result is intended only for comparison; it is not a display value.
24
+ *
25
+ * @example
26
+ * normalizeName("Khârn the Betrayer"); // "kharn the betrayer"
27
+ * normalizeName("T'au"); // "tau"
28
+ */
29
+ export function normalizeName(input) {
30
+ return input
31
+ .normalize("NFD")
32
+ .replace(/\p{Diacritic}/gu, "")
33
+ .toLowerCase()
34
+ .replace(/['’‘`"“”]/g, "")
35
+ .replace(/[\s-]+/g, " ")
36
+ .trim();
37
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The shape of the embedded data bundle: one named array per entity collection.
3
+ *
4
+ * `RawData` is the boundary between the generated JSON-Schema types and the
5
+ * linked view layer. The codegen ({@link file://../codegen-data.ts}) emits a
6
+ * `RAW_DATA: RawData` constant; {@link Dataset} wraps it with linked accessors.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ import type { AbilityDSLEntry, DeploymentPattern, Detachment, Enhancement, Faction, ForceDisposition, GameVersion, InteractionFlag, LeaderAttachment, Mission, MissionMatchup, PhaseMapping, ResourcePool, SecondaryCard, Stratagem, TimingFlag, Unit, UnitComposition, WargearOption, Weapon } from "../generated.js";
11
+ /**
12
+ * Every entity collection in the dataset, keyed by camelCase collection name.
13
+ *
14
+ * Collections with no authored data yet (e.g. `interactionFlags`) are present
15
+ * as empty arrays so the API surface is stable and new data flows through
16
+ * automatically once authored.
17
+ */
18
+ export interface RawData {
19
+ units: Unit[];
20
+ weapons: Weapon[];
21
+ factions: Faction[];
22
+ /** Community-authored ability mechanics (key is `ability_id`, not `id`). */
23
+ abilities: AbilityDSLEntry[];
24
+ /** Phase assignments, joined to abilities/stratagems/etc. via `source_id`. */
25
+ phaseMappings: PhaseMapping[];
26
+ detachments: Detachment[];
27
+ stratagems: Stratagem[];
28
+ enhancements: Enhancement[];
29
+ leaderAttachments: LeaderAttachment[];
30
+ unitCompositions: UnitComposition[];
31
+ wargearOptions: WargearOption[];
32
+ gameVersions: GameVersion[];
33
+ missions: Mission[];
34
+ missionMatchups: MissionMatchup[];
35
+ secondaryCards: SecondaryCard[];
36
+ deploymentPatterns: DeploymentPattern[];
37
+ forceDispositions: ForceDisposition[];
38
+ resourcePools: ResourcePool[];
39
+ timingFlags: TimingFlag[];
40
+ interactionFlags: InteractionFlag[];
41
+ }
42
+ /** A `RawData` with every collection initialised to an empty array. */
43
+ export declare function emptyRawData(): RawData;
@@ -0,0 +1,25 @@
1
+ /** A `RawData` with every collection initialised to an empty array. */
2
+ export function emptyRawData() {
3
+ return {
4
+ units: [],
5
+ weapons: [],
6
+ factions: [],
7
+ abilities: [],
8
+ phaseMappings: [],
9
+ detachments: [],
10
+ stratagems: [],
11
+ enhancements: [],
12
+ leaderAttachments: [],
13
+ unitCompositions: [],
14
+ wargearOptions: [],
15
+ gameVersions: [],
16
+ missions: [],
17
+ missionMatchups: [],
18
+ secondaryCards: [],
19
+ deploymentPatterns: [],
20
+ forceDispositions: [],
21
+ resourcePools: [],
22
+ timingFlags: [],
23
+ interactionFlags: [],
24
+ };
25
+ }