@optolith/entity-descriptions 0.2.1 → 0.3.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.
- package/CHANGELOG.md +58 -0
- package/lib/creator.d.ts +32 -0
- package/lib/creator.js +72 -0
- package/lib/entities/activatable.d.ts +52 -0
- package/lib/entities/activatable.js +609 -0
- package/lib/entities/alternativeRule.d.ts +7 -0
- package/lib/entities/alternativeRule.js +21 -0
- package/lib/entities/attribute.d.ts +6 -0
- package/lib/entities/attribute.js +15 -0
- package/lib/entities/combatTechnique.d.ts +5 -7
- package/lib/entities/combatTechnique.js +34 -24
- package/lib/entities/condition.d.ts +12 -0
- package/lib/entities/condition.js +63 -0
- package/lib/entities/culture.d.ts +8 -0
- package/lib/entities/culture.js +309 -0
- package/lib/entities/curriculum.d.ts +11 -0
- package/lib/entities/curriculum.js +266 -0
- package/lib/entities/derivedCharacteristic.d.ts +9 -0
- package/lib/entities/derivedCharacteristic.js +91 -0
- package/lib/entities/disease.d.ts +9 -0
- package/lib/entities/disease.js +88 -0
- package/lib/entities/elixir.d.ts +10 -0
- package/lib/entities/elixir.js +76 -0
- package/lib/entities/equipment.d.ts +24 -0
- package/lib/entities/equipment.js +613 -0
- package/lib/entities/equipmentPackage.d.ts +8 -0
- package/lib/entities/equipmentPackage.js +301 -0
- package/lib/entities/experienceLevel.d.ts +3 -2
- package/lib/entities/experienceLevel.js +33 -28
- package/lib/entities/focusRule.d.ts +3 -4
- package/lib/entities/focusRule.js +13 -5
- package/lib/entities/influence.d.ts +7 -0
- package/lib/entities/influence.js +35 -0
- package/lib/entities/liturgicalChant.d.ts +10 -23
- package/lib/entities/liturgicalChant.js +169 -131
- package/lib/entities/optionalRule.d.ts +3 -2
- package/lib/entities/optionalRule.js +4 -3
- package/lib/entities/partial/activatableNameChunks.d.ts +58 -0
- package/lib/entities/partial/activatableNameChunks.js +356 -0
- package/lib/entities/partial/adventurePointsValue.d.ts +9 -0
- package/lib/entities/partial/adventurePointsValue.js +243 -0
- package/lib/entities/partial/animalTypes.d.ts +11 -0
- package/lib/entities/partial/animalTypes.js +13 -0
- package/lib/entities/partial/commonnessRatedAdvantagesAndDisadvantages.d.ts +16 -0
- package/lib/entities/partial/commonnessRatedAdvantagesAndDisadvantages.js +40 -0
- package/lib/entities/partial/dice.d.ts +10 -0
- package/lib/entities/partial/dice.js +13 -0
- package/lib/entities/partial/herbary.d.ts +28 -0
- package/lib/entities/partial/herbary.js +65 -0
- package/lib/entities/partial/map.d.ts +49 -0
- package/lib/entities/partial/map.js +43 -0
- package/lib/entities/partial/mathOperation.d.ts +36 -0
- package/lib/entities/partial/mathOperation.js +107 -0
- package/lib/entities/partial/prerequisites/displayOption.d.ts +7 -0
- package/lib/entities/partial/prerequisites/displayOption.js +19 -0
- package/lib/entities/partial/prerequisites/index.d.ts +67 -0
- package/lib/entities/partial/prerequisites/index.js +189 -0
- package/lib/entities/partial/prerequisites/part.d.ts +26 -0
- package/lib/entities/partial/prerequisites/part.js +88 -0
- package/lib/entities/partial/prerequisites/prerequisiteGroups.d.ts +65 -0
- package/lib/entities/partial/prerequisites/prerequisiteGroups.js +269 -0
- package/lib/entities/partial/prerequisites/single/activatable.d.ts +18 -0
- package/lib/entities/partial/prerequisites/single/activatable.js +40 -0
- package/lib/entities/partial/prerequisites/single/animistPower.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/animistPower.js +23 -0
- package/lib/entities/partial/prerequisites/single/blessedTradition.d.ts +7 -0
- package/lib/entities/partial/prerequisites/single/blessedTradition.js +32 -0
- package/lib/entities/partial/prerequisites/single/commonSuggestedByRCP.d.ts +6 -0
- package/lib/entities/partial/prerequisites/single/commonSuggestedByRCP.js +19 -0
- package/lib/entities/partial/prerequisites/single/culture.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/culture.js +20 -0
- package/lib/entities/partial/prerequisites/single/enhancement.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/enhancement.js +41 -0
- package/lib/entities/partial/prerequisites/single/influence.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/influence.js +17 -0
- package/lib/entities/partial/prerequisites/single/magicalTradition.d.ts +7 -0
- package/lib/entities/partial/prerequisites/single/magicalTradition.js +27 -0
- package/lib/entities/partial/prerequisites/single/noOtherAncestorBloodAdvantage.d.ts +6 -0
- package/lib/entities/partial/prerequisites/single/noOtherAncestorBloodAdvantage.js +8 -0
- package/lib/entities/partial/prerequisites/single/pact.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/pact.js +30 -0
- package/lib/entities/partial/prerequisites/single/personalityTrait.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/personalityTrait.js +28 -0
- package/lib/entities/partial/prerequisites/single/primaryAttribute.d.ts +7 -0
- package/lib/entities/partial/prerequisites/single/primaryAttribute.js +15 -0
- package/lib/entities/partial/prerequisites/single/publication.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/publication.js +19 -0
- package/lib/entities/partial/prerequisites/single/race.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/race.js +20 -0
- package/lib/entities/partial/prerequisites/single/rated.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/rated.js +41 -0
- package/lib/entities/partial/prerequisites/single/ratedMinimumNumber.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/ratedMinimumNumber.js +89 -0
- package/lib/entities/partial/prerequisites/single/ratedSum.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/ratedSum.js +21 -0
- package/lib/entities/partial/prerequisites/single/rule.d.ts +7 -0
- package/lib/entities/partial/prerequisites/single/rule.js +4 -0
- package/lib/entities/partial/prerequisites/single/sex.d.ts +7 -0
- package/lib/entities/partial/prerequisites/single/sex.js +19 -0
- package/lib/entities/partial/prerequisites/single/sexualCharacteristic.d.ts +7 -0
- package/lib/entities/partial/prerequisites/single/sexualCharacteristic.js +21 -0
- package/lib/entities/partial/prerequisites/single/socialStatus.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/socialStatus.js +21 -0
- package/lib/entities/partial/prerequisites/single/state.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/state.js +20 -0
- package/lib/entities/partial/prerequisites/single/text.d.ts +7 -0
- package/lib/entities/partial/prerequisites/single/text.js +9 -0
- package/lib/entities/partial/professions.d.ts +15 -0
- package/lib/entities/partial/professions.js +19 -0
- package/lib/entities/partial/rated/activatable/castingTime.d.ts +16 -7
- package/lib/entities/partial/rated/activatable/castingTime.js +35 -20
- package/lib/entities/partial/rated/activatable/checkResultBased.d.ts +18 -3
- package/lib/entities/partial/rated/activatable/checkResultBased.js +18 -10
- package/lib/entities/partial/rated/activatable/cost.d.ts +88 -8
- package/lib/entities/partial/rated/activatable/cost.js +183 -115
- package/lib/entities/partial/rated/activatable/duration.d.ts +36 -13
- package/lib/entities/partial/rated/activatable/duration.js +72 -61
- package/lib/entities/partial/rated/activatable/effect.d.ts +4 -4
- package/lib/entities/partial/rated/activatable/effect.js +32 -25
- package/lib/entities/partial/rated/activatable/index.d.ts +31 -27
- package/lib/entities/partial/rated/activatable/index.js +63 -28
- package/lib/entities/partial/rated/activatable/isMinimumMaximum.d.ts +5 -6
- package/lib/entities/partial/rated/activatable/isMinimumMaximum.js +8 -5
- package/lib/entities/partial/rated/activatable/nonModifiableSuffix.d.ts +2 -4
- package/lib/entities/partial/rated/activatable/nonModifiableSuffix.js +7 -42
- package/lib/entities/partial/rated/activatable/range.d.ts +22 -14
- package/lib/entities/partial/rated/activatable/range.js +54 -54
- package/lib/entities/partial/rated/activatable/speed.d.ts +11 -2
- package/lib/entities/partial/rated/activatable/speed.js +14 -1
- package/lib/entities/partial/rated/activatable/targetCategory.d.ts +4 -5
- package/lib/entities/partial/rated/activatable/targetCategory.js +19 -24
- package/lib/entities/partial/rated/improvementCost.d.ts +16 -4
- package/lib/entities/partial/rated/improvementCost.js +63 -4
- package/lib/entities/partial/rated/skillCheck.d.ts +20 -17
- package/lib/entities/partial/rated/skillCheck.js +56 -54
- package/lib/entities/partial/reader.d.ts +266 -0
- package/lib/entities/partial/reader.js +175 -0
- package/lib/entities/partial/responsiveText.d.ts +10 -5
- package/lib/entities/partial/responsiveText.js +19 -3
- package/lib/entities/partial/units/energy.d.ts +5 -8
- package/lib/entities/partial/units/energy.js +5 -23
- package/lib/entities/partial/units/length.d.ts +20 -2
- package/lib/entities/partial/units/length.js +24 -5
- package/lib/entities/partial/units/timeSpan.d.ts +25 -4
- package/lib/entities/partial/units/timeSpan.js +27 -15
- package/lib/entities/partial/unknown.d.ts +5 -1
- package/lib/entities/partial/unknown.js +5 -1
- package/lib/entities/personalityTrait.d.ts +7 -0
- package/lib/entities/personalityTrait.js +56 -0
- package/lib/entities/poison.d.ts +12 -0
- package/lib/entities/poison.js +356 -0
- package/lib/entities/profession.d.ts +12 -0
- package/lib/entities/profession.js +585 -0
- package/lib/entities/race.d.ts +9 -0
- package/lib/entities/race.js +146 -0
- package/lib/entities/sexPractice.d.ts +6 -0
- package/lib/entities/sexPractice.js +33 -0
- package/lib/entities/skill.d.ts +9 -9
- package/lib/entities/skill.js +124 -91
- package/lib/entities/spell.d.ts +83 -26
- package/lib/entities/spell.js +835 -147
- package/lib/entities/state.d.ts +6 -0
- package/lib/entities/state.js +17 -0
- package/lib/helpers/enums.d.ts +11 -0
- package/lib/helpers/enums.js +6 -0
- package/lib/helpers/getTypes.d.ts +12 -482
- package/lib/helpers/getTypes.js +1 -0
- package/lib/helpers/identifiers.d.ts +314 -0
- package/lib/helpers/identifiers.js +333 -0
- package/lib/helpers/locale.d.ts +21 -2
- package/lib/helpers/translate.d.ts +47 -5
- package/lib/helpers/translate.js +13 -6
- package/lib/index.d.ts +848 -21
- package/lib/index.js +182 -17
- package/lib/references/index.d.ts +6 -3
- package/lib/references/index.js +25 -33
- package/lib/references/page.d.ts +1 -1
- package/lib/references/page.js +14 -14
- package/lib/references/pageRange.d.ts +1 -5
- package/lib/references/pageRange.js +7 -16
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/package.json +30 -10
- package/.prettierrc.yml +0 -1
- package/lib/entities/partial/rated/activatable/entity.d.ts +0 -11
- package/lib/entities/partial/rated/activatable/entity.js +0 -12
- package/lib/references/occurrence.d.ts +0 -4
- package/lib/references/occurrence.js +0 -3
package/lib/helpers/locale.d.ts
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
import { Compare } from "@optolith/helpers/compare";
|
|
2
|
-
import {
|
|
2
|
+
import type { LocaleMeasurementAdjustments } from "optolith-database-schema/gen";
|
|
3
|
+
import { Translate, TranslateMap, type Format } from "./translate.js";
|
|
4
|
+
/**
|
|
5
|
+
* The type of list to join in a locale-aware way.
|
|
6
|
+
*/
|
|
7
|
+
export type LocaleJoinType = "conjunction" | "disjunction" | "unit";
|
|
8
|
+
/**
|
|
9
|
+
* The environment for a locale.
|
|
10
|
+
*/
|
|
3
11
|
export type LocaleEnvironment = {
|
|
4
12
|
id: string;
|
|
13
|
+
format: Format;
|
|
5
14
|
translate: Translate;
|
|
6
15
|
translateMap: TranslateMap;
|
|
7
|
-
compare:
|
|
16
|
+
compare: LocaleCompare;
|
|
17
|
+
join: (list: string[], type: LocaleJoinType) => string;
|
|
18
|
+
measurementAdjustments: Required<LocaleMeasurementAdjustments>;
|
|
8
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* A function that compares two strings according to the locale's sorting rules.
|
|
22
|
+
*/
|
|
23
|
+
export type LocaleCompare = Compare<string>;
|
|
24
|
+
/**
|
|
25
|
+
* A function that joins a list of strings according to the locale's rules for the given type.
|
|
26
|
+
*/
|
|
27
|
+
export type LocaleJoin = (list: string[], type: LocaleJoinType) => string;
|
|
@@ -1,14 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Locale } from "optolith-database-schema/gen";
|
|
2
|
+
import { ResponsiveTextSize } from "../entities/partial/responsiveText.js";
|
|
3
|
+
/**
|
|
4
|
+
* The type of all translations
|
|
5
|
+
*/
|
|
6
|
+
export type Translations = NonNullable<Locale["translations"]>;
|
|
7
|
+
/**
|
|
8
|
+
* A function that formats a string with the given arguments.
|
|
9
|
+
*/
|
|
10
|
+
export type Format = (text: string, args?: Record<string, unknown>) => string;
|
|
3
11
|
/**
|
|
4
12
|
* Translates a given key into a string, optionally with parameters.
|
|
5
13
|
*/
|
|
6
|
-
export type Translate = <K extends keyof
|
|
14
|
+
export type Translate = <K extends keyof Translations>(key: K, ...rest: TranslationParamsInArray<K>) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Extracts the parameters for a given translation key, or never if the key does not have parameters.
|
|
17
|
+
*/
|
|
18
|
+
export type TranslationParams<K extends keyof Translations> = Translations[K] extends string & {
|
|
19
|
+
__params: infer Params;
|
|
20
|
+
} ? Params : undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Extracts the parameters for a given translation key as an array, or an empty array if the key does not have parameters.
|
|
23
|
+
*/
|
|
24
|
+
export type TranslationParamsInArray<K extends keyof Translations> = Translations[K] extends string & {
|
|
25
|
+
__params: infer Params;
|
|
26
|
+
} ? [params: Params] : [];
|
|
7
27
|
/**
|
|
8
|
-
* A
|
|
28
|
+
* A dictionary of locale identifiers to other values.
|
|
9
29
|
*/
|
|
10
|
-
export
|
|
30
|
+
export type LocaleMap<T> = Record<string, T>;
|
|
11
31
|
/**
|
|
12
32
|
* Selects a value from a locale dictionary based on the selected locale.
|
|
13
33
|
*/
|
|
14
34
|
export type TranslateMap = <T>(map: LocaleMap<T> | undefined) => T | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* The set of translation keys that do not have parameters.
|
|
37
|
+
*/
|
|
38
|
+
export type TranslationKeysWithoutParams = {
|
|
39
|
+
[K in keyof Translations]-?: Translations[K] extends string & {
|
|
40
|
+
__params: object;
|
|
41
|
+
} ? never : K;
|
|
42
|
+
}[keyof Translations];
|
|
43
|
+
/**
|
|
44
|
+
* Extracts the translation keys that match the parameters.
|
|
45
|
+
*/
|
|
46
|
+
export type TranslationKeyMatchingParams<Params> = Params extends object ? {
|
|
47
|
+
[K in keyof Translations]-?: keyof Params extends keyof TranslationParams<K> ? keyof TranslationParams<K> extends keyof Params ? K : never : never;
|
|
48
|
+
}[keyof Translations] : TranslationKeysWithoutParams;
|
|
49
|
+
/**
|
|
50
|
+
* Extracts the translation keys that match the parameters of the given key.
|
|
51
|
+
*/
|
|
52
|
+
export type TranslationKeyMatchingParamsOfKey<T extends keyof Translations> = Translations[T] extends object ? TranslationKeyMatchingParams<TranslationParams<T>> : TranslationKeysWithoutParams;
|
|
53
|
+
/**
|
|
54
|
+
* Translates a key that has different translations based on the responsive text size, e.g. a full and a compressed version of the same translation.
|
|
55
|
+
*/
|
|
56
|
+
export declare const responsiveTranslate: <K extends keyof Translations, K2 extends TranslationKeyMatchingParamsOfKey<K>>(translate: Translate, responsiveTextSize: ResponsiveTextSize, fullKey: K, compressedKey: K2, ...rest: TranslationParamsInArray<K> & TranslationParamsInArray<K2>) => string;
|
package/lib/helpers/translate.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return params[index]?.toString() ?? `{${rawIndex}}`;
|
|
4
|
-
});
|
|
1
|
+
import { assertExhaustive } from "@elyukai/utils/typeSafety";
|
|
2
|
+
import { ResponsiveTextSize } from "../entities/partial/responsiveText.js";
|
|
5
3
|
/**
|
|
6
|
-
*
|
|
4
|
+
* Translates a key that has different translations based on the responsive text size, e.g. a full and a compressed version of the same translation.
|
|
7
5
|
*/
|
|
8
|
-
export const
|
|
6
|
+
export const responsiveTranslate = (translate, responsiveTextSize, fullKey, compressedKey, ...rest) => {
|
|
7
|
+
switch (responsiveTextSize) {
|
|
8
|
+
case ResponsiveTextSize.Full:
|
|
9
|
+
return translate(fullKey, ...rest);
|
|
10
|
+
case ResponsiveTextSize.Compressed:
|
|
11
|
+
return translate(compressedKey, ...rest);
|
|
12
|
+
default:
|
|
13
|
+
return assertExhaustive(responsiveTextSize);
|
|
14
|
+
}
|
|
15
|
+
};
|