@jetta/axle-load-calculator
v0.3.5
Published
Merged weight_by_axis physics and orchestration library
Keywords
Readme
axle-load-calculator
TypeScript library that merges ms-faixas-porcentuais weight_on_axles_physics orchestration with the axleweight physics engine. v1 is in-process only (no HTTP).
Requirements
- Node.js 20+
- npm
How to install
npm install
npm run buildUsage
import {
calculate_weight_on_axles_physics,
UnsupportedVehicleTypeError,
type WeightByAxisRequestInput,
type WeightByAxisSuccessOutput
} from '@jetta/axle-load-calculator'
import { ZodError } from 'zod'
const request: WeightByAxisRequestInput = { envs: [...] }
try {
const response: WeightByAxisSuccessOutput = calculate_weight_on_axles_physics(request)
// response.envs with axle weights
} catch (error) {
if (error instanceof ZodError) {
// invalid request shape (null, array, missing containers, etc.)
} else if (error instanceof UnsupportedVehicleTypeError) {
// unsupported tipoVeiculo
}
}Contract:
- Input: object
{ envs, config? }with requiredcontainerson each env (cloned before processing) - Success:
{ envs }withcontainers[].pesoEixosfilled;itemsandfaixascleared on containers - Failure: throws (see Errors below)
Errors
Thrown by calculate_weight_on_axles_physics
| Class | When |
|-------|------|
| ZodError (from zod, not re-exported) | Invalid request shape (null, array, missing containers, etc.) |
| UnsupportedVehicleTypeError | Unknown tipoVeiculo |
| UnrecognizedSuspensionTypeError | Invalid vanderleia suspension type |
| GrouperNotFoundError | Merged-container grouper not found |
| ItemOverlapError | Two allocated items occupy the same volume |
Import ZodError directly from zod.
Exported for lower-level use
Also exported from @jetta/axle-load-calculator for instanceof checks when using internal physics modules (not thrown by calculate_weight_on_axles_physics):
| Class | When |
|-------|------|
| ContainerSequenceNotFoundError | Container sequence missing on transport |
| MissingContainerError | Container lookup failed |
| UnknownItemIdError | Unknown item template id |
| DeflectionModelNotImplementedError | No deflection model for the vehicle |
Dependencies
- zod — request validation at the public boundary
@jetta/number-compare— float-safe interval tests in cargo collision- publint (dev) — npm package manifest validation
Scripts
| Command | Description |
|---------|-------------|
| npm test | Mocha tests (physics + Java integration fixtures) |
| npm run lint | ESLint (src, test/src) |
| npm run lint:package | Validate npm publish manifest with publint (run after build) |
| npm run build | tsc → build/ |
Layout
src/index.ts— public APIsrc/core/physics/— axleweight port (models, deflection, tare, services)src/core/orchestration/— Java weight-by-axis glue (mass center, collision, output)src/service/— reserved for future HTTP layertest/src/— mirrorssrc/; fixtures undertest/data/src/
