@jetta/cargo-stabilizer 0.1.0-5 → 0.1.0-7

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 (42) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/README.md +2 -2
  3. package/build/core/adapters/axle_adapter.d.ts.map +1 -1
  4. package/build/core/adapters/axle_adapter.js +6 -10
  5. package/build/core/adapters/build_axle_request.d.ts +15 -0
  6. package/build/core/adapters/build_axle_request.d.ts.map +1 -0
  7. package/build/core/adapters/build_axle_request.js +39 -0
  8. package/build/core/adapters/run_axle_calculator.d.ts +16 -0
  9. package/build/core/adapters/run_axle_calculator.d.ts.map +1 -0
  10. package/build/core/adapters/run_axle_calculator.js +32 -0
  11. package/build/core/evaluation/compute_reorder_objective.d.ts +13 -0
  12. package/build/core/evaluation/compute_reorder_objective.d.ts.map +1 -0
  13. package/build/core/evaluation/compute_reorder_objective.js +13 -0
  14. package/build/core/evaluation/state_evaluator.d.ts.map +1 -1
  15. package/build/core/evaluation/state_evaluator.js +3 -2
  16. package/build/core/exceptions/AxleCalculationError.d.ts +4 -0
  17. package/build/core/exceptions/AxleCalculationError.d.ts.map +1 -0
  18. package/build/core/exceptions/AxleCalculationError.js +6 -0
  19. package/build/core/validation/contract/cargo_movement_wire_field_map.d.ts +17 -1
  20. package/build/core/validation/contract/cargo_movement_wire_field_map.d.ts.map +1 -1
  21. package/build/core/validation/contract/cargo_movement_wire_field_map.js +18 -2
  22. package/build/core/validation/contract/map_contract_to_wire_shape.js +20 -6
  23. package/build/core/validation/contract/map_wire_input_to_contract_shape.d.ts.map +1 -1
  24. package/build/core/validation/contract/map_wire_input_to_contract_shape.js +16 -18
  25. package/build/core/validation/contract/map_wire_item_to_contract.d.ts +12 -0
  26. package/build/core/validation/contract/map_wire_item_to_contract.d.ts.map +1 -0
  27. package/build/core/validation/contract/map_wire_item_to_contract.js +49 -0
  28. package/build/core/validation/contract/parse_stabilizer_input.d.ts +3 -0
  29. package/build/core/validation/contract/parse_stabilizer_input.d.ts.map +1 -1
  30. package/build/core/validation/contract/parse_stabilizer_output.d.ts +3 -0
  31. package/build/core/validation/contract/parse_stabilizer_output.d.ts.map +1 -1
  32. package/build/core/validation/contract/stabilizer_domain_schema.d.ts +9 -0
  33. package/build/core/validation/contract/stabilizer_domain_schema.d.ts.map +1 -1
  34. package/build/core/validation/contract/stabilizer_domain_schema.js +6 -3
  35. package/build/core/validation/contract/stabilizer_input_schema.d.ts +3 -0
  36. package/build/core/validation/contract/stabilizer_input_schema.d.ts.map +1 -1
  37. package/build/core/validation/contract/stabilizer_output_schema.d.ts +6 -0
  38. package/build/core/validation/contract/stabilizer_output_schema.d.ts.map +1 -1
  39. package/build/core/validation/contract/wire_mapper_record_utils.d.ts +14 -0
  40. package/build/core/validation/contract/wire_mapper_record_utils.d.ts.map +1 -1
  41. package/build/core/validation/contract/wire_mapper_record_utils.js +30 -0
  42. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -16,6 +16,7 @@ Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
16
16
  ### Changed
17
17
 
18
18
  - README documents I/O contract mapping, configuration keys, dependencies, and test/coverage commands.
19
+ - Reorder objective is whole-cargo `transport_score`; loose-item score sum is only a tie-break. Axle, waypoint, and milkrun gates are unchanged.
19
20
 
20
21
  ### Testing
21
22
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @jetta/cargo-stabilizer
2
2
 
3
- TypeScript library that reorders **loose items only** to improve cargo stability while keeping compound blocks pinned. Implements five config-selectable strategies with organization gates (waypoint order, milkrun wall reservation) and empty-space candidate discovery (JET-2262).
3
+ TypeScript library that reorders **loose items only** to improve **whole-cargo transport stability** while keeping compound blocks pinned. The reorder objective is `transport_score` (loose-item score sum is a tie-break). Implements five config-selectable strategies with organization gates (waypoint order, milkrun wall reservation) and empty-space candidate discovery (JET-2262).
4
4
 
5
5
  ## Requirements
6
6
 
