@optolith/entity-descriptions 0.3.2 → 0.4.1

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 (93) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/lib/creator.d.ts +2 -2
  3. package/lib/creator.js +1 -1
  4. package/lib/entities/activatable.js +35 -64
  5. package/lib/entities/culture.js +18 -26
  6. package/lib/entities/curriculum.js +30 -33
  7. package/lib/entities/derivedCharacteristic.js +1 -1
  8. package/lib/entities/disease.js +3 -6
  9. package/lib/entities/elixir.js +6 -4
  10. package/lib/entities/equipment.js +17 -17
  11. package/lib/entities/equipmentPackage.js +4 -3
  12. package/lib/entities/experienceLevel.js +7 -7
  13. package/lib/entities/focusRule.js +2 -2
  14. package/lib/entities/influence.js +2 -2
  15. package/lib/entities/liturgicalChant.d.ts +1 -1
  16. package/lib/entities/partial/adventurePointsValue.js +14 -19
  17. package/lib/entities/partial/enhancements.d.ts +1 -1
  18. package/lib/entities/partial/enhancements.js +1 -1
  19. package/lib/entities/partial/herbary.js +13 -9
  20. package/lib/entities/partial/map.d.ts +3 -1
  21. package/lib/entities/partial/map.js +21 -8
  22. package/lib/entities/partial/mathOperation.js +12 -17
  23. package/lib/entities/partial/prerequisites/displayOption.d.ts +2 -2
  24. package/lib/entities/partial/prerequisites/index.d.ts +3 -3
  25. package/lib/entities/partial/prerequisites/index.js +10 -4
  26. package/lib/entities/partial/prerequisites/part.d.ts +1 -1
  27. package/lib/entities/partial/prerequisites/prerequisiteGroups.d.ts +4 -4
  28. package/lib/entities/partial/prerequisites/prerequisiteGroups.js +1 -1
  29. package/lib/entities/partial/prerequisites/single/activatable.d.ts +3 -3
  30. package/lib/entities/partial/prerequisites/single/animistPower.d.ts +2 -2
  31. package/lib/entities/partial/prerequisites/single/animistPower.js +1 -1
  32. package/lib/entities/partial/prerequisites/single/blessedTradition.d.ts +2 -2
  33. package/lib/entities/partial/prerequisites/single/commonSuggestedByRCP.d.ts +2 -2
  34. package/lib/entities/partial/prerequisites/single/culture.d.ts +4 -4
  35. package/lib/entities/partial/prerequisites/single/enhancement.d.ts +4 -4
  36. package/lib/entities/partial/prerequisites/single/influence.d.ts +3 -3
  37. package/lib/entities/partial/prerequisites/single/magicalTradition.d.ts +2 -2
  38. package/lib/entities/partial/prerequisites/single/noOtherAncestorBloodAdvantage.d.ts +2 -2
  39. package/lib/entities/partial/prerequisites/single/pact.d.ts +3 -3
  40. package/lib/entities/partial/prerequisites/single/personalityTrait.d.ts +4 -4
  41. package/lib/entities/partial/prerequisites/single/primaryAttribute.d.ts +3 -3
  42. package/lib/entities/partial/prerequisites/single/primaryAttribute.js +1 -1
  43. package/lib/entities/partial/prerequisites/single/profession.d.ts +4 -4
  44. package/lib/entities/partial/prerequisites/single/publication.d.ts +4 -4
  45. package/lib/entities/partial/prerequisites/single/race.d.ts +4 -4
  46. package/lib/entities/partial/prerequisites/single/rated.d.ts +2 -2
  47. package/lib/entities/partial/prerequisites/single/rated.js +2 -2
  48. package/lib/entities/partial/prerequisites/single/ratedMinimumNumber.d.ts +3 -3
  49. package/lib/entities/partial/prerequisites/single/ratedMinimumNumber.js +1 -1
  50. package/lib/entities/partial/prerequisites/single/ratedSum.d.ts +4 -4
  51. package/lib/entities/partial/prerequisites/single/rule.d.ts +3 -3
  52. package/lib/entities/partial/prerequisites/single/sex.d.ts +1 -1
  53. package/lib/entities/partial/prerequisites/single/sexualCharacteristic.d.ts +3 -3
  54. package/lib/entities/partial/prerequisites/single/socialStatus.d.ts +3 -3
  55. package/lib/entities/partial/prerequisites/single/state.d.ts +4 -4
  56. package/lib/entities/partial/prerequisites/single/text.d.ts +3 -3
  57. package/lib/entities/partial/rated/activatable/castingTime.d.ts +1 -1
  58. package/lib/entities/partial/rated/activatable/castingTime.js +6 -8
  59. package/lib/entities/partial/rated/activatable/cost.d.ts +1 -1
  60. package/lib/entities/partial/rated/activatable/cost.js +17 -14
  61. package/lib/entities/partial/rated/activatable/duration.js +4 -4
  62. package/lib/entities/partial/rated/activatable/effect.js +1 -1
  63. package/lib/entities/partial/rated/activatable/isMinimumMaximum.js +2 -2
  64. package/lib/entities/partial/rated/activatable/range.js +6 -6
  65. package/lib/entities/partial/rated/activatable/speed.d.ts +1 -1
  66. package/lib/entities/partial/rated/activatable/targetCategory.js +2 -2
  67. package/lib/entities/partial/reader.d.ts +4 -2
  68. package/lib/entities/partial/responsiveText.d.ts +5 -1
  69. package/lib/entities/partial/responsiveText.js +3 -5
  70. package/lib/entities/partial/units/length.d.ts +1 -1
  71. package/lib/entities/partial/units/length.js +2 -10
  72. package/lib/entities/partial/units/timeSpan.d.ts +4 -4
  73. package/lib/entities/partial/units/timeSpan.js +21 -17
  74. package/lib/entities/personalityTrait.js +3 -4
  75. package/lib/entities/poison.js +4 -4
  76. package/lib/entities/profession.d.ts +1 -1
  77. package/lib/entities/profession.js +19 -14
  78. package/lib/entities/race.js +11 -13
  79. package/lib/entities/sexPractice.js +1 -3
  80. package/lib/entities/skill.js +2 -3
  81. package/lib/entities/spell.js +14 -4
  82. package/lib/helpers/getTypes.d.ts +2 -2
  83. package/lib/helpers/locale.d.ts +8 -2
  84. package/lib/helpers/translate.d.ts +1 -1
  85. package/lib/index.d.ts +11 -2
  86. package/lib/index.js +5 -0
  87. package/lib/references/index.d.ts +1 -1
  88. package/lib/references/index.js +1 -1
  89. package/lib/references/page.d.ts +3 -3
  90. package/lib/references/page.js +1 -1
  91. package/lib/references/pageRange.d.ts +2 -2
  92. package/lib/tsconfig.tsbuildinfo +1 -1
  93. package/package.json +4 -3
