@optolith/entity-descriptions 0.4.11 → 0.4.13

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 (87) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/lib/creator.d.ts +1 -1
  3. package/lib/entities/activatable.d.ts +1 -1
  4. package/lib/entities/activatable.js +68 -0
  5. package/lib/entities/culture.d.ts +2 -0
  6. package/lib/entities/culture.js +20 -14
  7. package/lib/entities/curriculum.js +103 -19
  8. package/lib/entities/disease.d.ts +1 -1
  9. package/lib/entities/elixir.d.ts +1 -1
  10. package/lib/entities/equipment.d.ts +2 -2
  11. package/lib/entities/equipmentPackage.d.ts +1 -1
  12. package/lib/entities/influence.d.ts +1 -1
  13. package/lib/entities/liturgicalChant.d.ts +1 -1
  14. package/lib/entities/partial/activatableNameChunks.d.ts +11 -3
  15. package/lib/entities/partial/activatableNameChunks.js +27 -12
  16. package/lib/entities/partial/adventurePointsValue.d.ts +2 -2
  17. package/lib/entities/partial/animalTypes.d.ts +1 -1
  18. package/lib/entities/partial/animalTypes.js +2 -1
  19. package/lib/entities/partial/commonnessRatedAdvantagesAndDisadvantages.d.ts +4 -4
  20. package/lib/entities/partial/commonnessRatedAdvantagesAndDisadvantages.js +56 -13
  21. package/lib/entities/partial/dice.d.ts +1 -1
  22. package/lib/entities/partial/enhancements.d.ts +1 -1
  23. package/lib/entities/partial/herbary.d.ts +1 -1
  24. package/lib/entities/partial/map.d.ts +1 -1
  25. package/lib/entities/partial/map.js +1 -1
  26. package/lib/entities/partial/markdown.d.ts +2 -2
  27. package/lib/entities/partial/markdown.js +4 -1
  28. package/lib/entities/partial/mathOperation.d.ts +1 -1
  29. package/lib/entities/partial/prerequisites/displayOption.d.ts +1 -1
  30. package/lib/entities/partial/prerequisites/index.d.ts +1 -1
  31. package/lib/entities/partial/prerequisites/part.d.ts +1 -1
  32. package/lib/entities/partial/prerequisites/prerequisiteGroups.d.ts +1 -1
  33. package/lib/entities/partial/prerequisites/single/activatable.d.ts +2 -2
  34. package/lib/entities/partial/prerequisites/single/animistPower.d.ts +1 -1
  35. package/lib/entities/partial/prerequisites/single/blessedTradition.d.ts +1 -1
  36. package/lib/entities/partial/prerequisites/single/culture.d.ts +1 -1
  37. package/lib/entities/partial/prerequisites/single/enhancement.d.ts +1 -1
  38. package/lib/entities/partial/prerequisites/single/influence.d.ts +1 -1
  39. package/lib/entities/partial/prerequisites/single/magicalTradition.d.ts +1 -1
  40. package/lib/entities/partial/prerequisites/single/pact.d.ts +1 -1
  41. package/lib/entities/partial/prerequisites/single/personalityTrait.d.ts +1 -1
  42. package/lib/entities/partial/prerequisites/single/primaryAttribute.d.ts +1 -1
  43. package/lib/entities/partial/prerequisites/single/profession.d.ts +1 -1
  44. package/lib/entities/partial/prerequisites/single/publication.d.ts +1 -1
  45. package/lib/entities/partial/prerequisites/single/race.d.ts +1 -1
  46. package/lib/entities/partial/prerequisites/single/rated.d.ts +1 -1
  47. package/lib/entities/partial/prerequisites/single/ratedMinimumNumber.d.ts +1 -1
  48. package/lib/entities/partial/prerequisites/single/ratedSum.d.ts +1 -1
  49. package/lib/entities/partial/prerequisites/single/rule.d.ts +1 -1
  50. package/lib/entities/partial/prerequisites/single/sex.d.ts +1 -1
  51. package/lib/entities/partial/prerequisites/single/sexualCharacteristic.d.ts +1 -1
  52. package/lib/entities/partial/prerequisites/single/socialStatus.d.ts +1 -1
  53. package/lib/entities/partial/prerequisites/single/state.d.ts +1 -1
  54. package/lib/entities/partial/prerequisites/single/text.d.ts +1 -1
  55. package/lib/entities/partial/professions.d.ts +1 -1
  56. package/lib/entities/partial/professions.js +2 -4
  57. package/lib/entities/partial/rated/activatable/castingTime.d.ts +1 -1
  58. package/lib/entities/partial/rated/activatable/checkResultBased.d.ts +1 -1
  59. package/lib/entities/partial/rated/activatable/cost.d.ts +1 -1
  60. package/lib/entities/partial/rated/activatable/duration.d.ts +1 -1
  61. package/lib/entities/partial/rated/activatable/effect.d.ts +1 -1
  62. package/lib/entities/partial/rated/activatable/index.d.ts +1 -1
  63. package/lib/entities/partial/rated/activatable/range.d.ts +1 -1
  64. package/lib/entities/partial/rated/activatable/speed.d.ts +1 -1
  65. package/lib/entities/partial/rated/activatable/targetCategory.d.ts +1 -1
  66. package/lib/entities/partial/rated/improvementCost.d.ts +1 -1
  67. package/lib/entities/partial/rated/skillCheck.d.ts +1 -1
  68. package/lib/entities/partial/rated/skillCheck.js +5 -3
  69. package/lib/entities/partial/reader.d.ts +7 -1
  70. package/lib/entities/partial/reader.js +4 -0
  71. package/lib/entities/partial/responsiveText.d.ts +1 -1
  72. package/lib/entities/poison.d.ts +1 -1
  73. package/lib/entities/profession.d.ts +1 -1
  74. package/lib/entities/profession.js +19 -16
  75. package/lib/entities/race.d.ts +2 -0
  76. package/lib/entities/race.js +71 -52
  77. package/lib/entities/skill.d.ts +1 -1
  78. package/lib/entities/spell.d.ts +1 -1
  79. package/lib/helpers/getTypes.d.ts +1 -1
  80. package/lib/helpers/locale.d.ts +1 -1
  81. package/lib/helpers/translate.d.ts +1 -1
  82. package/lib/index.d.ts +128 -126
  83. package/lib/references/index.d.ts +1 -1
  84. package/lib/references/page.d.ts +1 -1
  85. package/lib/references/pageRange.d.ts +1 -1
  86. package/lib/tsconfig.tsbuildinfo +1 -1
  87. package/package.json +12 -12