@@ -70,7 +70,7 @@ Exported parsers: `parse_stabilizer_input`, `parse_stabilizer_output`, `safe_par
70
70
  | Key | Default | Description |
71
71
  |-----|---------|-------------|
72
72
  | `cargo_stabilizer.reorder_strategy` | `gravity` | `gravity`, `greedy`, `beam_search`, `simulated_annealing`, `genetic` |
73
- | `cargo_stabilizer.transport_stability_floor` | `0` | Hard minimum transport stability score |
73
+ | `cargo_stabilizer.transport_stability_floor` | `0` | Hard minimum transport stability score (gate, not the maximize objective) |
74
74
  | `cargo_stabilizer.max_iteration` | `10` | Greedy / SA iteration budget |
75
75
  | `cargo_stabilizer.preserve_tie_block_organization` | `true` | When true, enforce waypoint Z zones and macro delivery order |
76
76
  | `cargo_stabilizer.enforce_milkrun_wall_reservation` | `false` | When true, reserve rear compound-wall Z bands using profile key below |
@@ -1 +1 @@
1
- {"version":3,"file":"axle_adapter.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/axle_adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAA;AAEvF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAC9B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAClB,OAAO,CAGT;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAUjF"}
1
+ {"version":3,"file":"axle_adapter.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/axle_adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAA;AAEvF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAC9B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAClB,OAAO,CAGT;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAejF"}
@@ -1,5 +1,4 @@
1
- import { calculate_weight_on_axles_physics } from '@jetta/axle-load-calculator';
2
- import { map_contract_to_wire_output } from '../validation/contract/cargo_movement_wire_mapper.js';
1
+ import { run_axle_calculator } from './run_axle_calculator.js';
3
2
  /**
4
3
  * @param final_kg - Loaded weight including tare.
5
4
  * @param max_kg - Axle supported max.
@@ -19,16 +18,13 @@ export function is_axle_load_valid(env, folga_pct) {
19
18
  if (!env.axles || env.axles.length === 0) {
20
19
  return true;
21
20
  }
22
- const output_env = parse_axle_calculator_output(env);
23
- const containers = (output_env.containers ?? []);
21
+ const result = run_axle_calculator(env);
22
+ if (!result.calculated) {
23
+ return false;
24
+ }
25
+ const containers = (result.env.containers ?? []);
24
26
  return containers.every(container => container_axles_within_folga(container, folga_pct));
25
27
  }
26
- function parse_axle_calculator_output(env) {
27
- const wire_cargo_state = map_contract_to_wire_output({ envs: [env] });
28
- const request = { envs: wire_cargo_state.envs };
29
- const output = JSON.parse(calculate_weight_on_axles_physics(JSON.stringify(request)));
30
- return output.envs[0];
31
- }
32
28
  function container_axles_within_folga(container, folga_pct) {
33
29
  const axles = (container.pesoEixos ?? []);
34
30
  return axles.every(axle => {
@@ -0,0 +1,15 @@
1
+ import type { StabilizerEnv } from '../validation/contract/stabilizer_domain_schema.js';
2
+ /**
3
+ * Builds the axle-load-calculator request for a single env.
4
+ *
5
+ * The calculator physics reads `peso`, `largura`, `altura` and `comprimento`
6
+ * (ItemTemplates and JavaMassCenter), none of which exist in the
7
+ * cargo-movement wire item shape (`wg`, `w`, `h`, `d`). Without these aliases
8
+ * every item weighs zero and the axle gate can never reject a layout, so the
9
+ * contract values are stamped onto each request item here. Longitudinal extent
10
+ * is `depth`, matching the wire `y` axis the calculator uses for equilibrium.
11
+ * @param env - Stabilizer env with containers and axles.
12
+ * @returns Calculator request payload.
13
+ */
14
+ export declare function build_axle_request(env: StabilizerEnv): Record<string, unknown>;
15
+ //# sourceMappingURL=build_axle_request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build_axle_request.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/build_axle_request.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAER,aAAa,EAEhB,MAAM,oDAAoD,CAAA;AAE3D;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAS9E"}
@@ -0,0 +1,39 @@
1
+ import { map_contract_to_wire_output } from '../validation/contract/cargo_movement_wire_mapper.js';
2
+ /**
3
+ * Builds the axle-load-calculator request for a single env.
4
+ *
5
+ * The calculator physics reads `peso`, `largura`, `altura` and `comprimento`
6
+ * (ItemTemplates and JavaMassCenter), none of which exist in the
7
+ * cargo-movement wire item shape (`wg`, `w`, `h`, `d`). Without these aliases
8
+ * every item weighs zero and the axle gate can never reject a layout, so the
9
+ * contract values are stamped onto each request item here. Longitudinal extent
10
+ * is `depth`, matching the wire `y` axis the calculator uses for equilibrium.
11
+ * @param env - Stabilizer env with containers and axles.
12
+ * @returns Calculator request payload.
13
+ */
14
+ export function build_axle_request(env) {
15
+ const wire = map_contract_to_wire_output({ envs: [env] });
16
+ const wire_env = wire.envs[0];
17
+ const wire_containers = (wire_env.containers ?? []);
18
+ wire_env.containers = wire_containers.map((wire_container, index) => stamp_container_physics_aliases(wire_container, env.containers[index]));
19
+ return { envs: wire.envs };
20
+ }
21
+ function stamp_container_physics_aliases(wire_container, container) {
22
+ const wire_items = (wire_container.items ?? []);
23
+ return {
24
+ ...wire_container,
25
+ items: wire_items.map((wire_item, index) => stamp_item_physics_aliases(wire_item, container?.items[index]))
26
+ };
27
+ }
28
+ function stamp_item_physics_aliases(wire_item, item) {
29
+ if (item === undefined) {
30
+ return wire_item;
31
+ }
32
+ return {
33
+ ...wire_item,
34
+ peso: item.weight ?? 0,
35
+ largura: item.width,
36
+ altura: item.height,
37
+ comprimento: item.depth
38
+ };
39
+ }
@@ -0,0 +1,16 @@
1
+ import type { StabilizerEnv } from '../validation/contract/stabilizer_domain_schema.js';
2
+ export type AxleCalculatorResult = {
3
+ calculated: true;
4
+ env: Record<string, unknown>;
5
+ } | {
6
+ calculated: false;
7
+ reason: string;
8
+ };
9
+ /**
10
+ * Runs the axle-load calculator for a candidate env layout.
11
+ * @param env - Stabilizer env with containers and axles.
12
+ * @returns Calculated env, or the reason the layout was rejected.
13
+ * @throws {AxleCalculationError} When the vehicle or item configuration cannot be calculated.
14
+ */
15
+ export declare function run_axle_calculator(env: StabilizerEnv): AxleCalculatorResult;
16
+ //# sourceMappingURL=run_axle_calculator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run_axle_calculator.d.ts","sourceRoot":"","sources":["../../../src/core/adapters/run_axle_calculator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAA;AASvF,MAAM,MAAM,oBAAoB,GAC1B;IAAE,UAAU,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAClD;IAAE,UAAU,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAE3C;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,aAAa,GAAG,oBAAoB,CAoB5E"}
@@ -0,0 +1,32 @@
1
+ import { calculate_weight_on_axles_physics } from '@jetta/axle-load-calculator';
2
+ import { build_axle_request } from './build_axle_request.js';
3
+ import { AxleCalculationError } from '../exceptions/AxleCalculationError.js';
4
+ import { stabilizer_logger } from '../logging/stabilizer_logger.js';
5
+ /**
6
+ * Calculator failures caused by the candidate layout rather than by the vehicle
7
+ * or item configuration. These reject the candidate layout; every other failure
8
+ * means the env can never be evaluated and aborts the run.
9
+ */
10
+ const LAYOUT_REJECTION_MESSAGES = Object.freeze(['Item overlap error']);
11
+ /**
12
+ * Runs the axle-load calculator for a candidate env layout.
13
+ * @param env - Stabilizer env with containers and axles.
14
+ * @returns Calculated env, or the reason the layout was rejected.
15
+ * @throws {AxleCalculationError} When the vehicle or item configuration cannot be calculated.
16
+ */
17
+ export function run_axle_calculator(env) {
18
+ const request = build_axle_request(env);
19
+ const output = JSON.parse(calculate_weight_on_axles_physics(JSON.stringify(request)));
20
+ if (Array.isArray(output.envs) && output.envs.length > 0) {
21
+ return { calculated: true, env: output.envs[0] };
22
+ }
23
+ const reason = output.apiError ?? 'calculator returned no envs';
24
+ if (!is_layout_rejection(reason)) {
25
+ throw new AxleCalculationError(reason);
26
+ }
27
+ stabilizer_logger.debug('axle gate rejected candidate layout: ' + reason);
28
+ return { calculated: false, reason };
29
+ }
30
+ function is_layout_rejection(reason) {
31
+ return LAYOUT_REJECTION_MESSAGES.some(message => reason.includes(message));
32
+ }
@@ -0,0 +1,13 @@
1
+ import { type StabilityEvaluation } from '../adapters/stability_adapter.js';
2
+ import type { StabilizerContainer } from '../validation/contract/stabilizer_domain_schema.js';
3
+ import type { LooseItemRef } from '../filters/loose_item_filter.js';
4
+ export declare const LOOSE_SUM_TIE_BREAK_SCALE = 0.000001;
5
+ /**
6
+ * Computes the reorder objective: maximize transport stability, then loose-item sum.
7
+ * @param stability - Transport stability evaluation.
8
+ * @param containers - Container layout used for loose-item index lookup.
9
+ * @param loose_items - Loose items included in the tie-break term.
10
+ * @returns Scalar objective; higher is better.
11
+ */
12
+ export declare function compute_reorder_objective(stability: StabilityEvaluation, containers: StabilizerContainer[], loose_items: LooseItemRef[]): number;
13
+ //# sourceMappingURL=compute_reorder_objective.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute_reorder_objective.d.ts","sourceRoot":"","sources":["../../../src/core/evaluation/compute_reorder_objective.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,mBAAmB,EAC3B,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAA;AAC7F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAEnE,eAAO,MAAM,yBAAyB,WAAO,CAAA;AAE7C;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACrC,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EAAE,mBAAmB,EAAE,EACjC,WAAW,EAAE,YAAY,EAAE,GAC5B,MAAM,CAIR"}
@@ -0,0 +1,13 @@
1
+ import { sum_loose_item_scores } from '../adapters/stability_adapter.js';
2
+ export const LOOSE_SUM_TIE_BREAK_SCALE = 1e-6;
3
+ /**
4
+ * Computes the reorder objective: maximize transport stability, then loose-item sum.
5
+ * @param stability - Transport stability evaluation.
6
+ * @param containers - Container layout used for loose-item index lookup.
7
+ * @param loose_items - Loose items included in the tie-break term.
8
+ * @returns Scalar objective; higher is better.
9
+ */
10
+ export function compute_reorder_objective(stability, containers, loose_items) {
11
+ const loose_sum = sum_loose_item_scores(stability, containers, loose_items);
12
+ return stability.transport_score + loose_sum * LOOSE_SUM_TIE_BREAK_SCALE;
13
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"state_evaluator.d.ts","sourceRoot":"","sources":["../../../src/core/evaluation/state_evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAA;AAC7F,OAAO,EAGH,KAAK,mBAAmB,EAC3B,MAAM,kCAAkC,CAAA;AAKzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAA;AAE9E,MAAM,WAAW,gBAAgB;IAE7B,SAAS,EAAE,mBAAmB,CAAA;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,qBAAqB,EAAE,OAAO,CAAA;IAC9B,UAAU,EAAE,OAAO,CAAA;IACnB,cAAc,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,OAAO,CAAA;IACtB,cAAc,EAAE,OAAO,CAAA;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC1B,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,EAAE,sBAAsB,GAChC,gBAAgB,CAUlB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,mBAAmB,EAAE,EAC5B,OAAO,EAAE,sBAAsB,GAChC,gBAAgB,CAGlB;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,cAAc,GAAG,sBAAsB,CAU/F;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,mBAAmB,EAAE,GAAG,mBAAmB,EAAE,CAGvF;AAwBD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACvC,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,EAAE,sBAAsB,GAChC;IAAE,cAAc,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,CAMrD"}
1
+ {"version":3,"file":"state_evaluator.d.ts","sourceRoot":"","sources":["../../../src/core/evaluation/state_evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAA;AAC7F,OAAO,EAEH,KAAK,mBAAmB,EAC3B,MAAM,kCAAkC,CAAA;AAMzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAA;AAE9E,MAAM,WAAW,gBAAgB;IAE7B,SAAS,EAAE,mBAAmB,CAAA;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,qBAAqB,EAAE,OAAO,CAAA;IAC9B,UAAU,EAAE,OAAO,CAAA;IACnB,cAAc,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,OAAO,CAAA;IACtB,cAAc,EAAE,OAAO,CAAA;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC1B,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,EAAE,sBAAsB,GAChC,gBAAgB,CAUlB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,mBAAmB,EAAE,EAC5B,OAAO,EAAE,sBAAsB,GAChC,gBAAgB,CAGlB;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,cAAc,GAAG,sBAAsB,CAU/F;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,mBAAmB,EAAE,GAAG,mBAAmB,EAAE,CAGvF;AAwBD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACvC,UAAU,EAAE,mBAAmB,EAAE,EACjC,OAAO,EAAE,sBAAsB,GAChC;IAAE,cAAc,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,CAMrD"}
@@ -1,4 +1,5 @@
1
- import { try_evaluate_transport_stability, sum_loose_item_scores } from '../adapters/stability_adapter.js';
1
+ import { try_evaluate_transport_stability } from '../adapters/stability_adapter.js';
2
+ import { compute_reorder_objective } from './compute_reorder_objective.js';
2
3
  import { is_axle_load_valid } from '../adapters/axle_adapter.js';
3
4
  import { preserves_waypoint_order } from '../waypoint/preserves_waypoint_order.js';
4
5
  import { is_layout_milkrun_valid } from '../waypoint/milkrun_wall_reservation.js';
@@ -50,7 +51,7 @@ export function clone_baseline(containers) {
50
51
  return clone_containers(containers);
51
52
  }
52
53
  function evaluate_gates(containers, context, stability) {
53
- const objective = sum_loose_item_scores(stability, containers, context.loose_items);
54
+ const objective = compute_reorder_objective(stability, containers, context.loose_items);
54
55
  const transport_floor_valid = stability.transport_score >= context.config.transport_stability_floor;
55
56
  const axle_valid = is_axle_load_valid({ ...context.env, containers }, context.config.axle_load_margin_percent);
56
57
  const waypoint_valid = is_waypoint_order_valid(containers, context);
@@ -0,0 +1,4 @@
1
+ export declare class AxleCalculationError extends Error {
2
+ constructor(reason: string);
3
+ }
4
+ //# sourceMappingURL=AxleCalculationError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AxleCalculationError.d.ts","sourceRoot":"","sources":["../../../src/core/exceptions/AxleCalculationError.ts"],"names":[],"mappings":"AAAA,qBAAa,oBAAqB,SAAQ,KAAK;gBAE/B,MAAM,EAAE,MAAM;CAK7B"}
@@ -0,0 +1,6 @@
1
+ export class AxleCalculationError extends Error {
2
+ constructor(reason) {
3
+ super('Axle load calculation failed: ' + reason);
4
+ this.name = 'AxleCalculationError';
5
+ }
6
+ }
@@ -4,8 +4,24 @@ export declare const ITEM_WIRE_TO_CONTRACT: {
4
4
  readonly w: "width";
5
5
  readonly h: "height";
6
6
  readonly d: "depth";
7
- readonly peso: "weight";
8
7
  };
8
+ /**
9
+ * Cargo-movement wire keys feeding each contract item field, in precedence
10
+ * order. Items are read-only for the stabilizer apart from their position, so
11
+ * these keys are read rather than renamed: the original wire record is
12
+ * retained in `attributes` and is what gets emitted back.
13
+ */
14
+ export declare const ITEM_CONTRACT_WIRE_KEYS: Readonly<{
15
+ item_id: string[];
16
+ group_id: string[];
17
+ waypoint_id: string[];
18
+ width: string[];
19
+ height: string[];
20
+ depth: string[];
21
+ weight: string[];
22
+ }>;
23
+ /** Item fields the stabilizer mutates, and therefore must emit itself. */
24
+ export declare const ITEM_POSITION_KEYS: string[];
9
25
  export declare const CONTAINER_WIRE_TO_CONTRACT: {
10
26
  readonly sequencia: "sequence";
11
27
  readonly largura: "width";
@@ -1 +1 @@
1
- {"version":3,"file":"cargo_movement_wire_field_map.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/cargo_movement_wire_field_map.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB;;;;;;;CAOxB,CAAA;AAEV,eAAO,MAAM,0BAA0B;;;;;CAK7B,CAAA;AAEV,eAAO,MAAM,oBAAoB;;CAEvB,CAAA;AAEV,eAAO,MAAM,qBAAqB,wBAAoC,CAAA;AACtE,eAAO,MAAM,0BAA0B,wBAAyC,CAAA;AAChF,eAAO,MAAM,oBAAoB,wBAAmC,CAAA"}
1
+ {"version":3,"file":"cargo_movement_wire_field_map.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/cargo_movement_wire_field_map.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB;;;;;;CAMxB,CAAA;AAEV;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;EAQlC,CAAA;AAEF,0EAA0E;AAC1E,eAAO,MAAM,kBAAkB,UAAkB,CAAA;AAEjD,eAAO,MAAM,0BAA0B;;;;;CAK7B,CAAA;AAEV,eAAO,MAAM,oBAAoB;;CAEvB,CAAA;AAEV,eAAO,MAAM,qBAAqB,wBAAoC,CAAA;AACtE,eAAO,MAAM,0BAA0B,wBAAyC,CAAA;AAChF,eAAO,MAAM,oBAAoB,wBAAmC,CAAA"}
@@ -3,9 +3,25 @@ export const ITEM_WIRE_TO_CONTRACT = {
3
3
  groupId: 'group_id',
4
4
  w: 'width',
5
5
  h: 'height',
6
- d: 'depth',
7
- peso: 'weight'
6
+ d: 'depth'
8
7
  };
8
+ /**
9
+ * Cargo-movement wire keys feeding each contract item field, in precedence
10
+ * order. Items are read-only for the stabilizer apart from their position, so
11
+ * these keys are read rather than renamed: the original wire record is
12
+ * retained in `attributes` and is what gets emitted back.
13
+ */
14
+ export const ITEM_CONTRACT_WIRE_KEYS = Object.freeze({
15
+ item_id: ['item_id', '_id'],
16
+ group_id: ['groupId', 'group_id'],
17
+ waypoint_id: ['waypoint_id'],
18
+ width: ['w', 'width'],
19
+ height: ['h', 'height'],
20
+ depth: ['d', 'depth'],
21
+ weight: ['wg', 'peso', 'weight']
22
+ });
23
+ /** Item fields the stabilizer mutates, and therefore must emit itself. */
24
+ export const ITEM_POSITION_KEYS = ['x', 'y', 'z'];
9
25
  export const CONTAINER_WIRE_TO_CONTRACT = {
10
26
  sequencia: 'sequence',
11
27
  largura: 'width',
@@ -1,5 +1,5 @@
1
1
  import { CONTRACT_TO_CONTAINER_WIRE, CONTRACT_TO_ITEM_WIRE } from './cargo_movement_wire_field_map.js';
2
- import { rename_keys } from './wire_mapper_record_utils.js';
2
+ import { omit_keys, rename_keys } from './wire_mapper_record_utils.js';
3
3
  export function map_cargo_state_to_wire(cargo_state) {
4
4
  const wire = {
5
5
  envs: cargo_state.envs.map(map_env_to_wire)
@@ -10,19 +10,33 @@ export function map_cargo_state_to_wire(cargo_state) {
10
10
  return wire;
11
11
  }
12
12
  function map_env_to_wire(env) {
13
- const wire = {
14
- containers: env.containers.map(map_container_to_wire)
15
- };
13
+ const wire = { ...(env.vehicle ?? {}) };
14
+ wire.containers = env.containers.map(map_container_to_wire);
16
15
  if (env.axles !== undefined) {
17
16
  wire.eixos = env.axles;
18
17
  }
19
18
  return wire;
20
19
  }
21
20
  function map_container_to_wire(container) {
22
- const wire = rename_keys(container, CONTRACT_TO_CONTAINER_WIRE);
21
+ const modelled = omit_keys(container, ['attributes', 'items']);
22
+ const wire = { ...(container.attributes ?? {}) };
23
+ Object.assign(wire, rename_keys(modelled, CONTRACT_TO_CONTAINER_WIRE));
23
24
  wire.items = container.items.map(map_item_to_wire);
24
25
  return wire;
25
26
  }
27
+ /**
28
+ * Emits a contract item back to the wire.
29
+ *
30
+ * Position is the only field the stabilizer mutates, so an item that came from
31
+ * the cargo-movement wire is emitted as its retained original record with the
32
+ * new position stamped on. Items parsed straight from the English contract have
33
+ * no retained record and fall back to renaming the modelled fields.
34
+ * @param item - Contract item.
35
+ * @returns Wire item.
36
+ */
26
37
  function map_item_to_wire(item) {
27
- return rename_keys(item, CONTRACT_TO_ITEM_WIRE);
38
+ if (item.attributes === undefined) {
39
+ return rename_keys(omit_keys(item, ['attributes']), CONTRACT_TO_ITEM_WIRE);
40
+ }
41
+ return { ...item.attributes, x: item.x, y: item.y, z: item.z };
28
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"map_wire_input_to_contract_shape.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/map_wire_input_to_contract_shape.ts"],"names":[],"mappings":"AAOA,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAiBnE"}
1
+ {"version":3,"file":"map_wire_input_to_contract_shape.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/map_wire_input_to_contract_shape.ts"],"names":[],"mappings":"AAUA,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAiBnE"}
@@ -1,5 +1,8 @@
1
- import { CONTAINER_WIRE_TO_CONTRACT, ENV_WIRE_TO_CONTRACT, ITEM_WIRE_TO_CONTRACT } from './cargo_movement_wire_field_map.js';
2
- import { is_record, pick_keys, rename_keys } from './wire_mapper_record_utils.js';
1
+ import { CONTAINER_WIRE_TO_CONTRACT, ENV_WIRE_TO_CONTRACT } from './cargo_movement_wire_field_map.js';
2
+ import { map_wire_item_to_contract } from './map_wire_item_to_contract.js';
3
+ import { is_record, omit_keys, pick_keys, rename_keys } from './wire_mapper_record_utils.js';
4
+ const CONTAINER_CONTRACT_KEYS = ['sequence', 'width', 'height', 'length'];
5
+ const ENV_CONTRACT_KEYS = ['axles'];
3
6
  export function map_cargo_state_to_contract(value) {
4
7
  if (!is_record(value)) {
5
8
  return value;
@@ -29,34 +32,29 @@ function map_container_to_contract(value) {
29
32
  }
30
33
  const mapped = rename_keys(value, CONTAINER_WIRE_TO_CONTRACT);
31
34
  if (Array.isArray(value.items)) {
32
- mapped.items = value.items.map(map_item_to_contract);
35
+ mapped.items = value.items.map(map_wire_item_to_contract);
33
36
  }
34
37
  return pick_container_contract_keys(mapped);
35
38
  }
36
- function map_item_to_contract(value) {
37
- if (!is_record(value)) {
38
- return value;
39
- }
40
- const mapped = rename_keys(value, ITEM_WIRE_TO_CONTRACT);
41
- return pick_item_contract_keys(mapped);
42
- }
43
- function pick_item_contract_keys(source) {
44
- return pick_keys(source, [
45
- 'item_id', 'group_id', 'waypoint_id', 'x', 'y', 'z',
46
- 'width', 'height', 'depth', 'weight'
47
- ]);
48
- }
49
39
  function pick_container_contract_keys(source) {
50
- const picked = pick_keys(source, ['sequence', 'width', 'height', 'length']);
40
+ const picked = pick_keys(source, CONTAINER_CONTRACT_KEYS);
51
41
  if (Array.isArray(source.items)) {
52
42
  picked.items = source.items;
53
43
  }
44
+ const attributes = omit_keys(source, [...CONTAINER_CONTRACT_KEYS, 'items']);
45
+ if (Object.keys(attributes).length > 0) {
46
+ picked.attributes = attributes;
47
+ }
54
48
  return picked;
55
49
  }
56
50
  function pick_env_contract_keys(source) {
57
- const picked = pick_keys(source, ['axles']);
51
+ const picked = pick_keys(source, ENV_CONTRACT_KEYS);
58
52
  if (Array.isArray(source.containers)) {
59
53
  picked.containers = source.containers;
60
54
  }
55
+ const vehicle = omit_keys(source, [...ENV_CONTRACT_KEYS, 'containers']);
56
+ if (Object.keys(vehicle).length > 0) {
57
+ picked.vehicle = vehicle;
58
+ }
61
59
  return picked;
62
60
  }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Maps a cargo-movement wire item to the stabilizer contract shape.
3
+ *
4
+ * Contract fields are read from the wire rather than renamed, because a CM item
5
+ * can carry both spellings of the same field (`_id` and `item_id`) and renaming
6
+ * makes one silently overwrite the other. The whole original record is kept in
7
+ * `attributes` so every allocation field survives the round-trip.
8
+ * @param value - Raw wire item.
9
+ * @returns Contract item, or the input unchanged when it is not a record.
10
+ */
11
+ export declare function map_wire_item_to_contract(value: unknown): unknown;
12
+ //# sourceMappingURL=map_wire_item_to_contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map_wire_item_to_contract.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/map_wire_item_to_contract.ts"],"names":[],"mappings":"AAMA;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAcjE"}
@@ -0,0 +1,49 @@
1
+ import { ITEM_CONTRACT_WIRE_KEYS, ITEM_POSITION_KEYS } from './cargo_movement_wire_field_map.js';
2
+ import { is_record, omit_keys, read_first_present } from './wire_mapper_record_utils.js';
3
+ /**
4
+ * Maps a cargo-movement wire item to the stabilizer contract shape.
5
+ *
6
+ * Contract fields are read from the wire rather than renamed, because a CM item
7
+ * can carry both spellings of the same field (`_id` and `item_id`) and renaming
8
+ * makes one silently overwrite the other. The whole original record is kept in
9
+ * `attributes` so every allocation field survives the round-trip.
10
+ * @param value - Raw wire item.
11
+ * @returns Contract item, or the input unchanged when it is not a record.
12
+ */
13
+ export function map_wire_item_to_contract(value) {
14
+ if (!is_record(value)) {
15
+ return value;
16
+ }
17
+ const contract = read_contract_item_fields(value);
18
+ const attributes = omit_keys(value, ITEM_POSITION_KEYS);
19
+ if (Object.keys(attributes).length > 0) {
20
+ contract.attributes = attributes;
21
+ }
22
+ return contract;
23
+ }
24
+ function read_contract_item_fields(source) {
25
+ const contract = {
26
+ x: source.x,
27
+ y: source.y,
28
+ z: source.z
29
+ };
30
+ for (const [contract_key, wire_keys] of Object.entries(ITEM_CONTRACT_WIRE_KEYS)) {
31
+ const value = read_first_present(source, wire_keys);
32
+ if (value !== undefined) {
33
+ contract[contract_key] = normalize_contract_field(contract_key, value);
34
+ }
35
+ }
36
+ return contract;
37
+ }
38
+ /**
39
+ * Coerces blocks-wall numeric group ids to the string contract type.
40
+ * @param contract_key - English contract field name.
41
+ * @param value - Wire value.
42
+ * @returns String group id when a finite number was provided; otherwise the value.
43
+ */
44
+ function normalize_contract_field(contract_key, value) {
45
+ if (contract_key === 'group_id' && typeof value === 'number' && Number.isFinite(value)) {
46
+ return String(value);
47
+ }
48
+ return value;
49
+ }
@@ -23,10 +23,13 @@ export declare function safe_parse_stabilizer_input(input_data: unknown): import
23
23
  group_id?: string | null | undefined;
24
24
  waypoint_id?: string | undefined;
25
25
  weight?: number | undefined;
26
+ attributes?: Record<string, unknown> | undefined;
26
27
  }[];
27
28
  sequence?: number | undefined;
29
+ attributes?: Record<string, unknown> | undefined;
28
30
  }[];
29
31
  axles?: Record<string, unknown>[] | undefined;
32
+ vehicle?: Record<string, unknown> | undefined;
30
33
  }[];
31
34
  config?: Record<string, unknown> | undefined;
32
35
  };
@@ -1 +1 @@
1
- {"version":3,"file":"parse_stabilizer_input.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/parse_stabilizer_input.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAA2B,KAAK,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAE5F;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAI9D;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,OAAO,GAAG,eAAe,CAS3E;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
1
+ {"version":3,"file":"parse_stabilizer_input.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/parse_stabilizer_input.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAA2B,KAAK,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAE5F;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAI9D;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,OAAO,GAAG,eAAe,CAS3E;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
@@ -24,10 +24,13 @@ export declare function safe_parse_stabilizer_output(output_data: unknown): impo
24
24
  group_id?: string | null | undefined;
25
25
  waypoint_id?: string | undefined;
26
26
  weight?: number | undefined;
27
+ attributes?: Record<string, unknown> | undefined;
27
28
  }[];
28
29
  sequence?: number | undefined;
30
+ attributes?: Record<string, unknown> | undefined;
29
31
  }[];
30
32
  axles?: Record<string, unknown>[] | undefined;
33
+ vehicle?: Record<string, unknown> | undefined;
31
34
  }[];
32
35
  config?: Record<string, unknown> | undefined;
33
36
  };
@@ -1 +1 @@
1
- {"version":3,"file":"parse_stabilizer_output.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/parse_stabilizer_output.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAEH,KAAK,kBAAkB,EAC1B,MAAM,+BAA+B,CAAA;AAEtC;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAGhE;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,OAAO,GAAG,kBAAkB,CAShF;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
1
+ {"version":3,"file":"parse_stabilizer_output.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/parse_stabilizer_output.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAEH,KAAK,kBAAkB,EAC1B,MAAM,+BAA+B,CAAA;AAEtC;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAGhE;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,OAAO,GAAG,kBAAkB,CAShF;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
@@ -10,6 +10,7 @@ export declare const stabilizer_item_schema: z.ZodObject<{
10
10
  height: z.ZodNumber;
11
11
  depth: z.ZodNumber;
12
12
  weight: z.ZodOptional<z.ZodNumber>;
13
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
13
14
  }, z.core.$strict>;
14
15
  export declare const stabilizer_container_schema: z.ZodObject<{
15
16
  sequence: z.ZodOptional<z.ZodNumber>;
@@ -27,7 +28,9 @@ export declare const stabilizer_container_schema: z.ZodObject<{
27
28
  height: z.ZodNumber;
28
29
  depth: z.ZodNumber;
29
30
  weight: z.ZodOptional<z.ZodNumber>;
31
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
30
32
  }, z.core.$strict>>;
33
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
31
34
  }, z.core.$strict>;
32
35
  export declare const stabilizer_env_schema: z.ZodObject<{
33
36
  containers: z.ZodArray<z.ZodObject<{
@@ -46,9 +49,12 @@ export declare const stabilizer_env_schema: z.ZodObject<{
46
49
  height: z.ZodNumber;
47
50
  depth: z.ZodNumber;
48
51
  weight: z.ZodOptional<z.ZodNumber>;
52
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
49
53
  }, z.core.$strict>>;
54
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
50
55
  }, z.core.$strict>>;
51
56
  axles: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
57
+ vehicle: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
52
58
  }, z.core.$strict>;
53
59
  export declare const stabilizer_cargo_state_schema: z.ZodObject<{
54
60
  envs: z.ZodArray<z.ZodObject<{
@@ -68,9 +74,12 @@ export declare const stabilizer_cargo_state_schema: z.ZodObject<{
68
74
  height: z.ZodNumber;
69
75
  depth: z.ZodNumber;
70
76
  weight: z.ZodOptional<z.ZodNumber>;
77
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
71
78
  }, z.core.$strict>>;
79
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
72
80
  }, z.core.$strict>>;
73
81
  axles: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
82
+ vehicle: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
74
83
  }, z.core.$strict>>;
75
84
  config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
76
85
  }, z.core.$strict>;
@@ -1 +1 @@
1
- {"version":3,"file":"stabilizer_domain_schema.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/stabilizer_domain_schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,sBAAsB;;;;;;;;;;;kBAWxB,CAAA;AAEX,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;kBAM7B,CAAA;AAEX,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;kBAGvB,CAAA;AAEX,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;kBAG/B,CAAA;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AACnE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAC7E,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AACjE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AAEhF;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,oBAAoB,GAAG,IAAI,CAKtF;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC1C,WAAW,EAAE,oBAAoB,EACjC,OAAO,EAAE,CAAC,CAAC,aAAa,GACzB,IAAI,CAqBN"}
1
+ {"version":3,"file":"stabilizer_domain_schema.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/stabilizer_domain_schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;kBAYxB,CAAA;AAEX,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;kBAO7B,CAAA;AAEX,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;kBAIvB,CAAA;AAEX,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;kBAG/B,CAAA;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AACnE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAC7E,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AACjE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AAEhF;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,oBAAoB,GAAG,IAAI,CAKtF;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC1C,WAAW,EAAE,oBAAoB,EACjC,OAAO,EAAE,CAAC,CAAC,aAAa,GACzB,IAAI,CAqBN"}
@@ -11,18 +11,21 @@ export const stabilizer_item_schema = z.object({
11
11
  width: z.number().positive(),
12
12
  height: z.number().positive(),
13
13
  depth: z.number().positive(),
14
- weight: z.number().optional()
14
+ weight: z.number().optional(),
15
+ attributes: z.record(z.string(), z.unknown()).optional()
15
16
  }).strict();
16
17
  export const stabilizer_container_schema = z.object({
17
18
  sequence: z.number().optional(),
18
19
  width: z.number().positive(),
19
20
  height: z.number().positive(),
20
21
  length: z.number().positive(),
21
- items: z.array(stabilizer_item_schema)
22
+ items: z.array(stabilizer_item_schema),
23
+ attributes: z.record(z.string(), z.unknown()).optional()
22
24
  }).strict();
23
25
  export const stabilizer_env_schema = z.object({
24
26
  containers: z.array(stabilizer_container_schema).min(1),
25
- axles: z.array(z.record(z.string(), z.unknown())).optional()
27
+ axles: z.array(z.record(z.string(), z.unknown())).optional(),
28
+ vehicle: z.record(z.string(), z.unknown()).optional()
26
29
  }).strict();
27
30
  export const stabilizer_cargo_state_schema = z.object({
28
31
  envs: z.array(stabilizer_env_schema).min(1),
@@ -20,9 +20,12 @@ export declare const stabilizer_input_schema: z.ZodObject<{
20
20
  height: z.ZodNumber;
21
21
  depth: z.ZodNumber;
22
22
  weight: z.ZodOptional<z.ZodNumber>;
23
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
23
24
  }, z.core.$strict>>;
25
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
24
26
  }, z.core.$strict>>;
25
27
  axles: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
28
+ vehicle: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
26
29
  }, z.core.$strict>>;
27
30
  config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
28
31
  }, z.core.$strict>;
@@ -1 +1 @@
1
- {"version":3,"file":"stabilizer_input_schema.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/stabilizer_input_schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBASlC,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA"}
1
+ {"version":3,"file":"stabilizer_input_schema.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/stabilizer_input_schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBASlC,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA"}
@@ -19,9 +19,12 @@ export declare const stabilizer_success_response_schema: z.ZodObject<{
19
19
  height: z.ZodNumber;
20
20
  depth: z.ZodNumber;
21
21
  weight: z.ZodOptional<z.ZodNumber>;
22
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
22
23
  }, z.core.$strict>>;
24
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
23
25
  }, z.core.$strict>>;
24
26
  axles: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
27
+ vehicle: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
25
28
  }, z.core.$strict>>;
26
29
  config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
27
30
  }, z.core.$strict>;
@@ -52,9 +55,12 @@ export declare const stabilizer_response_schema: z.ZodDiscriminatedUnion<[z.ZodO
52
55
  height: z.ZodNumber;
53
56
  depth: z.ZodNumber;
54
57
  weight: z.ZodOptional<z.ZodNumber>;
58
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
55
59
  }, z.core.$strict>>;
60
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
56
61
  }, z.core.$strict>>;
57
62
  axles: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
63
+ vehicle: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
58
64
  }, z.core.$strict>>;
59
65
  config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
60
66
  }, z.core.$strict>;
@@ -1 +1 @@
1
- {"version":3,"file":"stabilizer_output_schema.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/stabilizer_output_schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAIpC,CAAA;AAEX,eAAO,MAAM,gCAAgC;;;;kBAIlC,CAAA;AAEX,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAGrC,CAAA;AAEF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAA;AAC1F,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AACtF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA"}
1
+ {"version":3,"file":"stabilizer_output_schema.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/stabilizer_output_schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAIpC,CAAA;AAEX,eAAO,MAAM,gCAAgC;;;;kBAIlC,CAAA;AAEX,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAGrC,CAAA;AAEF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAA;AAC1F,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AACtF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA"}
@@ -17,4 +17,18 @@ export declare function rename_keys(source: Record<string, unknown>, key_map: Re
17
17
  * @returns Filtered record.
18
18
  */
19
19
  export declare function pick_keys(source: Record<string, unknown>, allowed_keys: string[]): Record<string, unknown>;
20
+ /**
21
+ * Reads the value of the first candidate key present on the record.
22
+ * @param source - Source record.
23
+ * @param candidate_keys - Candidate keys in precedence order.
24
+ * @returns Value of the first present key, or undefined when none is present.
25
+ */
26
+ export declare function read_first_present(source: Record<string, unknown>, candidate_keys: readonly string[]): unknown;
27
+ /**
28
+ * Keeps every defined key except the excluded ones.
29
+ * @param source - Source record.
30
+ * @param excluded_keys - Keys to drop.
31
+ * @returns Filtered record.
32
+ */
33
+ export declare function omit_keys(source: Record<string, unknown>, excluded_keys: string[]): Record<string, unknown>;
20
34
  //# sourceMappingURL=wire_mapper_record_utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wire_mapper_record_utils.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/wire_mapper_record_utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAG1E;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASzB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,YAAY,EAAE,MAAM,EAAE,GACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWzB"}
1
+ {"version":3,"file":"wire_mapper_record_utils.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/wire_mapper_record_utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAG1E;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASzB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,YAAY,EAAE,MAAM,EAAE,GACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWzB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,cAAc,EAAE,SAAS,MAAM,EAAE,GAClC,OAAO,CAUT;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,aAAa,EAAE,MAAM,EAAE,GACxB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYzB"}
@@ -34,3 +34,33 @@ export function pick_keys(source, allowed_keys) {
34
34
  }
35
35
  return picked;
36
36
  }
37
+ /**
38
+ * Reads the value of the first candidate key present on the record.
39
+ * @param source - Source record.
40
+ * @param candidate_keys - Candidate keys in precedence order.
41
+ * @returns Value of the first present key, or undefined when none is present.
42
+ */
43
+ export function read_first_present(source, candidate_keys) {
44
+ for (const key of candidate_keys) {
45
+ if (Object.hasOwn(source, key)) {
46
+ return source[key];
47
+ }
48
+ }
49
+ return undefined;
50
+ }
51
+ /**
52
+ * Keeps every defined key except the excluded ones.
53
+ * @param source - Source record.
54
+ * @param excluded_keys - Keys to drop.
55
+ * @returns Filtered record.
56
+ */
57
+ export function omit_keys(source, excluded_keys) {
58
+ const kept = {};
59
+ for (const [key, value] of Object.entries(source)) {
60
+ if (excluded_keys.includes(key) || value === undefined) {
61
+ continue;
62
+ }
63
+ kept[key] = value;
64
+ }
65
+ return kept;
66
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetta/cargo-stabilizer",
3
- "version": "0.1.0-5",
3
+ "version": "0.1.0-7",
4
4
  "description": "Stable loose-item reorder library for cargo-movement (JET-2262)",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",