@optolith/entity-descriptions 0.14.0 → 0.16.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 (62) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/lib/creator.d.ts +17 -12
  3. package/lib/creator.js +89 -17
  4. package/lib/entities/activatable.d.ts +5 -2
  5. package/lib/entities/activatable.js +7 -1
  6. package/lib/entities/alternativeRule.d.ts +1 -1
  7. package/lib/entities/attribute.d.ts +1 -3
  8. package/lib/entities/combatTechnique.d.ts +2 -2
  9. package/lib/entities/condition.d.ts +2 -6
  10. package/lib/entities/culture.d.ts +2 -1
  11. package/lib/entities/curriculum.d.ts +1 -1
  12. package/lib/entities/derivedCharacteristic.d.ts +1 -1
  13. package/lib/entities/disease.d.ts +1 -1
  14. package/lib/entities/disease.js +5 -6
  15. package/lib/entities/elixir.d.ts +1 -1
  16. package/lib/entities/elixir.js +2 -2
  17. package/lib/entities/equipment.d.ts +6 -8
  18. package/lib/entities/equipment.js +517 -213
  19. package/lib/entities/equipmentPackage.d.ts +1 -1
  20. package/lib/entities/experienceLevel.d.ts +1 -3
  21. package/lib/entities/focusRule.d.ts +1 -1
  22. package/lib/entities/influence.d.ts +1 -1
  23. package/lib/entities/liturgicalChant.d.ts +3 -3
  24. package/lib/entities/optionalRule.d.ts +1 -3
  25. package/lib/entities/partial/commonnessRatedAdvantagesAndDisadvantages.d.ts +1 -1
  26. package/lib/entities/partial/enhancements.d.ts +1 -1
  27. package/lib/entities/partial/herbary.d.ts +6 -3
  28. package/lib/entities/partial/herbary.js +5 -3
  29. package/lib/entities/partial/prerequisites/index.d.ts +1 -1
  30. package/lib/entities/partial/rated/activatable/effect.d.ts +1 -1
  31. package/lib/entities/partial/rated/activatable/index.d.ts +1 -1
  32. package/lib/entities/partial/rated/activatable/targetCategory.d.ts +1 -1
  33. package/lib/entities/partial/rated/improvementCost.d.ts +1 -1
  34. package/lib/entities/partial/units/simple.d.ts +55 -0
  35. package/lib/entities/partial/units/simple.js +56 -0
  36. package/lib/entities/personalityTrait.d.ts +1 -1
  37. package/lib/entities/poison.d.ts +1 -1
  38. package/lib/entities/poison.js +2 -2
  39. package/lib/entities/profession.d.ts +2 -1
  40. package/lib/entities/race.d.ts +2 -2
  41. package/lib/entities/sexPractice.d.ts +1 -3
  42. package/lib/entities/skill.d.ts +1 -1
  43. package/lib/entities/spell.d.ts +17 -16
  44. package/lib/entities/state.d.ts +1 -3
  45. package/lib/entities/tradeSecret.d.ts +4 -0
  46. package/lib/entities/tradeSecret.js +77 -0
  47. package/lib/entityDescription.d.ts +118 -0
  48. package/lib/entityDescription.js +1 -0
  49. package/lib/env.d.ts +9 -2
  50. package/lib/helpers/locale.d.ts +4 -0
  51. package/lib/index.d.ts +247 -423
  52. package/lib/index.js +9 -1
  53. package/lib/rawEntityDescription.d.ts +144 -0
  54. package/lib/rawEntityDescription.js +1 -0
  55. package/lib/references/index.d.ts +2 -3
  56. package/lib/references/index.js +11 -16
  57. package/lib/references/page.d.ts +4 -2
  58. package/lib/references/page.js +6 -4
  59. package/lib/references/pageRange.d.ts +3 -3
  60. package/lib/references/pageRange.js +6 -4
  61. package/lib/tsconfig.tsbuildinfo +1 -1
  62. package/package.json +3 -2