@@ -60,9 +60,11 @@ const zipChunks = (chunks) => chunks
60
60
  .reduce((acc, chunk) => (acc === "" ? chunk : combineChunks(acc, chunk, (a, b) => `${a}, ${b}`)), "");
61
61
  const renderLevel = (formatAsPrerequisite, id, level) => level === undefined
62
62
  ? undefined
63
- : formatAsPrerequisite || id.kind === "Advantage" || id.kind === "Disadvantage" || level === 1
64
- ? romanize(level)
65
- : `I–${romanize(level)}`;
63
+ : Array.isArray(level)
64
+ ? `${romanize(level[0])}–${romanize(level[1])}`
65
+ : formatAsPrerequisite || id.kind === "Advantage" || id.kind === "Disadvantage" || level === 1
66
+ ? romanize(level)
67
+ : `I–${romanize(level)}`;
66
68
  /**
67
69
  * Converts a name chunk to a displayable string.
68
70
  */
@@ -83,7 +85,9 @@ const renderActivatableNameChunk = (translateMap, chunk) => {
83
85
  */
84
86
  export const renderActivatableNameComponentsWithoutLevel = (translateMap, components) => {
85
87
  const { levelPlacement, useParenthesis } = components.nameBuilderRules;
86
- const wrapParens = useParenthesis ? str => `(${str})` : identity;
88
+ const wrapParens = useParenthesis
89
+ ? str => (str.length > 0 ? `(${str})` : undefined)
90
+ : identity;
87
91
  const base = renderActivatableNameChunk(translateMap, components.base);
88
92
  const options = components.options === undefined
89
93
  ? undefined
@@ -125,6 +129,10 @@ export const combineNameComponents = (elements) => {
125
129
  */
126
130
  export const renderCombinedActivatableNameComponents = (translateMap, components, formatAsPrerequisite, join = list => list.join(", ")) => renderActivatableNameComponents(translateMap, {
127
131
  ...components,
132
+ nameBuilderRules: {
133
+ ...components.nameBuilderRules,
134
+ useParenthesis: true,
135
+ },
128
136
  options: join(components.options.map(chunk => renderActivatableNameChunk(translateMap, normalizeChunks(chunk)))),
129
137
  }, formatAsPrerequisite);
130
138
  /**
@@ -306,7 +314,10 @@ export const renderActivatableNameComponentsCombinedIfPossible = (translateMap,
306
314
  // ),
307
315
  // )(staticData)
308
316
  // }
309
- const renderOptions = (displayedInProfession, getResolvedSelectOptionById, id, options) => {
317
+ /**
318
+ * Renders the options of an activatable entry, combining them if necessary.
319
+ */
320
+ export const renderNameComponentsOptions = (displayedInProfession, getResolvedSelectOptionById, id, options) => {
310
321
  const arr = options?.map(optionId => {
311
322
  const optTranslations = getResolvedSelectOptionById(id, optionId)?.content.translations;
312
323
  return optTranslations === undefined
@@ -319,18 +330,22 @@ const renderOptions = (displayedInProfession, getResolvedSelectOptionById, id, o
319
330
  }
320
331
  return arr[0];
321
332
  };
333
+ /**
334
+ * Provides default values for name builder rules and ensures that all properties are present.
335
+ */
336
+ export const makeNameBuilderRulesWithDefaults = (input) => ({
337
+ levelPlacement: input?.levelPlacement ?? {
338
+ kind: "AfterOptions",
339
+ },
340
+ useParenthesis: input?.useParenthesis ?? true,
341
+ });
322
342
  /**
323
343
  * Gets the name components for an activatable entry.
324
344
  */
325
345
  export const getNameComponents = (translate, id, options, level, nameBuilderRules, translations, getBaseName, getResolvedSelectOptionById, displayedInProfession) => {
326
- const nameBuilderRulesWithDefaults = {
327
- levelPlacement: nameBuilderRules?.levelPlacement ?? {
328
- kind: "AfterOptions",
329
- },
330
- useParenthesis: nameBuilderRules?.useParenthesis ?? true,
331
- };
346
+ const nameBuilderRulesWithDefaults = makeNameBuilderRulesWithDefaults(nameBuilderRules);
332
347
  const renderedBase = mapObject(translations, getBaseName);
333
- const renderedOptions = renderOptions(displayedInProfession, getResolvedSelectOptionById, id, options);
348
+ const renderedOptions = renderNameComponentsOptions(displayedInProfession, getResolvedSelectOptionById, id, options);
334
349
  const isTradition = id.kind === "MagicalTradition" || id.kind === "BlessedTradition";
335
350
  const actualBase = isTradition ? translate("Tradition") : renderedBase;
336
351
  const actualOptions = isTradition
@@ -1,5 +1,5 @@
1
- import type { ResolvedSelectOption, ResolvedSelectOptionIdentifier } from "optolith-database-schema/cache";
2
- import type { ActivatableIdentifier, AdventurePointsValue } from "optolith-database-schema/gen";
1
+ import type { ResolvedSelectOption, ResolvedSelectOptionIdentifier } from "@optolith/database-schema/cache";
2
+ import type { ActivatableIdentifier, AdventurePointsValue } from "@optolith/database-schema/gen";
3
3
  import type { GetAllInstances } from "../../helpers/getTypes.js";
4
4
  import type { LocaleEnvironment } from "../../helpers/locale.js";
5
5
  import type { BaseActivatable, BaseActivatableTranslation } from "../activatable.js";
@@ -1,4 +1,4 @@
1
- import type { AnimalType_ID } from "optolith-database-schema/gen";
1
+ import type { AnimalType_ID } from "@optolith/database-schema/gen";
2
2
  import type { GetInstanceById } from "../../helpers/getTypes.js";
3
3
  import type { LocaleCompare } from "../../helpers/locale.js";
4
4
  import type { Translate, TranslateMap } from "../../helpers/translate.js";
@@ -7,7 +7,8 @@ export const renderAnimalTypesSection = (translate, translateMap, localeCompare,
7
7
  value: animalTypes.length === 0
8
8
  ? translate("All")
9
9
  : animalTypes
10
- .map(animalTypeId => translateMap(getInstanceById("AnimalType", animalTypeId)?.translations)?.name ?? MISSING_VALUE)
10
+ .map(animalTypeId => translateMap(getInstanceById("AnimalType", animalTypeId)?.translations)?.name ??
11
+ MISSING_VALUE)
11
12
  .toSorted(localeCompare)
12
13
  .join(", "),
13
14
  });
@@ -1,16 +1,16 @@
1
- import type { CommonnessRatedAdvantageDisadvantage } from "optolith-database-schema/gen";
1
+ import type { CommonnessRatedAdvantageDisadvantage } from "@optolith/database-schema/gen";
2
2
  import type { TranslationKeysWithoutParams } from "../../helpers/translate.js";
3
3
  import type { RawDefinitionListEntityDescriptionSectionItem } from "../../index.js";
4
4
  import type { StdReader } from "./reader.js";
5
5
  /**
6
6
  * Render the names of either commonness-rated advantages or commonness-rated disadvantages.
7
7
  */
8
- export declare const renderCommonnessRatedAdvantagesOrDisadvantages: <E extends "Advantage" | "Disadvantage">(entity: E, items: CommonnessRatedAdvantageDisadvantage<string>[] | undefined) => StdReader<string, "t" | "tm" | "lc" | "ibi", E>;
8
+ export declare const renderCommonnessRatedAdvantagesOrDisadvantages: <E extends "Advantage" | "Disadvantage", T extends string | undefined>(entity: E, items: CommonnessRatedAdvantageDisadvantage<string>[] | undefined, emptyString: T) => StdReader<string | T, "tm" | "lc" | "ibi" | "rso", E>;
9
9
  /**
10
10
  * Render the names of commonness-rated advantages and disadvantages together.
11
11
  */
12
- export declare const renderCommonnessRatedAdvantagesAndDisadvantages: (advantages: CommonnessRatedAdvantageDisadvantage<string>[] | undefined, disadvantages: CommonnessRatedAdvantageDisadvantage<string>[] | undefined) => StdReader<string, "t" | "tm" | "lc" | "ibi", "Advantage" | "Disadvantage">;
12
+ export declare const renderCommonnessRatedAdvantagesAndDisadvantages: <T extends string | undefined>(advantages: CommonnessRatedAdvantageDisadvantage<string>[] | undefined, disadvantages: CommonnessRatedAdvantageDisadvantage<string>[] | undefined, emptyString: T) => StdReader<string | T, "tm" | "lc" | "ibi" | "rso", "Advantage" | "Disadvantage">;
13
13
  /**
14
14
  * Render a value with a possible translation, falling back to explicity rendering the value if no translation is available.
15
15
  */
16
- export declare const renderValueWithPossibleTranslation: <T>(label: TranslationKeysWithoutParams, value: T, renderValue: (value: T) => string, valueTranslation: string | undefined) => StdReader<RawDefinitionListEntityDescriptionSectionItem, "t">;
16
+ export declare const renderValueWithPossibleTranslation: <T>(label: TranslationKeysWithoutParams, value: T, renderValue: (value: T) => string, _valueTranslation: string | undefined) => StdReader<RawDefinitionListEntityDescriptionSectionItem, "t">;
@@ -1,36 +1,79 @@
1
1
  import { isNotEmpty } from "@elyukai/utils/array/nonEmpty";
2
2
  import { mapNullable } from "@elyukai/utils/nullable";
3
3
  import { Reader } from "@elyukai/utils/reader";
4
+ import { assertExhaustive } from "@elyukai/utils/typeSafety";
4
5
  import { ensureNonEmpty } from "@optolith/helpers/array";
6
+ import { Case } from "tsondb/schema/gen";
7
+ import { makeNameBuilderRulesWithDefaults, renderCombinedActivatableNameComponents, renderNameComponentsOptions, } from "./activatableNameChunks.js";
5
8
  import { attributedCustomName } from "./markdown.js";
6
- import { parensIf } from "./rated/activatable/parensIf.js";
7
9
  import { MISSING_VALUE } from "./unknown.js";
8
- const renderCommonnessRatedAdvantageOrDisadvantageName = (translateMap, getInstanceById, entity, item) => {
10
+ const convertCommonnessRatedAdvantageOrDisadvantageLevel = (level) => {
11
+ switch (level.kind) {
12
+ case "Range":
13
+ return [level.Range.min, level.Range.max];
14
+ case "Constant":
15
+ return level.Constant;
16
+ default:
17
+ return assertExhaustive(level);
18
+ }
19
+ };
20
+ const makeActivatableIdentifierForCommonnessRatedAdvantageOrDisadvantage = (entity, id) => {
21
+ switch (entity) {
22
+ case "Advantage":
23
+ return Case("Advantage", id);
24
+ case "Disadvantage":
25
+ return Case("Disadvantage", id);
26
+ default:
27
+ return assertExhaustive(entity);
28
+ }
29
+ };
30
+ const renderCommonnessRatedAdvantageOrDisadvantageName = (translateMap, getInstanceById, getResolvedSelectOptionById, entity, item) => {
9
31
  const customTranslation = translateMap(item.translations);
10
- return (attributedCustomName(translateMap, getInstanceById, entity, translation => {
11
- const name = translation.name_in_library ?? translation.name;
12
- return customTranslation?.options !== undefined && name.endsWith(")")
13
- ? `${name.slice(0, -1)}; ${customTranslation.options})`
14
- : name + parensIf(customTranslation?.options);
32
+ return (attributedCustomName(translateMap, getInstanceById, entity, (translation, instance) => {
33
+ if (customTranslation?.full !== undefined) {
34
+ return customTranslation.full;
35
+ }
36
+ const id = makeActivatableIdentifierForCommonnessRatedAdvantageOrDisadvantage(entity, item.id);
37
+ const level = item.level === undefined
38
+ ? undefined
39
+ : convertCommonnessRatedAdvantageOrDisadvantageLevel(item.level);
40
+ const options = customTranslation?.options === undefined
41
+ ? (item.options?.map(option => renderNameComponentsOptions(false, getResolvedSelectOptionById, id, [option]) ??
42
+ MISSING_VALUE) ?? [])
43
+ : [customTranslation.options];
44
+ const name = translation.name_in_library !== undefined && options.length === 0
45
+ ? translation.name_in_library
46
+ : translation.name;
47
+ return renderCombinedActivatableNameComponents(translateMap, {
48
+ id,
49
+ base: name,
50
+ level,
51
+ nameBuilderRules: makeNameBuilderRulesWithDefaults(instance.nameBuilderRules),
52
+ options: customTranslation?.options === undefined
53
+ ? (item.options?.map(option => renderNameComponentsOptions(false, getResolvedSelectOptionById, id, [
54
+ option,
55
+ ]) ?? MISSING_VALUE) ?? [])
56
+ : [customTranslation.options],
57
+ }, false);
15
58
  }, entity, item.id) ?? MISSING_VALUE);
16
59
  };
17
60
  /**
18
61
  * Render the names of either commonness-rated advantages or commonness-rated disadvantages.
19
62
  */
20
- export const renderCommonnessRatedAdvantagesOrDisadvantages = (entity, items) => Reader.asks(({ translate, translateMap, getInstanceById, localeCompare }) => items === undefined || !isNotEmpty(items)
21
- ? translate("none")
63
+ export const renderCommonnessRatedAdvantagesOrDisadvantages = (entity, items, emptyString) => Reader.asks(({ translateMap, getInstanceById, getResolvedSelectOptionById, localeCompare }) => items === undefined || !isNotEmpty(items)
64
+ ? emptyString
22
65
  : items
23
- .map(item => renderCommonnessRatedAdvantageOrDisadvantageName(translateMap, getInstanceById, entity, item))
66
+ .map(item => renderCommonnessRatedAdvantageOrDisadvantageName(translateMap, getInstanceById, getResolvedSelectOptionById, entity, item))
24
67
  .toSorted(localeCompare)
25
68
  .join(", "));
26
69
  /**
27
70
  * Render the names of commonness-rated advantages and disadvantages together.
28
71
  */
29
- export const renderCommonnessRatedAdvantagesAndDisadvantages = (advantages, disadvantages) => Reader.asks(({ translate, translateMap, getInstanceById, localeCompare }) => mapNullable(ensureNonEmpty([["Advantage", advantages], ["Disadvantage", disadvantages]].flatMap(([entity, items]) => items?.map(item => renderCommonnessRatedAdvantageOrDisadvantageName(translateMap, getInstanceById, entity, item)) ?? [])), renderedItems => renderedItems.toSorted(localeCompare).join(", ")) ?? translate("none"));
72
+ export const renderCommonnessRatedAdvantagesAndDisadvantages = (advantages, disadvantages, emptyString) => Reader.asks(({ translateMap, getInstanceById, getResolvedSelectOptionById, localeCompare }) => mapNullable(ensureNonEmpty([["Advantage", advantages], ["Disadvantage", disadvantages]].flatMap(([entity, items]) => items?.map(item => renderCommonnessRatedAdvantageOrDisadvantageName(translateMap, getInstanceById, getResolvedSelectOptionById, entity, item)) ?? [])), renderedItems => renderedItems.toSorted(localeCompare).join(", ")) ?? emptyString);
30
73
  /**
31
74
  * Render a value with a possible translation, falling back to explicity rendering the value if no translation is available.
32
75
  */
33
- export const renderValueWithPossibleTranslation = (label, value, renderValue, valueTranslation) => Reader.asks(({ translate }) => ({
76
+ export const renderValueWithPossibleTranslation = (label, value, renderValue, _valueTranslation) => Reader.asks(({ translate }) => ({
34
77
  label: translate(label),
35
- value: valueTranslation ?? renderValue(value),
78
+ value: /* valueTranslation ?? */ renderValue(value),
36
79
  }));
@@ -1,4 +1,4 @@
1
- import type { Dice } from "optolith-database-schema/gen";
1
+ import type { Dice } from "@optolith/database-schema/gen";
2
2
  import type { Translate } from "../../helpers/translate.js";
3
3
  /**
4
4
  * Renders a dice expression like "2D6" into a localized string.
@@ -1,4 +1,4 @@
1
- import type { ImprovementCost, RatedIdentifier, SkillWithEnhancementsIdentifier } from "optolith-database-schema/gen";
1
+ import type { ImprovementCost, RatedIdentifier, SkillWithEnhancementsIdentifier } from "@optolith/database-schema/gen";
2
2
  import type { RawEntityDescriptionSection } from "../../index.js";
3
3
  import { type StdReader } from "./reader.js";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { AlternativeName, LaboratoryLevel, Resistance } from "optolith-database-schema/gen";
1
+ import type { AlternativeName, LaboratoryLevel, Resistance } from "@optolith/database-schema/gen";
2
2
  import type { GetInstanceById } from "../../helpers/getTypes.js";
3
3
  import type { LocaleMap, Translate, TranslateMap } from "../../helpers/translate.js";
4
4
  import type { IdMap } from "../../index.js";
@@ -1,4 +1,4 @@
1
- import type { MapStyle, ResponsiveTextOptional } from "optolith-database-schema/gen";
1
+ import type { MapStyle, ResponsiveTextOptional } from "@optolith/database-schema/gen";
2
2
  import type { LocaleMap, Translate, TranslateMap } from "../../helpers/translate.js";
3
3
  import { type StdReader } from "./reader.js";
4
4
  /**
@@ -9,7 +9,7 @@ import { MISSING_VALUE } from "./unknown.js";
9
9
  export const renderMap = (translate, translateMap, map, getValue, surroundValues = values => values, getLabel, getListPrefix, getListSuffix, getReplacement, ...moreToAppend) => {
10
10
  const translation = translateMap(map.translations);
11
11
  const replacement = mapNullable(translation, t => getReplacement(t));
12
- if (replacement !== undefined) {
12
+ if (isNotNullish(replacement)) {
13
13
  return replacement;
14
14
  }
15
15
  if (map.style?.kind === "Verbose") {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Some helpers to create Markdown content.
3
3
  */
4
- import type { EntityMap } from "optolith-database-schema/gen";
4
+ import type { EntityMap } from "@optolith/database-schema/gen";
5
5
  import { type IdArgsVariant } from "tsondb/schema/gen";
6
6
  import type { GetInstanceById } from "../../helpers/getTypes.js";
7
7
  import type { LocaleMap, TranslateMap } from "../../helpers/translate.js";
@@ -32,7 +32,7 @@ export declare const customName: <E extends { [K in keyof EntityMap]: EntityMap[
32
32
  */
33
33
  export declare const attributedCustomName: <E extends { [K in keyof EntityMap]: EntityMap[K] extends {
34
34
  translations: LocaleMap<object>;
35
- } ? K : never; }[keyof EntityMap]>(translateMap: TranslateMap, getInstanceById: GetInstanceById<E>, context: string, fn: (translation: EntityMap[E]["translations"][string]) => string, ...args: IdArgsVariant<EntityMap, E>) => string | undefined;
35
+ } ? K : never; }[keyof EntityMap]>(translateMap: TranslateMap, getInstanceById: GetInstanceById<E>, context: string, fn: (translation: EntityMap[E]["translations"][string], instance: EntityMap[E]) => string, ...args: IdArgsVariant<EntityMap, E>) => string | undefined;
36
36
  /**
37
37
  * Renders the name of an instance in an attributed string.
38
38
  */
@@ -34,7 +34,10 @@ export const customName = (translateMap, getInstanceById, fn, ...args) => mapNul
34
34
  */
35
35
  export const attributedCustomName = (translateMap, getInstanceById, context, fn, ...args) => {
36
36
  const id = normalizedIdArgs(args);
37
- return mapNullable(translateMap(getInstanceById(...args)?.translations), translation => attributedInstance(fn(translation), id.entityName, id.id, { context: `"${context}"` }));
37
+ const instance = getInstanceById(...args);
38
+ return mapNullable(translateMap(instance?.translations), translation => attributedInstance(
39
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- instance must be non-nullish if translation is non-nullish
40
+ fn(translation, instance), id.entityName, id.id, { context: `"${context}"` }));
38
41
  };
39
42
  /**
40
43
  * Renders the name of an instance in an attributed string.
@@ -1,4 +1,4 @@
1
- import type { MathOperation } from "optolith-database-schema/gen";
1
+ import type { MathOperation } from "@optolith/database-schema/gen";
2
2
  type UnaryFormatter = (value: string | number) => string;
3
3
  type BinaryFormatter = (left: string | number, right: string | number) => string;
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { DisplayOption } from "optolith-database-schema/gen";
1
+ import type { DisplayOption } from "@optolith/database-schema/gen";
2
2
  import type { TranslateMap } from "../../../helpers/translate.js";
3
3
  import type { PrerequisitePart } from "./part.js";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { ActivatableIdentifier, AdvantageDisadvantagePrerequisites, AnimistPowerPrerequisites, ArcaneTraditionPrerequisites, DerivedCharacteristicPrerequisites, EnhancementPrerequisites, GeneralPrerequisites, GeodeRitualPrerequisites, InfluencePrerequisites, LanguagePrerequisites, LiturgyPrerequisites, PersonalityTraitPrerequisites, PlainGeneralPrerequisites, ProfessionPrerequisites, PublicationPrerequisites, RatedIdentifier, SpellworkPrerequisites } from "optolith-database-schema/gen";
1
+ import type { ActivatableIdentifier, AdvantageDisadvantagePrerequisites, AnimistPowerPrerequisites, ArcaneTraditionPrerequisites, DerivedCharacteristicPrerequisites, EnhancementPrerequisites, GeneralPrerequisites, GeodeRitualPrerequisites, InfluencePrerequisites, LanguagePrerequisites, LiturgyPrerequisites, PersonalityTraitPrerequisites, PlainGeneralPrerequisites, ProfessionPrerequisites, PublicationPrerequisites, RatedIdentifier, SpellworkPrerequisites } from "@optolith/database-schema/gen";
2
2
  import type { GetAllChildInstancesForParent, GetInstanceById } from "../../../helpers/getTypes.js";
3
3
  import type { LocaleEnvironment } from "../../../helpers/locale.js";
4
4
  import type { GetResolvedSelectOptionById } from "./single/activatable.js";
@@ -1,4 +1,4 @@
1
- import type { SentenceType } from "optolith-database-schema/gen";
1
+ import type { SentenceType } from "@optolith/database-schema/gen";
2
2
  import type { LocaleCompare } from "../../../helpers/locale.js";
3
3
  import type { Translate, TranslateMap } from "../../../helpers/translate.js";
4
4
  import { type ActivatableNameComponents } from "../activatableNameChunks.js";
@@ -1,4 +1,4 @@
1
- import type { ActivatableIdentifier, AdvantageDisadvantagePrerequisiteGroup, AnimistPowerPrerequisiteGroup, ArcaneTraditionPrerequisiteGroup, DerivedCharacteristicPrerequisiteGroup, EnhancementPrerequisiteGroup, GeneralPrerequisiteGroup, GeodeRitualPrerequisiteGroup, InfluencePrerequisiteGroup, LanguagePrerequisiteGroup, LiturgyPrerequisiteGroup, PersonalityTraitPrerequisiteGroup, PreconditionGroup, ProfessionPrerequisiteGroup, PublicationPrerequisiteGroup, RatedIdentifier, SpellworkPrerequisiteGroup } from "optolith-database-schema/gen";
1
+ import type { ActivatableIdentifier, AdvantageDisadvantagePrerequisiteGroup, AnimistPowerPrerequisiteGroup, ArcaneTraditionPrerequisiteGroup, DerivedCharacteristicPrerequisiteGroup, EnhancementPrerequisiteGroup, GeneralPrerequisiteGroup, GeodeRitualPrerequisiteGroup, InfluencePrerequisiteGroup, LanguagePrerequisiteGroup, LiturgyPrerequisiteGroup, PersonalityTraitPrerequisiteGroup, PreconditionGroup, ProfessionPrerequisiteGroup, PublicationPrerequisiteGroup, RatedIdentifier, SpellworkPrerequisiteGroup } from "@optolith/database-schema/gen";
2
2
  import type { GetAllChildInstancesForParent, GetInstanceById } from "../../../helpers/getTypes.js";
3
3
  import type { LocaleEnvironment } from "../../../helpers/locale.js";
4
4
  import type { PrerequisitePart } from "./part.js";
@@ -1,5 +1,5 @@
1
- import type { ResolvedSelectOption, ResolvedSelectOptionIdentifier } from "optolith-database-schema/cache";
2
- import type { ActivatableIdentifier, ActivatablePrerequisite, RequirableSelectOptionIdentifier } from "optolith-database-schema/gen";
1
+ import type { ResolvedSelectOption, ResolvedSelectOptionIdentifier } from "@optolith/database-schema/cache";
2
+ import type { ActivatableIdentifier, ActivatablePrerequisite, RequirableSelectOptionIdentifier } from "@optolith/database-schema/gen";
3
3
  import type { GetInstanceById } from "../../../../helpers/getTypes.js";
4
4
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
5
5
  import type { Translate } from "../../../../helpers/translate.js";
@@ -1,4 +1,4 @@
1
- import type { AnimistPowerPrerequisite } from "optolith-database-schema/gen";
1
+ import type { AnimistPowerPrerequisite } from "@optolith/database-schema/gen";
2
2
  import { type GetInstanceById } from "../../../../helpers/getTypes.js";
3
3
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
4
4
  import type { PrerequisitePart } from "../part.js";
@@ -1,4 +1,4 @@
1
- import type { BlessedTraditionPrerequisite } from "optolith-database-schema/gen";
1
+ import type { BlessedTraditionPrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
3
3
  import type { PrerequisitePart } from "../part.js";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { CulturePrerequisite } from "optolith-database-schema/gen";
1
+ import type { CulturePrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { GetInstanceById } from "../../../../helpers/getTypes.js";
3
3
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
4
4
  import type { PrerequisitePart } from "../part.js";
@@ -1,4 +1,4 @@
1
- import type { EnhancementPrerequisite } from "optolith-database-schema/gen";
1
+ import type { EnhancementPrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { GetInstanceById } from "../../../../helpers/getTypes.js";
3
3
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
4
4
  import type { PrerequisitePart } from "../part.js";
@@ -1,4 +1,4 @@
1
- import type { InfluencePrerequisite } from "optolith-database-schema/gen";
1
+ import type { InfluencePrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { GetInstanceById } from "../../../../helpers/getTypes.js";
3
3
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
4
4
  import type { PrerequisitePart } from "../part.js";
@@ -1,4 +1,4 @@
1
- import type { MagicalTraditionPrerequisite } from "optolith-database-schema/gen";
1
+ import type { MagicalTraditionPrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
3
3
  import type { PrerequisitePart } from "../part.js";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { PactPrerequisite } from "optolith-database-schema/gen";
1
+ import type { PactPrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { GetInstanceById } from "../../../../helpers/getTypes.js";
3
3
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
4
4
  import type { PrerequisitePart } from "../part.js";
@@ -1,4 +1,4 @@
1
- import type { PersonalityTraitPrerequisite } from "optolith-database-schema/gen";
1
+ import type { PersonalityTraitPrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { GetInstanceById } from "../../../../helpers/getTypes.js";
3
3
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
4
4
  import type { PrerequisitePart } from "../part.js";
@@ -1,4 +1,4 @@
1
- import type { PrimaryAttributePrerequisite } from "optolith-database-schema/gen";
1
+ import type { PrimaryAttributePrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
3
3
  import type { PrerequisitePart } from "../part.js";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { ProfessionPrerequisite } from "optolith-database-schema/gen";
1
+ import type { ProfessionPrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { GetAllChildInstancesForParent } from "../../../../helpers/getTypes.js";
3
3
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
4
4
  import type { PrerequisitePart } from "../part.js";
@@ -1,4 +1,4 @@
1
- import type { PublicationPrerequisite } from "optolith-database-schema/gen";
1
+ import type { PublicationPrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { GetInstanceById } from "../../../../helpers/getTypes.js";
3
3
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
4
4
  import type { PrerequisitePart } from "../part.js";
@@ -1,4 +1,4 @@
1
- import type { RacePrerequisite } from "optolith-database-schema/gen";
1
+ import type { RacePrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { GetInstanceById } from "../../../../helpers/getTypes.js";
3
3
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
4
4
  import type { PrerequisitePart } from "../part.js";
@@ -1,4 +1,4 @@
1
- import type { RatedPrerequisite } from "optolith-database-schema/gen";
1
+ import type { RatedPrerequisite } from "@optolith/database-schema/gen";
2
2
  import { type GetInstanceById } from "../../../../helpers/getTypes.js";
3
3
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
4
4
  import type { PrerequisitePart } from "../part.js";
@@ -1,4 +1,4 @@
1
- import type { RatedMinimumNumberPrerequisite } from "optolith-database-schema/gen";
1
+ import type { RatedMinimumNumberPrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { GetInstanceById } from "../../../../helpers/getTypes.js";
3
3
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
4
4
  import type { PrerequisitePart } from "../part.js";
@@ -1,4 +1,4 @@
1
- import type { RatedSumPrerequisite } from "optolith-database-schema/gen";
1
+ import type { RatedSumPrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { GetInstanceById } from "../../../../helpers/getTypes.js";
3
3
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
4
4
  import type { PrerequisitePart } from "../part.js";
@@ -1,4 +1,4 @@
1
- import type { RulePrerequisite } from "optolith-database-schema/gen";
1
+ import type { RulePrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
3
3
  import type { PrerequisitePart } from "../part.js";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { SexPrerequisite } from "optolith-database-schema/gen";
1
+ import type { SexPrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { Translate } from "../../../../helpers/translate.js";
3
3
  import type { PrerequisitePart } from "../part.js";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { SexualCharacteristicPrerequisite } from "optolith-database-schema/gen";
1
+ import type { SexualCharacteristicPrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
3
3
  import type { PrerequisitePart } from "../part.js";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { SocialStatusPrerequisite } from "optolith-database-schema/gen";
1
+ import type { SocialStatusPrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { GetInstanceById } from "../../../../helpers/getTypes.js";
3
3
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
4
4
  import type { PrerequisitePart } from "../part.js";
@@ -1,4 +1,4 @@
1
- import type { StatePrerequisite } from "optolith-database-schema/gen";
1
+ import type { StatePrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { GetInstanceById } from "../../../../helpers/getTypes.js";
3
3
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
4
4
  import type { PrerequisitePart } from "../part.js";
@@ -1,4 +1,4 @@
1
- import type { TextPrerequisite } from "optolith-database-schema/gen";
1
+ import type { TextPrerequisite } from "@optolith/database-schema/gen";
2
2
  import type { LocaleEnvironment } from "../../../../helpers/locale.js";
3
3
  import type { PrerequisitePart } from "../part.js";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { Profession_ID, ProfessionPackage } from "optolith-database-schema/gen";
1
+ import type { Profession_ID, ProfessionPackage } from "@optolith/database-schema/gen";
2
2
  import type { GetAllChildInstancesForParent, GetAllInstances } from "../../helpers/getTypes.js";
3
3
  import type { TranslateMap } from "../../helpers/translate.js";
4
4
  import type { IdMap } from "../../index.js";
@@ -9,11 +9,9 @@ export const getBaseProfessionPackageForCurriculum = (getAllInstances, getChildI
9
9
  if (baseProfession === undefined) {
10
10
  return undefined;
11
11
  }
12
- return reduceWhile(getChildInstancesForInstanceId("ProfessionVersion", baseProfession.id), (_acc, version) => getChildInstancesForInstanceId("ProfessionPackage", version.id).find(professionPackage => professionPackage.content.experience_level ===
13
- idMap.ExperienceLevel.Experienced), isNotNullish, undefined);
12
+ return reduceWhile(getChildInstancesForInstanceId("ProfessionVersion", baseProfession.id), (_acc, version) => getChildInstancesForInstanceId("ProfessionPackage", version.id).find(professionPackage => professionPackage.content.experience_level === idMap.ExperienceLevel.Experienced), isNotNullish, undefined);
14
13
  };
15
14
  /**
16
15
  * Gets the name of a profession, regardless of the profession version.
17
16
  */
18
- export const getProfessionName = (translateMap, getChildInstancesForInstanceId, professionId) => translateMap(getChildInstancesForInstanceId("ProfessionVersion", professionId)[0]
19
- ?.content.translations)?.name.default;
17
+ export const getProfessionName = (translateMap, getChildInstancesForInstanceId, professionId) => translateMap(getChildInstancesForInstanceId("ProfessionVersion", professionId)[0]?.content.translations)?.name.default;
@@ -1,4 +1,4 @@
1
- import type { CastingTime, FastCastingTime, FastSkillNonModifiableCastingTime, SlowCastingTime, SlowSkillNonModifiableCastingTime } from "optolith-database-schema/gen";
1
+ import type { CastingTime, FastCastingTime, FastSkillNonModifiableCastingTime, SlowCastingTime, SlowSkillNonModifiableCastingTime } from "@optolith/database-schema/gen";
2
2
  import { type StdReader } from "../../reader.js";
3
3
  /**
4
4
  * Renders the text for a non-modifiable casting time of a fast activatable skill.
@@ -1,4 +1,4 @@
1
- import type { CheckResultBasedModifier, CheckResultValue } from "optolith-database-schema/gen";
1
+ import type { CheckResultBasedModifier, CheckResultValue } from "@optolith/database-schema/gen";
2
2
  import { type StdReader } from "../../reader.js";
3
3
  interface CheckResultBased {
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { Reader } from "@elyukai/utils/reader";
2
- import type { CheckResultBasedModifier, DurationUnitValue, ElvenMagicalSongPermanentCost, FirstPersonMagicalMelodyCost, NonModifiableOneTimeCostPerCountable, NonModifiableSustainedCost, OneTimeCost, OneTimeCostMap, ResponsiveText, ResponsiveTextOptional, ResponsiveTextReplace, SkillModificationLevel_ID, SustainedCost } from "optolith-database-schema/gen";
2
+ import type { CheckResultBasedModifier, DurationUnitValue, ElvenMagicalSongPermanentCost, FirstPersonMagicalMelodyCost, NonModifiableOneTimeCostPerCountable, NonModifiableSustainedCost, OneTimeCost, OneTimeCostMap, ResponsiveText, ResponsiveTextOptional, ResponsiveTextReplace, SkillModificationLevel_ID, SustainedCost } from "@optolith/database-schema/gen";
3
3
  import { type LocaleMap } from "../../../../helpers/translate.js";
4
4
  import { type StdEnv, type StdReader } from "../../reader.js";
5
5
  /**
@@ -1,4 +1,4 @@
1
- import type { CastingTimeDuringLovemaking, CheckResultBasedDuration, DurationForSustained, FixedDuration, Immediate, MusicDuration, PermanentDuration, ResponsiveText } from "optolith-database-schema/gen";
1
+ import type { CastingTimeDuringLovemaking, CheckResultBasedDuration, DurationForSustained, FixedDuration, Immediate, MusicDuration, PermanentDuration, ResponsiveText } from "@optolith/database-schema/gen";
2
2
  import type { LocaleMap } from "../../../../helpers/translate.js";
3
3
  import { type StdReader } from "../../reader.js";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { ActivatableSkillEffect } from "optolith-database-schema/gen";
1
+ import type { ActivatableSkillEffect } from "@optolith/database-schema/gen";
2
2
  import type { RawDefinitionListEntityDescriptionSectionItem } from "../../../../index.js";
3
3
  import { type StdReader } from "../../reader.js";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { FastOneTimePerformanceParameters, FastSustainedPerformanceParameters, OneTimePerformanceParameters, ResponsiveTextOptional, SlowOneTimePerformanceParameters, SlowSustainedPerformanceParameters } from "optolith-database-schema/gen";
1
+ import type { FastOneTimePerformanceParameters, FastSustainedPerformanceParameters, OneTimePerformanceParameters, ResponsiveTextOptional, SlowOneTimePerformanceParameters, SlowSustainedPerformanceParameters } from "@optolith/database-schema/gen";
2
2
  import type { RawDefinitionListEntityDescriptionSectionItem } from "../../../../index.js";
3
3
  import type { StdReader } from "../../reader.js";
4
4
  type RenderedPerformanceParameters = {
@@ -1,4 +1,4 @@
1
- import type { CheckResultBasedRange, FixedRange, Range, RangeValue } from "optolith-database-schema/gen";
1
+ import type { CheckResultBasedRange, FixedRange, Range, RangeValue } from "@optolith/database-schema/gen";
2
2
  import { type StdReader } from "../../reader.js";
3
3
  /**
4
4
  * Returns the text for the non-modifiable range of an activatable skill.
@@ -1,4 +1,4 @@
1
- import type { FastSkillModificationLevelConfig, SkillModificationLevel, SlowSkillModificationLevelConfig } from "optolith-database-schema/gen";
1
+ import type { FastSkillModificationLevelConfig, SkillModificationLevel, SlowSkillModificationLevelConfig } from "@optolith/database-schema/gen";
2
2
  /**
3
3
  * The speed of an activatable skill.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { AffectedTargetCategories } from "optolith-database-schema/gen";
1
+ import type { AffectedTargetCategories } from "@optolith/database-schema/gen";
2
2
  import { type RawDefinitionListEntityDescriptionSectionItem } from "../../../../index.js";
3
3
  import { type StdReader } from "../../reader.js";
4
4
  /**