Setup getConfig with typebox validations
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"ml-levenberg-marquardt": "^5.0.0",
|
||||
"ml-levenberg-marquardt": "^5.0.1",
|
||||
"@blade-and-brawn/domain": "workspace:*"
|
||||
},
|
||||
"exports": {
|
||||
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
type StandardUnit,
|
||||
} from "@blade-and-brawn/domain";
|
||||
import { levenbergMarquardt as LM } from "ml-levenberg-marquardt";
|
||||
import { Type, type Static } from "@sinclair/typebox";
|
||||
import { Value } from "@sinclair/typebox/value";
|
||||
import defaultConfig from "./config.json" with { type: "json" };
|
||||
import defaultStandardsJson from "./data/default-standards.json" with { type: "json" };
|
||||
import { getAvgWeight } from "./avg-weights";
|
||||
@@ -211,26 +213,27 @@ export class LevelCalculator {
|
||||
}
|
||||
}
|
||||
|
||||
export type StandardsConfig = {
|
||||
global: {
|
||||
maxLevel: number;
|
||||
};
|
||||
activity: Record<
|
||||
Activity,
|
||||
{
|
||||
weightModifier: number;
|
||||
weightSkew: number;
|
||||
ageModifier: number;
|
||||
enableGeneration: boolean;
|
||||
difficultyModifier: number;
|
||||
peakAge: number;
|
||||
stretch: {
|
||||
upper: number;
|
||||
lower: number;
|
||||
};
|
||||
}
|
||||
>;
|
||||
};
|
||||
const StandardsActivityConfigSchema = Type.Object({
|
||||
weightModifier: Type.Number(),
|
||||
weightSkew: Type.Number(),
|
||||
ageModifier: Type.Number(),
|
||||
enableGeneration: Type.Boolean(),
|
||||
difficultyModifier: Type.Number(),
|
||||
peakAge: Type.Number(),
|
||||
stretch: Type.Object({
|
||||
upper: Type.Number(),
|
||||
lower: Type.Number(),
|
||||
}),
|
||||
});
|
||||
|
||||
export const StandardsConfigSchema = Type.Object({
|
||||
global: Type.Object({
|
||||
maxLevel: Type.Number(),
|
||||
}),
|
||||
activity: Type.Record(Type.Enum(Activity), StandardsActivityConfigSchema),
|
||||
});
|
||||
|
||||
export type StandardsConfig = Static<typeof StandardsConfigSchema>;
|
||||
|
||||
export class Standards {
|
||||
readonly cfg: StandardsConfig;
|
||||
|
||||
@@ -6,7 +6,5 @@
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"pino": "^10.3.1"
|
||||
}
|
||||
"dependencies": {}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@blade-and-brawn/domain": "workspace:*",
|
||||
"@sinclair/typebox": "^0.34.48"
|
||||
"@blade-and-brawn/domain": "workspace:*"
|
||||
},
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
|
||||
Reference in New Issue
Block a user