@@ -0,0 +1,118 @@
1
+ /**
2
+ * A JSON representation of the rules text for a library entry.
3
+ */
4
+ export type EntityDescription<Cols extends string> = TextEntityDescription | TabularEntityDescription<Cols> | TabularEntityDescription<Cols>[];
5
+ /**
6
+ * A JSON representation of the rules text for a library entry.
7
+ */
8
+ export type TextEntityDescription = {
9
+ type?: "text";
10
+ category?: {
11
+ label: string;
12
+ value: string;
13
+ };
14
+ title: string;
15
+ subtitle?: string;
16
+ badge?: EntityDescriptionBadge;
17
+ className: string;
18
+ body: EntityDescriptionSection[];
19
+ errata?: {
20
+ date: string;
21
+ description: string;
22
+ }[];
23
+ references?: string;
24
+ };
25
+ /**
26
+ * A JSON representation of the rules text for a library entry.
27
+ */
28
+ export type TabularEntityDescription<Cols extends string> = {
29
+ type: "tabular";
30
+ category?: {
31
+ label: string;
32
+ value: string;
33
+ };
34
+ title: string;
35
+ labels: {
36
+ [K in Cols]: string;
37
+ };
38
+ values: {
39
+ [K in Cols]: string;
40
+ };
41
+ additionalInformation?: {
42
+ label: string;
43
+ id: string;
44
+ value: string;
45
+ }[];
46
+ errata?: {
47
+ date: string;
48
+ description: string;
49
+ }[];
50
+ references?: string;
51
+ };
52
+ /**
53
+ * A badge that can be displayed next to the title of a library entry.
54
+ */
55
+ export type EntityDescriptionBadge = {
56
+ type: "level" | "armedCombat" | "unarmedCombat";
57
+ value: string;
58
+ };
59
+ /**
60
+ * A labeled or unlabeled section of a library entry text.
61
+ */
62
+ export type EntityDescriptionSection = EntityDescriptionSectionContent<DefinitionListEntityDescriptionSection> | LabeledEntityDescriptionSection;
63
+ /**
64
+ * A slice of the content of a library entry text.
65
+ */
66
+ export type EntityDescriptionSectionContent<DL> = PlainEntityDescriptionSection | DL | TableEntityDescriptionSection;
67
+ /**
68
+ * A labeled section of a library entry text.
69
+ */
70
+ export type LabeledEntityDescriptionSection = {
71
+ type: "labeled";
72
+ label: string;
73
+ value: EntityDescriptionSectionContent<DefinitionListEntityDescriptionSection>;
74
+ };
75
+ /**
76
+ * A plain text, possibly containing Markdown syntax.
77
+ */
78
+ export type PlainEntityDescriptionSection = {
79
+ type: "plain";
80
+ text: string;
81
+ };
82
+ /**
83
+ * A list of labeled values, such as prerequisites or quality levels.
84
+ */
85
+ export type DefinitionListEntityDescriptionSection = {
86
+ type: "definitionList";
87
+ items: DefinitionListEntityDescriptionSectionItem[];
88
+ };
89
+ /**
90
+ * A list of labeled values, such as prerequisites or quality levels, nested within another definition list.
91
+ */
92
+ export type NestedDefinitionListEntityDescriptionSection = {
93
+ type: "definitionList";
94
+ /**
95
+ * How to render this definition list.
96
+ *
97
+ * - `"hidden"`: The definition list does not look like it is nested, it just looks like it belongs to its parent definition list.
98
+ * - `"nested"`: The definition list is visually nested inside its parent definition list, usually indented and with italic labels instead of bold ones.
99
+ */
100
+ style: "hidden" | "nested";
101
+ items: DefinitionListEntityDescriptionSectionItem[];
102
+ };
103
+ /**
104
+ * A single labeled value in a definition list.
105
+ */
106
+ export type DefinitionListEntityDescriptionSectionItem = {
107
+ label: string;
108
+ value: string | EntityDescriptionSectionContent<NestedDefinitionListEntityDescriptionSection>[];
109
+ };
110
+ /**
111
+ * A table with a header, rows, and an optional footer.
112
+ */
113
+ export type TableEntityDescriptionSection = {
114
+ type: "table";
115
+ header: string[];
116
+ rows: string[][];
117
+ footer?: string[];
118
+ };
@@ -0,0 +1 @@
1
+ export {};
package/lib/env.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import type { AnyNonNullish } from "@elyukai/utils/nullable";
2
2
  import type { Reader } from "@elyukai/utils/reader";