package/lib/index.d.ts CHANGED
@@ -6,12 +6,14 @@ import type { EntityDescriptionCreator } from "./creator.js";
6
6
  import type { GetResolvedSelectOptionById } from "./entities/partial/prerequisites/single/activatable.js";
7
7
  import type { CountInstances, GetAllChildInstancesForParent, GetAllInstances, GetInstanceById } from "./helpers/getTypes.js";
8
8
  import type { LocaleEnvironment } from "./helpers/locale.js";
9
+ export type { LocaleEnvironment };
9
10
  /**
10
11
  * A JSON representation of the rules text for a library entry.
11
12
  */
12
13
  export type EntityDescription = {
13
14
  title: string;
14
15
  subtitle?: string;
16
+ badge?: number;
15
17
  className: string;
16
18
  body: EntityDescriptionSection[];
17
19
  errata?: {
@@ -43,6 +45,7 @@ export type EntityDescriptionSectionContent<DL = DefinitionListEntityDescription
43
45
  export type RawEntityDescription = {
44
46
  title: string;
45
47
  subtitle?: string;
48
+ badge?: number;
46
49
  className: string;
47
50
  body: (RawEntityDescriptionSection | undefined)[];
48
51
  errata?: Errata;
@@ -847,11 +850,18 @@ declare const registeredEntityDescriptionCreators: {
847
850
  getInstanceById: GetInstanceById<"Publication">;
848
851
  }, EntityDescription>;
849
852
  };
850
- type AvailableCreatorEntity = keyof typeof registeredEntityDescriptionCreators;
853
+ /**
854
+ * The set of entities for which there is a registered description creator function.
855
+ */
856
+ export type AvailableCreatorEntity = keyof typeof registeredEntityDescriptionCreators;
851
857
  /**
852
858
  * Checks if there is a registered description creator for the given entity name.
853
859
  */
854
860
  export declare const isSupportedEntity: (entityName: string) => entityName is AvailableCreatorEntity;
861
+ /**
862
+ * The list of entity names for which there is a registered description creator function.
863
+ */
864
+ export declare const supportedEntities: AvailableCreatorEntity[];
855
865
  /**
856
866
  * Human-readable aliases for certain identifiers in the database.
857
867
  */
@@ -875,4 +885,3 @@ export type GetAllResolvedSkillUses = (id: Skill_ID) => ResolvedSkillUse[];
875
885
  * Get a JSON representation of the rules text for an entry in the database.
876
886
  */
877
887
  export declare const getEntityDescription: <E extends AvailableCreatorEntity>(database: TSONDB<TSONDBTypes>, localeEnv: LocaleEnvironment, idMap: IdMap, getResolvedSelectOptionById: GetResolvedSelectOptionById, getAllResolvedSelectOptions: GetAllResolvedSelectOptions, getAllResolvedNewSkillApplications: GetAllResolvedNewSkillApplications, getAllResolvedSkillUses: GetAllResolvedSkillUses, entityName: E, instanceId: string) => EntityDescription | undefined;
878
- export {};
package/lib/index.js CHANGED
@@ -164,9 +164,14 @@ const registeredEntityDescriptionCreators = {
164
164
  * Checks if there is a registered description creator for the given entity name.
165
165
  */
166
166
  export const isSupportedEntity = (entityName) => entityName in registeredEntityDescriptionCreators;
167
+ /**
168
+ * The list of entity names for which there is a registered description creator function.
169
+ */
170
+ export const supportedEntities = Object.keys(registeredEntityDescriptionCreators).toSorted();
167
171
  /**
168
172
  * Get a JSON representation of the rules text for an entry in the database.
169
173
  */
174
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- false positive
170
175
  export const getEntityDescription = (database, localeEnv, idMap, getResolvedSelectOptionById, getAllResolvedSelectOptions, getAllResolvedNewSkillApplications, getAllResolvedSkillUses, entityName, instanceId) => {
171
176
  const creator = registeredEntityDescriptionCreators[entityName];
172
177
  const instance = database.getInstanceOfEntityById(entityName, instanceId);
@@ -1,6 +1,6 @@
1
1
  import type { PublicationRefs } from "optolith-database-schema/gen";
2
2
  import type { GetInstanceById } from "../helpers/getTypes.js";
3
- import { LocaleEnvironment } from "../helpers/locale.js";
3
+ import type { LocaleEnvironment } from "../helpers/locale.js";
4
4
  /**
5
5
  * Returns the translation of the references.
6
6
  */
@@ -1,6 +1,6 @@
1
1
  import { isNotNullish } from "@optolith/helpers/nullable";
2
2
  import { assertExhaustive } from "@optolith/helpers/typeSafety";
3
- import { fromRawPageRange, normalizePageRanges, printPageRanges, } from "./pageRange.js";
3
+ import { fromRawPageRange, normalizePageRanges, printPageRanges } from "./pageRange.js";
4
4
  /**
5
5
  * Returns the translation of the references.
6
6
  */
@@ -1,6 +1,6 @@
1
- import { Compare } from "@optolith/helpers/compare";
2
- import { Page } from "optolith-database-schema/gen";
3
- import { Translate } from "../helpers/translate.js";
1
+ import type { Compare } from "@optolith/helpers/compare";
2
+ import type { Page } from "optolith-database-schema/gen";
3
+ import type { Translate } from "../helpers/translate.js";
4
4
  /**
5
5
  * A comparison function for two pages.
6
6
  */
@@ -54,7 +54,7 @@ export const printPage = (translate, page) => {
54
54
  case "InsideCoverBack":
55
55
  return translate("Back Cover Inside");
56
56
  case "Numbered":
57
- return page.Numbered.toString();
57
+ return page.Numbered.toFixed();
58
58
  default:
59
59
  return assertExhaustive(page);
60
60
  }
@@ -1,5 +1,5 @@
1
- import { Page, PageRange as RawPageRange } from "optolith-database-schema/gen";
2
- import { Translate } from "../helpers/translate.js";
1
+ import type { Page, PageRange as RawPageRange } from "optolith-database-schema/gen";
2
+ import type { Translate } from "../helpers/translate.js";
3
3
  /**
4
4
  * A range of pages, including the first and last page, if the range includes
5
5
  * more than on page.