@optolith/entity-descriptions 0.14.0 → 0.15.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.
- package/CHANGELOG.md +10 -0
- package/lib/creator.d.ts +4 -11
- package/lib/creator.js +57 -1
- package/lib/entities/activatable.d.ts +5 -2
- package/lib/entities/activatable.js +7 -1
- package/lib/entities/alternativeRule.d.ts +1 -1
- package/lib/entities/attribute.d.ts +1 -3
- package/lib/entities/combatTechnique.d.ts +2 -2
- package/lib/entities/condition.d.ts +2 -6
- package/lib/entities/culture.d.ts +2 -1
- package/lib/entities/curriculum.d.ts +1 -1
- package/lib/entities/derivedCharacteristic.d.ts +1 -1
- package/lib/entities/disease.d.ts +1 -1
- package/lib/entities/elixir.d.ts +1 -1
- package/lib/entities/equipment.d.ts +4 -6
- package/lib/entities/equipment.js +517 -213
- package/lib/entities/equipmentPackage.d.ts +1 -1
- package/lib/entities/experienceLevel.d.ts +1 -3
- package/lib/entities/focusRule.d.ts +1 -1
- package/lib/entities/influence.d.ts +1 -1
- package/lib/entities/liturgicalChant.d.ts +3 -3
- package/lib/entities/optionalRule.d.ts +1 -3
- package/lib/entities/partial/units/simple.d.ts +55 -0
- package/lib/entities/partial/units/simple.js +56 -0
- package/lib/entities/personalityTrait.d.ts +1 -1
- package/lib/entities/poison.d.ts +1 -1
- package/lib/entities/profession.d.ts +2 -1
- package/lib/entities/race.d.ts +2 -2
- package/lib/entities/sexPractice.d.ts +1 -3
- package/lib/entities/skill.d.ts +1 -1
- package/lib/entities/spell.d.ts +17 -16
- package/lib/entities/state.d.ts +1 -3
- package/lib/entities/tradeSecret.d.ts +4 -0
- package/lib/entities/tradeSecret.js +77 -0
- package/lib/env.d.ts +9 -2
- package/lib/helpers/locale.d.ts +4 -0
- package/lib/index.d.ts +320 -293
- package/lib/index.js +9 -1
- package/lib/references/index.d.ts +2 -3
- package/lib/references/index.js +11 -16
- package/lib/references/page.d.ts +4 -2
- package/lib/references/page.js +6 -4
- package/lib/references/pageRange.d.ts +3 -3
- package/lib/references/pageRange.js +6 -4
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import { getFocusRuleEntityDescription } from "./entities/focusRule.js";
|
|
|
15
15
|
import { getInfluenceEntityDescription } from "./entities/influence.js";
|
|
16
16
|
import { getBlessingEntityDescription, getCeremonyEntityDescription, getLiturgicalChantEntityDescription, } from "./entities/liturgicalChant.js";
|
|
17
17
|
import { getOptionalRuleEntityDescription } from "./entities/optionalRule.js";
|
|
18
|
+
import { ResponsiveTextSize } from "./entities/partial/responsiveText.js";
|
|
18
19
|
import { getPersonalityTraitEntityDescription } from "./entities/personalityTrait.js";
|
|
19
20
|
import { getPoisonEntityDescription } from "./entities/poison.js";
|
|
20
21
|
import { getProfessionVersionEntityDescription } from "./entities/profession.js";
|
|
@@ -23,6 +24,7 @@ import { getSexPracticeEntityDescription } from "./entities/sexPractice.js";
|
|
|
23
24
|
import { getSkillEntityDescription } from "./entities/skill.js";
|
|
24
25
|
import { getAnimistPowerEntityDescription, getBannzeichenEntityDescription, getCantripEntityDescription, getCurseEntityDescription, getDominationRitualEntityDescription, getElvenMagicalSongEntityDescription, getFamiliarsTrickEntityDescription, getGeodeRitualEntityDescription, getGoblinRitualEntityDescription, getJesterTrickEntityDescription, getMagicalDanceEntityDescription, getMagicalMelodyEntityDescription, getMagicalRuneEntityDescription, getRitualEntityDescription, getSpellEntityDescription, getZibiljaRitualEntityDescription, } from "./entities/spell.js";
|
|
25
26
|
import { getStateEntityDescription } from "./entities/state.js";
|
|
27
|
+
import { getTradeSecretEntityDescription } from "./entities/tradeSecret.js";
|
|
26
28
|
const registeredEntityDescriptionCreators = {
|
|
27
29
|
// rules
|
|
28
30
|
// CoreRule: getCoreRuleEntityDescription,
|
|
@@ -124,6 +126,8 @@ const registeredEntityDescriptionCreators = {
|
|
|
124
126
|
Vision: getActivatableEntityDescription,
|
|
125
127
|
WandEnchantment: getActivatableEntityDescription,
|
|
126
128
|
WeaponEnchantment: getActivatableEntityDescription,
|
|
129
|
+
// auxiliary special ability
|
|
130
|
+
TradeSecret: getTradeSecretEntityDescription,
|
|
127
131
|
// equipment
|
|
128
132
|
Ammunition: getEquipmentEntityDescription,
|
|
129
133
|
Animal: getEquipmentEntityDescription,
|
|
@@ -177,7 +181,7 @@ export const supportedEntities = Object.keys(registeredEntityDescriptionCreators
|
|
|
177
181
|
* Get a JSON representation of the rules text for an entry in the database.
|
|
178
182
|
*/
|
|
179
183
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- false positive
|
|
180
|
-
export const getEntityDescription = (database, localeEnv, idMap, getResolvedSelectOptionById, getAllResolvedSelectOptions, getAllResolvedNewSkillApplications, getAllResolvedSkillUses, entityName, instanceId, publicationOptions) => {
|
|
184
|
+
export const getEntityDescription = (database, localeEnv, idMap, getResolvedSelectOptionById, getAllResolvedSelectOptions, getAllResolvedNewSkillApplications, getAllResolvedSkillUses, entityName, instanceId, publicationOptions, responsiveTextSize = "Full") => {
|
|
181
185
|
const creator = registeredEntityDescriptionCreators[entityName];
|
|
182
186
|
const instance = database.getInstanceOfEntityById(entityName, instanceId);
|
|
183
187
|
if (!instance) {
|
|
@@ -193,5 +197,9 @@ export const getEntityDescription = (database, localeEnv, idMap, getResolvedSele
|
|
|
193
197
|
getAllResolvedNewSkillApplications,
|
|
194
198
|
getAllResolvedSkillUses,
|
|
195
199
|
idMap,
|
|
200
|
+
...localeEnv,
|
|
201
|
+
localeJoin: localeEnv.join,
|
|
202
|
+
localeCompare: localeEnv.compare,
|
|
203
|
+
responsiveTextSize: ResponsiveTextSize[responsiveTextSize],
|
|
196
204
|
}, localeEnv, { entity: entityName, content: instance, id: instanceId }, { publications: publicationOptions });
|
|
197
205
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { PublicationRefs } from "@optolith/database-schema/gen";
|
|
2
|
-
import type {
|
|
3
|
-
import type { LocaleEnvironment } from "../helpers/locale.js";
|
|
2
|
+
import type { StdReader } from "../env.js";
|
|
4
3
|
import { type PublicationOptions } from "./publicationOptions.js";
|
|
5
4
|
/**
|
|
6
5
|
* Returns the translation of the references.
|
|
7
6
|
*/
|
|
8
|
-
export declare const getReferencesTranslation: (
|
|
7
|
+
export declare const getReferencesTranslation: (publicationOptions: PublicationOptions, references: PublicationRefs) => StdReader<string, "t" | "tm" | "ibi", "Publication">;
|
package/lib/references/index.js
CHANGED
|
@@ -1,41 +1,36 @@
|
|
|
1
|
+
import { Reader } from "@elyukai/utils/reader";
|
|
1
2
|
import { isNotNullish } from "@optolith/helpers/nullable";
|
|
2
3
|
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
4
|
+
import { getInstanceByIdR, sequence, translateMapR, translateR, } from "../entities/partial/reader.js";
|
|
3
5
|
import { fromRawPageRange, normalizePageRanges, printPageRanges } from "./pageRange.js";
|
|
4
6
|
import { isPublicationIncluded } from "./publicationOptions.js";
|
|
5
7
|
/**
|
|
6
8
|
* Returns the translation of the references.
|
|
7
9
|
*/
|
|
8
|
-
export const getReferencesTranslation = (
|
|
9
|
-
.map(ref => {
|
|
10
|
-
const publication = getInstanceById("Publication", ref.id);
|
|
11
|
-
const publicationTranslations = locale.translateMap(publication?.translations);
|
|
12
|
-
const occurrences = locale.translateMap(ref.occurrences);
|
|
10
|
+
export const getReferencesTranslation = (publicationOptions, references) => Reader.traverse(references, ref => getInstanceByIdR("Publication", ref.id).thenW(publication => translateMapR(publication?.translations).thenW(publicationTranslation => translateMapR(ref.occurrences).thenW(occurrences => {
|
|
13
11
|
if (publication === undefined ||
|
|
14
|
-
|
|
12
|
+
publicationTranslation === undefined ||
|
|
15
13
|
occurrences === undefined ||
|
|
16
14
|
(publicationOptions.onlyShowReferencesToIncludedPublications &&
|
|
17
15
|
!isPublicationIncluded(publicationOptions, ref.id, publication))) {
|
|
18
|
-
return undefined;
|
|
16
|
+
return Reader.of(undefined);
|
|
19
17
|
}
|
|
20
18
|
const initialPageRanges = normalizePageRanges(occurrences.initial.pages.map(fromRawPageRange));
|
|
21
19
|
const initial = occurrences.initial.printing === undefined
|
|
22
|
-
? printPageRanges(
|
|
23
|
-
: `${printPageRanges(
|
|
20
|
+
? printPageRanges(initialPageRanges)
|
|
21
|
+
: sequence `${printPageRanges(initialPageRanges)} (${translateR(".input {$printing :number} {{since the {$printing}. printing}}", { printing: occurrences.initial.printing })})`;
|
|
24
22
|
const revisions = occurrences.revisions?.map(rev => {
|
|
25
23
|
switch (rev.kind) {
|
|
26
24
|
case "Since": {
|
|
27
25
|
const pageRanges = normalizePageRanges(rev.Since.pages.map(fromRawPageRange));
|
|
28
|
-
return `${printPageRanges(
|
|
26
|
+
return sequence `${printPageRanges(pageRanges)} (${translateR(".input {$printing :number} {{since the {$printing}. printing}}", { printing: rev.Since.printing })})`;
|
|
29
27
|
}
|
|
30
28
|
case "Deprecated": {
|
|
31
|
-
return
|
|
29
|
+
return translateR(".input {$printing :number} {{removed in {$printing}. printing}}", { printing: rev.Deprecated.printing });
|
|
32
30
|
}
|
|
33
31
|
default:
|
|
34
32
|
return assertExhaustive(rev);
|
|
35
33
|
}
|
|
36
34
|
}) ?? [];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})
|
|
40
|
-
.filter(isNotNullish)
|
|
41
|
-
.join("; ");
|
|
35
|
+
return Reader.sequence([initial, ...revisions]).map(list => `${publicationTranslation.name} ${list.join("; ")}`);
|
|
36
|
+
})))).map(list => list.filter(isNotNullish).join("; "));
|
package/lib/references/page.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Reader } from "@elyukai/utils/reader";
|
|
1
2
|
import type { Page } from "@optolith/database-schema/gen";
|
|
2
3
|
import type { Compare } from "@optolith/helpers/compare";
|
|
3
|
-
import type { Translate } from "../helpers/translate.js";
|
|
4
4
|
/**
|
|
5
5
|
* A comparison function for two pages.
|
|
6
6
|
*/
|
|
@@ -20,4 +20,6 @@ export declare const numberToPage: (number: number) => Page;
|
|
|
20
20
|
/**
|
|
21
21
|
* Returns a string representation of a page.
|
|
22
22
|
*/
|
|
23
|
-
export declare const printPage: (
|
|
23
|
+
export declare const printPage: (page: Page) => Reader<{
|
|
24
|
+
translate: import("../helpers/translate.js").Translate;
|
|
25
|
+
}, string>;
|
package/lib/references/page.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Reader } from "@elyukai/utils/reader";
|
|
1
2
|
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
3
|
+
import { translateR } from "../entities/partial/reader.js";
|
|
2
4
|
/**
|
|
3
5
|
* A comparison function for two pages.
|
|
4
6
|
*/
|
|
@@ -47,14 +49,14 @@ export const numberToPage = (number) => ({
|
|
|
47
49
|
/**
|
|
48
50
|
* Returns a string representation of a page.
|
|
49
51
|
*/
|
|
50
|
-
export const printPage = (
|
|
52
|
+
export const printPage = (page) => {
|
|
51
53
|
switch (page.kind) {
|
|
52
54
|
case "InsideCoverFront":
|
|
53
|
-
return
|
|
55
|
+
return translateR("Front Cover Inside");
|
|
54
56
|
case "InsideCoverBack":
|
|
55
|
-
return
|
|
57
|
+
return translateR("Back Cover Inside");
|
|
56
58
|
case "Numbered":
|
|
57
|
-
return page.Numbered.toFixed();
|
|
59
|
+
return Reader.of(page.Numbered.toFixed());
|
|
58
60
|
default:
|
|
59
61
|
return assertExhaustive(page);
|
|
60
62
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Page, PageRange as RawPageRange } from "@optolith/database-schema/gen";
|
|
2
|
-
import type {
|
|
2
|
+
import type { StdReader } from "../env.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.
|
|
@@ -19,8 +19,8 @@ export declare const normalizePageRanges: (ranges: PageRange[]) => PageRange[];
|
|
|
19
19
|
/**
|
|
20
20
|
* Returns a string representation of a page range.
|
|
21
21
|
*/
|
|
22
|
-
export declare const printPageRange: (
|
|
22
|
+
export declare const printPageRange: (pageRange: PageRange) => StdReader<string, "t">;
|
|
23
23
|
/**
|
|
24
24
|
* Returns a string representation of a list of page ranges.
|
|
25
25
|
*/
|
|
26
|
-
export declare const printPageRanges: (
|
|
26
|
+
export declare const printPageRanges: (pageRanges: PageRange[]) => StdReader<string, "t">;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Reader } from "@elyukai/utils/reader";
|
|
1
2
|
import { range } from "@optolith/helpers/array";
|
|
3
|
+
import { sequence } from "../entities/partial/reader.js";
|
|
2
4
|
import { comparePage, equalsPage, printPage, succ } from "./page.js";
|
|
3
5
|
/**
|
|
4
6
|
* Converts a page object range from the database to a local page object range.
|
|
@@ -40,10 +42,10 @@ export const normalizePageRanges = (ranges) => ranges
|
|
|
40
42
|
/**
|
|
41
43
|
* Returns a string representation of a page range.
|
|
42
44
|
*/
|
|
43
|
-
export const printPageRange = (
|
|
44
|
-
? printPage(
|
|
45
|
-
: `${printPage(
|
|
45
|
+
export const printPageRange = (pageRange) => pageRange.lastPage === undefined
|
|
46
|
+
? printPage(pageRange.firstPage)
|
|
47
|
+
: sequence `${printPage(pageRange.firstPage)}–${printPage(pageRange.lastPage)}`;
|
|
46
48
|
/**
|
|
47
49
|
* Returns a string representation of a list of page ranges.
|
|
48
50
|
*/
|
|
49
|
-
export const printPageRanges = (
|
|
51
|
+
export const printPageRanges = (pageRanges) => Reader.traverse(pageRanges, printPageRange).map(list => list.join(", "));
|