3
- import type { ChildEntityMap, EntityMap } from "@optolith/database-schema/gen";
3
+ import type { ChildEntityMap, EntityMap, LocaleMeasurementAdjustments } from "@optolith/database-schema/gen";
4
4
  import type { GetResolvedSelectOptionById } from "./entities/partial/prerequisites/single/activatable.js";
5
5
  import type { ModifiableParameter } from "./entities/partial/rated/activatable/nonModifiableSuffix.js";
6
6
  import type { Speed } from "./entities/partial/rated/activatable/speed.js";
7
7
  import type { ResponsiveTextSize } from "./entities/partial/responsiveText.js";
8
8
  import { type EnergyUnit } from "./entities/partial/units/energy.js";
9
9
  import type { GetAllChildInstancesForParent, GetAllInstances, GetInstanceById } from "./helpers/getTypes.js";
10
- import type { FormatNumber, LocaleCompare, LocaleJoin } from "./helpers/locale.js";
10
+ import type { FormatDate, FormatNumber, LocaleCompare, LocaleJoin } from "./helpers/locale.js";
11
11
  import type { Format, Translate, TranslateMap, TranslationKeysWithoutParams } from "./helpers/translate.js";
12
+ import type { IdMap } from "./index.js";
12
13
  import type { PublicationOptions } from "./references/publicationOptions.js";
13
14
  /**
14
15
  * The standard set of environment properties for readers in this project.
@@ -16,6 +17,7 @@ import type { PublicationOptions } from "./references/publicationOptions.js";
16
17
  export type EnvMap<E extends keyof EntityMap = never, AE extends keyof EntityMap = never, CE extends keyof ChildEntityMap = never> = {
17
18
  format: Format;
18
19
  formatNumber: FormatNumber;
20
+ formatDate: FormatDate;
19
21
  translate: Translate;
20
22
  translateMap: TranslateMap;
21
23
  localeJoin: LocaleJoin;
@@ -30,6 +32,8 @@ export type EnvMap<E extends keyof EntityMap = never, AE extends keyof EntityMap
30
32
  getResolvedSelectOptionById: GetResolvedSelectOptionById;
31
33
  publicationOptions: PublicationOptions;
32
34
  displayedInProfession: boolean;
35
+ measurementAdjustments: Required<LocaleMeasurementAdjustments>;
36
+ idMap: IdMap;
33
37
  };
34
38
  /**
35
39
  * Shortcuts for selecting keys of the shared environment map type.
@@ -37,6 +41,7 @@ export type EnvMap<E extends keyof EntityMap = never, AE extends keyof EntityMap
37
41
  export type EnvMapAbbr = {
38
42
  f: "format";
39
43
  fn: "formatNumber";
44
+ fd: "formatDate";
40
45
  t: "translate";
41
46
  tm: "translateMap";
42
47
  lj: "localeJoin";
@@ -51,6 +56,8 @@ export type EnvMapAbbr = {
51
56
  rso: "getResolvedSelectOptionById";
52
57
  po: "publicationOptions";
53
58
  dip: "displayedInProfession";
59
+ ma: "measurementAdjustments";
60
+ idm: "idMap";
54
61
  };
55
62
  /**
56
63
  * The standard set of environment properties for readers in this project.
@@ -31,3 +31,7 @@ export type LocaleJoin = (list: string[], type: LocaleJoinType) => string;
31
31
  * A function that formats a number according to the locale’s rules.
32
32
  */
33
33
  export type FormatNumber = (value: number) => string;
34
+ /**
35
+ * A function that formats a date according to the locale’s rules.
36
+ */
37
+ export type FormatDate = (date: Date) => string;