@jetta/cargo-stabilizer 0.1.0-12 → 0.1.0-15

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 (134) hide show
  1. package/CHANGELOG.md +11 -2
  2. package/README.md +15 -10
  3. package/build/core/adapters/axle_adapter.d.ts +1 -0
  4. package/build/core/adapters/axle_adapter.d.ts.map +1 -1
  5. package/build/core/adapters/axle_adapter.js +3 -22
  6. package/build/core/adapters/axle_load_evaluation.d.ts +8 -0
  7. package/build/core/adapters/axle_load_evaluation.d.ts.map +1 -0
  8. package/build/core/adapters/axle_load_evaluation.js +1 -0
  9. package/build/core/adapters/build_axle_request.d.ts +2 -9
  10. package/build/core/adapters/build_axle_request.d.ts.map +1 -1
  11. package/build/core/adapters/build_axle_request.js +52 -24
  12. package/build/core/adapters/compute_axle_excess_kg.d.ts +8 -0
  13. package/build/core/adapters/compute_axle_excess_kg.d.ts.map +1 -0
  14. package/build/core/adapters/compute_axle_excess_kg.js +19 -0
  15. package/build/core/adapters/coordinate_mapper.d.ts +1 -1
  16. package/build/core/adapters/coordinate_mapper.js +3 -3
  17. package/build/core/adapters/evaluate_axle_load.d.ts +10 -0
  18. package/build/core/adapters/evaluate_axle_load.d.ts.map +1 -0
  19. package/build/core/adapters/evaluate_axle_load.js +32 -0
  20. package/build/core/adapters/map_item_to_stacking_item.d.ts +14 -0
  21. package/build/core/adapters/map_item_to_stacking_item.d.ts.map +1 -0
  22. package/build/core/adapters/map_item_to_stacking_item.js +40 -0
  23. package/build/core/adapters/run_axle_calculator.d.ts.map +1 -1
  24. package/build/core/adapters/run_axle_calculator.js +21 -16
  25. package/build/core/candidates/candidate_validation.d.ts.map +1 -1
  26. package/build/core/candidates/candidate_validation.js +4 -0
  27. package/build/core/candidates/is_candidate_stacking_valid.d.ts +14 -0
  28. package/build/core/candidates/is_candidate_stacking_valid.d.ts.map +1 -0
  29. package/build/core/candidates/is_candidate_stacking_valid.js +43 -0
  30. package/build/core/evaluation/compare_search_states.d.ts +12 -0
  31. package/build/core/evaluation/compare_search_states.d.ts.map +1 -0
  32. package/build/core/evaluation/compare_search_states.js +12 -0
  33. package/build/core/evaluation/evaluate_search_gates.d.ts +18 -0
  34. package/build/core/evaluation/evaluate_search_gates.d.ts.map +1 -0
  35. package/build/core/evaluation/evaluate_search_gates.js +30 -0
  36. package/build/core/evaluation/evaluation_result.d.ts +15 -0
  37. package/build/core/evaluation/evaluation_result.d.ts.map +1 -0
  38. package/build/core/evaluation/evaluation_result.js +1 -0
  39. package/build/core/evaluation/genetic_fitness.d.ts +9 -0
  40. package/build/core/evaluation/genetic_fitness.d.ts.map +1 -0
  41. package/build/core/evaluation/genetic_fitness.js +16 -0
  42. package/build/core/evaluation/is_non_axle_gates_pass.d.ts +8 -0
  43. package/build/core/evaluation/is_non_axle_gates_pass.d.ts.map +1 -0
  44. package/build/core/evaluation/is_non_axle_gates_pass.js +8 -0
  45. package/build/core/evaluation/is_search_trial_admissible.d.ts +10 -0
  46. package/build/core/evaluation/is_search_trial_admissible.d.ts.map +1 -0
  47. package/build/core/evaluation/is_search_trial_admissible.js +17 -0
  48. package/build/core/evaluation/is_waypoint_order_valid.d.ts +10 -0
  49. package/build/core/evaluation/is_waypoint_order_valid.d.ts.map +1 -0
  50. package/build/core/evaluation/is_waypoint_order_valid.js +14 -0
  51. package/build/core/evaluation/state_evaluator.d.ts +2 -10
  52. package/build/core/evaluation/state_evaluator.d.ts.map +1 -1
  53. package/build/core/evaluation/state_evaluator.js +6 -26
  54. package/build/core/factory/read_stabilizer_config.d.ts +3 -2
  55. package/build/core/factory/read_stabilizer_config.d.ts.map +1 -1
  56. package/build/core/factory/read_stabilizer_config_helpers.d.ts +5 -2
  57. package/build/core/factory/read_stabilizer_config_helpers.d.ts.map +1 -1
  58. package/build/core/filters/collect_pinned_floor_tie_ratio_group_ids.js +1 -1
  59. package/build/core/filters/is_item_on_cm_floor.d.ts +2 -2
  60. package/build/core/filters/is_item_on_cm_floor.js +3 -3
  61. package/build/core/geometry/has_penetrating_overlap.d.ts +2 -2
  62. package/build/core/geometry/has_penetrating_overlap.d.ts.map +1 -1
  63. package/build/core/geometry/has_penetrating_overlap.js +6 -6
  64. package/build/core/orchestration/StabilizerFlow.d.ts.map +1 -1
  65. package/build/core/orchestration/StabilizerFlow.js +1 -1
  66. package/build/core/strategies/reorder/BeamSearchReorder.d.ts.map +1 -1
  67. package/build/core/strategies/reorder/BeamSearchReorder.js +8 -10
  68. package/build/core/strategies/reorder/GeneticReorder.d.ts.map +1 -1
  69. package/build/core/strategies/reorder/GeneticReorder.js +2 -1
  70. package/build/core/strategies/reorder/SimulatedAnnealingReorder.d.ts.map +1 -1
  71. package/build/core/strategies/reorder/SimulatedAnnealingReorder.js +14 -5
  72. package/build/core/strategies/reorder/append_admitted_trial.d.ts +11 -0
  73. package/build/core/strategies/reorder/append_admitted_trial.d.ts.map +1 -0
  74. package/build/core/strategies/reorder/append_admitted_trial.js +22 -0
  75. package/build/core/strategies/reorder/beam_context.d.ts +1 -0
  76. package/build/core/strategies/reorder/beam_context.d.ts.map +1 -1
  77. package/build/core/strategies/reorder/greedy_improvement.d.ts.map +1 -1
  78. package/build/core/strategies/reorder/greedy_improvement.js +3 -2
  79. package/build/core/strategies/reorder/is_improving_greedy_trial.d.ts +10 -0
  80. package/build/core/strategies/reorder/is_improving_greedy_trial.d.ts.map +1 -0
  81. package/build/core/strategies/reorder/is_improving_greedy_trial.js +17 -0
  82. package/build/core/strategies/reorder/select_surviving_beam.d.ts +3 -2
  83. package/build/core/strategies/reorder/select_surviving_beam.d.ts.map +1 -1
  84. package/build/core/strategies/reorder/select_surviving_beam.js +5 -4
  85. package/build/core/validation/contract/cargo_movement_wire_field_map.d.ts +37 -3
  86. package/build/core/validation/contract/cargo_movement_wire_field_map.d.ts.map +1 -1
  87. package/build/core/validation/contract/cargo_movement_wire_field_map.js +40 -6
  88. package/build/core/validation/contract/cargo_movement_wire_mapper.d.ts.map +1 -1
  89. package/build/core/validation/contract/cargo_movement_wire_mapper.js +10 -1
  90. package/build/core/validation/contract/map_contract_to_wire_shape.d.ts.map +1 -1
  91. package/build/core/validation/contract/map_contract_to_wire_shape.js +12 -21
  92. package/build/core/validation/contract/map_input_config.d.ts +9 -0
  93. package/build/core/validation/contract/map_input_config.d.ts.map +1 -0
  94. package/build/core/validation/contract/map_input_config.js +40 -0
  95. package/build/core/validation/contract/map_wire_input_to_contract_shape.d.ts.map +1 -1
  96. package/build/core/validation/contract/map_wire_input_to_contract_shape.js +28 -22
  97. package/build/core/validation/contract/map_wire_item_stacking.d.ts +7 -0
  98. package/build/core/validation/contract/map_wire_item_stacking.d.ts.map +1 -0
  99. package/build/core/validation/contract/map_wire_item_stacking.js +40 -0
  100. package/build/core/validation/contract/map_wire_item_to_contract.d.ts +1 -5
  101. package/build/core/validation/contract/map_wire_item_to_contract.d.ts.map +1 -1
  102. package/build/core/validation/contract/map_wire_item_to_contract.js +16 -14
  103. package/build/core/validation/contract/parse_stabilizer_input.d.ts +49 -7
  104. package/build/core/validation/contract/parse_stabilizer_input.d.ts.map +1 -1
  105. package/build/core/validation/contract/parse_stabilizer_input.js +2 -0
  106. package/build/core/validation/contract/parse_stabilizer_output.d.ts +34 -5
  107. package/build/core/validation/contract/parse_stabilizer_output.d.ts.map +1 -1
  108. package/build/core/validation/contract/reject_forbidden_input_fields.d.ts +6 -0
  109. package/build/core/validation/contract/reject_forbidden_input_fields.d.ts.map +1 -0
  110. package/build/core/validation/contract/reject_forbidden_input_fields.js +53 -0
  111. package/build/core/validation/contract/stabilizer_domain_schema.d.ts +36 -65
  112. package/build/core/validation/contract/stabilizer_domain_schema.d.ts.map +1 -1
  113. package/build/core/validation/contract/stabilizer_domain_schema.js +16 -38
  114. package/build/core/validation/contract/stabilizer_env_schema.d.ts +112 -0
  115. package/build/core/validation/contract/stabilizer_env_schema.d.ts.map +1 -0
  116. package/build/core/validation/contract/stabilizer_env_schema.js +38 -0
  117. package/build/core/validation/contract/stabilizer_input_schema.d.ts +51 -7
  118. package/build/core/validation/contract/stabilizer_input_schema.d.ts.map +1 -1
  119. package/build/core/validation/contract/stabilizer_input_schema.js +2 -2
  120. package/build/core/validation/contract/stabilizer_item_schema.d.ts +25 -0
  121. package/build/core/validation/contract/stabilizer_item_schema.d.ts.map +1 -0
  122. package/build/core/validation/contract/stabilizer_item_schema.js +23 -0
  123. package/build/core/validation/contract/stabilizer_output_schema.d.ts +68 -10
  124. package/build/core/validation/contract/stabilizer_output_schema.d.ts.map +1 -1
  125. package/build/core/validation/contract/uniquify_contract_item_ids.d.ts +14 -0
  126. package/build/core/validation/contract/uniquify_contract_item_ids.d.ts.map +1 -0
  127. package/build/core/validation/contract/uniquify_contract_item_ids.js +54 -0
  128. package/build/core/validation/schemas/stabilizer_config_schema.d.ts +1 -1
  129. package/build/core/validation/schemas/stabilizer_config_schema.d.ts.map +1 -1
  130. package/build/core/validation/schemas/stabilizer_config_schema.js +1 -1
  131. package/build/index.d.ts +11 -12
  132. package/build/index.d.ts.map +1 -1
  133. package/build/index.js +29 -21
  134. package/package.json +12 -10
@@ -12,5 +12,6 @@ export interface BeamExpansionContext {
12
12
  export interface BeamState {
13
13
  containers: StabilizerContainer[];
14
14
  objective: number;
15
+ axle_excess_kg: number;
15
16
  }
16
17
  //# sourceMappingURL=beam_context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"beam_context.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/beam_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAA;AAChG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AACtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAA;AAEpF,MAAM,WAAW,oBAAoB;IAEjC,OAAO,EAAE,cAAc,CAAA;IACvB,UAAU,EAAE,sBAAsB,CAAA;IAClC,QAAQ,EAAE,SAAS,EAAE,CAAA;IACrB,KAAK,EAAE,SAAS,CAAA;IAChB,KAAK,EAAE,YAAY,CAAA;CACtB;AAED,MAAM,WAAW,SAAS;IAEtB,UAAU,EAAE,mBAAmB,EAAE,CAAA;IACjC,SAAS,EAAE,MAAM,CAAA;CACpB"}
1
+ {"version":3,"file":"beam_context.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/beam_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAA;AAChG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AACtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAA;AAEpF,MAAM,WAAW,oBAAoB;IAEjC,OAAO,EAAE,cAAc,CAAA;IACvB,UAAU,EAAE,sBAAsB,CAAA;IAClC,QAAQ,EAAE,SAAS,EAAE,CAAA;IACrB,KAAK,EAAE,SAAS,CAAA;IAChB,KAAK,EAAE,YAAY,CAAA;CACtB;AAED,MAAM,WAAW,SAAS;IAEtB,UAAU,EAAE,mBAAmB,EAAE,CAAA;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;CACzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"greedy_improvement.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/greedy_improvement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAA;AAEhG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAA;AAepF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAC/B,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,mBAAmB,EAAE,EAC9B,YAAY,EAAE,sBAAsB,GACrC,OAAO,CAiBT"}
1
+ {"version":3,"file":"greedy_improvement.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/greedy_improvement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAA;AAEhG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAA;AAiBpF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAC/B,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,mBAAmB,EAAE,EAC9B,YAAY,EAAE,sBAAsB,GACrC,OAAO,CAiBT"}
@@ -2,6 +2,7 @@ import { generate_candidates } from '../../candidates/candidate_generator.js';
2
2
  import { candidate_context_for_loose } from '../../candidates/build_candidate_context.js';
3
3
  import { apply_move, clone_containers } from '../../move/apply_move.js';
4
4
  import { evaluate_trial_layout } from '../../evaluation/state_evaluator.js';
5
+ import { is_improving_greedy_trial } from './is_improving_greedy_trial.js';
5
6
  /**
6
7
  * Attempts one greedy improvement on the worst loose item.
7
8
  * @param context - Reorder context.
@@ -21,7 +22,7 @@ export function improve_worst_loose(context, working, eval_context) {
21
22
  working,
22
23
  evaluation: eval_context,
23
24
  loose: worst,
24
- baseline_objective: current_eval.objective
25
+ parent_eval: current_eval
25
26
  });
26
27
  }
27
28
  function try_candidate_moves(move_context) {
@@ -37,7 +38,7 @@ function apply_improving_candidate(move_context, candidate) {
37
38
  const trial = clone_containers(move_context.working);
38
39
  apply_move(trial, candidate);
39
40
  const trial_eval = evaluate_trial_layout(trial, move_context.evaluation);
40
- if (!trial_eval.all_gates_pass || trial_eval.objective <= move_context.baseline_objective) {
41
+ if (!is_improving_greedy_trial(move_context.parent_eval, trial_eval)) {
41
42
  return false;
42
43
  }
43
44
  apply_move(move_context.working, candidate);
@@ -0,0 +1,10 @@
1
+ import type { EvaluationResult } from '../../evaluation/evaluation_result.js';
2
+ /**
3
+ * Returns true when a greedy trial improves the parent layout.
4
+ * Over parents climb on axle excess; legal parents require a better objective.
5
+ * @param parent_eval - Parent evaluation.
6
+ * @param trial_eval - Trial evaluation.
7
+ * @returns True when the trial should be applied.
8
+ */
9
+ export declare function is_improving_greedy_trial(parent_eval: EvaluationResult, trial_eval: EvaluationResult): boolean;
10
+ //# sourceMappingURL=is_improving_greedy_trial.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is_improving_greedy_trial.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/is_improving_greedy_trial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAA;AAG7E;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACrC,WAAW,EAAE,gBAAgB,EAC7B,UAAU,EAAE,gBAAgB,GAC7B,OAAO,CAWT"}
@@ -0,0 +1,17 @@
1
+ import { is_search_trial_admissible } from '../../evaluation/is_search_trial_admissible.js';
2
+ /**
3
+ * Returns true when a greedy trial improves the parent layout.
4
+ * Over parents climb on axle excess; legal parents require a better objective.
5
+ * @param parent_eval - Parent evaluation.
6
+ * @param trial_eval - Trial evaluation.
7
+ * @returns True when the trial should be applied.
8
+ */
9
+ export function is_improving_greedy_trial(parent_eval, trial_eval) {
10
+ if (!is_search_trial_admissible(parent_eval, trial_eval)) {
11
+ return false;
12
+ }
13
+ if (!parent_eval.axle_valid) {
14
+ return true;
15
+ }
16
+ return trial_eval.objective > parent_eval.objective;
17
+ }
@@ -1,7 +1,8 @@
1
1
  import type { BeamState } from './beam_context.js';
2
2
  /**
3
- * Keeps ranked expansions, or the parent beam when every trial failed the gates.
4
- * @param expanded - Trial states that passed gates.
3
+ * Keeps ranked expansions, or the parent beam when every trial failed admission.
4
+ * Ranks by axle excess then stability objective.
5
+ * @param expanded - Trial states that passed search admission.
5
6
  * @param parent_beam - Beam states before this item's expansion.
6
7
  * @param beam_width - Maximum states to keep.
7
8
  * @returns Next beam, never empty when the parent beam had states.
@@ -1 +1 @@
1
- {"version":3,"file":"select_surviving_beam.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/select_surviving_beam.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAElD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACjC,QAAQ,EAAE,SAAS,EAAE,EACrB,WAAW,EAAE,SAAS,EAAE,EACxB,UAAU,EAAE,MAAM,GACnB,SAAS,EAAE,CAKb"}
1
+ {"version":3,"file":"select_surviving_beam.d.ts","sourceRoot":"","sources":["../../../../src/core/strategies/reorder/select_surviving_beam.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAGlD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACjC,QAAQ,EAAE,SAAS,EAAE,EACrB,WAAW,EAAE,SAAS,EAAE,EACxB,UAAU,EAAE,MAAM,GACnB,SAAS,EAAE,CAIb"}
@@ -1,12 +1,13 @@
1
+ import { compare_search_states } from '../../evaluation/compare_search_states.js';
1
2
  /**
2
- * Keeps ranked expansions, or the parent beam when every trial failed the gates.
3
- * @param expanded - Trial states that passed gates.
3
+ * Keeps ranked expansions, or the parent beam when every trial failed admission.
4
+ * Ranks by axle excess then stability objective.
5
+ * @param expanded - Trial states that passed search admission.
4
6
  * @param parent_beam - Beam states before this item's expansion.
5
7
  * @param beam_width - Maximum states to keep.
6
8
  * @returns Next beam, never empty when the parent beam had states.
7
9
  */
8
10
  export function select_surviving_beam(expanded, parent_beam, beam_width) {
9
- const ranked = [...parent_beam, ...expanded]
10
- .sort((left, right) => right.objective - left.objective);
11
+ const ranked = [...parent_beam, ...expanded].sort(compare_search_states);
11
12
  return ranked.slice(0, beam_width);
12
13
  }
@@ -7,9 +7,7 @@ export declare const ITEM_WIRE_TO_CONTRACT: {
7
7
  };
8
8
  /**
9
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.
10
+ * order. Only modelled stabilizer and dependency fields are read.
13
11
  */
14
12
  export declare const ITEM_CONTRACT_WIRE_KEYS: Readonly<{
15
13
  item_id: string[];
@@ -19,6 +17,16 @@ export declare const ITEM_CONTRACT_WIRE_KEYS: Readonly<{
19
17
  height: string[];
20
18
  depth: string[];
21
19
  weight: string[];
20
+ tie_ratio_orientation: string[];
21
+ family: string[];
22
+ supported_families: string[];
23
+ constraint: string[];
24
+ stack_families: string[];
25
+ stack_same_item: string[];
26
+ stack_same_area: string[];
27
+ stacking_unit: string[];
28
+ supported_weight: string[];
29
+ priority: string[];
22
30
  }>;
23
31
  /** Item fields the stabilizer mutates, and therefore must emit itself. */
24
32
  export declare const ITEM_POSITION_KEYS: string[];
@@ -27,6 +35,30 @@ export declare const CONTAINER_WIRE_TO_CONTRACT: {
27
35
  readonly largura: "width";
28
36
  readonly altura: "height";
29
37
  readonly comprimento: "length";
38
+ readonly distPinoRei: "kingpin_distance";
39
+ readonly containerDistanceAhead: "container_distance_ahead";
40
+ readonly pesoMaxSuportado: "max_supported_weight";
41
+ readonly tara: "tare";
42
+ readonly pesoDeCarga: "cargo_weight";
43
+ readonly grouper: "grouper";
44
+ };
45
+ export declare const VEHICLE_WIRE_TO_CONTRACT: {
46
+ readonly _id: "vehicle_id";
47
+ readonly tipoVeiculo: "vehicle_type";
48
+ readonly tipoVersao: "version_type";
49
+ readonly tipoSuspensao: "suspension_type";
50
+ readonly primeiroEixo: "first_axle";
51
+ readonly tara: "tare";
52
+ readonly pesoMaxSuportado: "max_supported_weight";
53
+ readonly qtd: "quantity";
54
+ };
55
+ export declare const AXLE_WIRE_TO_CONTRACT: {
56
+ readonly distanciaOrigem: "distance_from_origin";
57
+ readonly pesoMaxSuportado: "max_supported_weight";
58
+ readonly pesoDnit: "dnit_weight";
59
+ readonly tara: "tare";
60
+ readonly sequenciaContainer: "container_sequence";
61
+ readonly sequence: "sequence";
30
62
  };
31
63
  export declare const ENV_WIRE_TO_CONTRACT: {
32
64
  readonly eixos: "axles";
@@ -34,4 +66,6 @@ export declare const ENV_WIRE_TO_CONTRACT: {
34
66
  export declare const CONTRACT_TO_ITEM_WIRE: Record<string, string>;
35
67
  export declare const CONTRACT_TO_CONTAINER_WIRE: Record<string, string>;
36
68
  export declare const CONTRACT_TO_ENV_WIRE: Record<string, string>;
69
+ export declare const CONTRACT_TO_VEHICLE_WIRE: Record<string, string>;
70
+ export declare const CONTRACT_TO_AXLE_WIRE: Record<string, string>;
37
71
  //# sourceMappingURL=cargo_movement_wire_field_map.d.ts.map
@@ -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;;;;;;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"}
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;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;EAkBlC,CAAA;AAEF,0EAA0E;AAC1E,eAAO,MAAM,kBAAkB,UAAkB,CAAA;AAEjD,eAAO,MAAM,0BAA0B;;;;;;;;;;;CAW7B,CAAA;AAEV,eAAO,MAAM,wBAAwB;;;;;;;;;CAS3B,CAAA;AAEV,eAAO,MAAM,qBAAqB;;;;;;;CAOxB,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;AACpE,eAAO,MAAM,wBAAwB,wBAAuC,CAAA;AAC5E,eAAO,MAAM,qBAAqB,wBAAoC,CAAA"}
@@ -7,18 +7,26 @@ export const ITEM_WIRE_TO_CONTRACT = {
7
7
  };
8
8
  /**
9
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.
10
+ * order. Only modelled stabilizer and dependency fields are read.
13
11
  */
14
12
  export const ITEM_CONTRACT_WIRE_KEYS = Object.freeze({
15
- item_id: ['item_id', '_id'],
13
+ item_id: ['_id', 'item_id'],
16
14
  group_id: ['groupId', 'group_id'],
17
15
  waypoint_id: ['waypoint_id'],
18
16
  width: ['w', 'width'],
19
17
  height: ['h', 'height'],
20
18
  depth: ['d', 'depth'],
21
- weight: ['wg', 'peso', 'weight']
19
+ weight: ['wg', 'peso', 'weight'],
20
+ tie_ratio_orientation: ['tie_ratio_orientation'],
21
+ family: ['family'],
22
+ supported_families: ['supported_families'],
23
+ constraint: ['constraint'],
24
+ stack_families: ['stack_families'],
25
+ stack_same_item: ['stack_same_item'],
26
+ stack_same_area: ['stack_same_area'],
27
+ stacking_unit: ['stacking_unit', 'stackingUnit'],
28
+ supported_weight: ['supported_weight', 'pesoMaxSuportado'],
29
+ priority: ['priority']
22
30
  });
23
31
  /** Item fields the stabilizer mutates, and therefore must emit itself. */
24
32
  export const ITEM_POSITION_KEYS = ['x', 'y', 'z'];
@@ -26,7 +34,31 @@ export const CONTAINER_WIRE_TO_CONTRACT = {
26
34
  sequencia: 'sequence',
27
35
  largura: 'width',
28
36
  altura: 'height',
29
- comprimento: 'length'
37
+ comprimento: 'length',
38
+ distPinoRei: 'kingpin_distance',
39
+ containerDistanceAhead: 'container_distance_ahead',
40
+ pesoMaxSuportado: 'max_supported_weight',
41
+ tara: 'tare',
42
+ pesoDeCarga: 'cargo_weight',
43
+ grouper: 'grouper'
44
+ };
45
+ export const VEHICLE_WIRE_TO_CONTRACT = {
46
+ _id: 'vehicle_id',
47
+ tipoVeiculo: 'vehicle_type',
48
+ tipoVersao: 'version_type',
49
+ tipoSuspensao: 'suspension_type',
50
+ primeiroEixo: 'first_axle',
51
+ tara: 'tare',
52
+ pesoMaxSuportado: 'max_supported_weight',
53
+ qtd: 'quantity'
54
+ };
55
+ export const AXLE_WIRE_TO_CONTRACT = {
56
+ distanciaOrigem: 'distance_from_origin',
57
+ pesoMaxSuportado: 'max_supported_weight',
58
+ pesoDnit: 'dnit_weight',
59
+ tara: 'tare',
60
+ sequenciaContainer: 'container_sequence',
61
+ sequence: 'sequence'
30
62
  };
31
63
  export const ENV_WIRE_TO_CONTRACT = {
32
64
  eixos: 'axles'
@@ -34,6 +66,8 @@ export const ENV_WIRE_TO_CONTRACT = {
34
66
  export const CONTRACT_TO_ITEM_WIRE = invert_map(ITEM_WIRE_TO_CONTRACT);
35
67
  export const CONTRACT_TO_CONTAINER_WIRE = invert_map(CONTAINER_WIRE_TO_CONTRACT);
36
68
  export const CONTRACT_TO_ENV_WIRE = invert_map(ENV_WIRE_TO_CONTRACT);
69
+ export const CONTRACT_TO_VEHICLE_WIRE = invert_map(VEHICLE_WIRE_TO_CONTRACT);
70
+ export const CONTRACT_TO_AXLE_WIRE = invert_map(AXLE_WIRE_TO_CONTRACT);
37
71
  function invert_map(source) {
38
72
  const inverted = {};
39
73
  for (const [wire_key, contract_key] of Object.entries(source)) {
@@ -1 +1 @@
1
- {"version":3,"file":"cargo_movement_wire_mapper.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/cargo_movement_wire_mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAOzE;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,OAAO,GAAG,OAAO,CAsBvE;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,oBAAoB,GAAG,OAAO,CAGtF"}
1
+ {"version":3,"file":"cargo_movement_wire_mapper.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/cargo_movement_wire_mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAQzE;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,OAAO,GAAG,OAAO,CAcvE;AAqBD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,oBAAoB,GAAG,OAAO,CAGtF"}
@@ -1,7 +1,8 @@
1
1
  import { map_cargo_state_to_wire } from './map_contract_to_wire_shape.js';
2
2
  import { map_cargo_state_to_contract } from './map_wire_input_to_contract_shape.js';
3
+ import { map_envelope_config } from './map_input_config.js';
3
4
  import { is_record } from './wire_mapper_record_utils.js';
4
- const INPUT_ENVELOPE_KEYS = new Set(['id', 'company', 'cargo_state', 'config', 'original_input']);
5
+ const INPUT_ENVELOPE_KEYS = new Set(['id', 'company', 'cargo_state', 'config']);
5
6
  /**
6
7
  * Maps a cargo-movement wire payload to the English contract shape.
7
8
  * @param input_data - Unknown CM wire payload.
@@ -11,6 +12,14 @@ export function map_wire_input_to_contract(input_data) {
11
12
  if (!is_record(input_data)) {
12
13
  return input_data;
13
14
  }
15
+ const mapped = map_envelope_fields(input_data);
16
+ const mapped_config = map_envelope_config(input_data.config, input_data.cargo_state);
17
+ if (mapped_config !== undefined) {
18
+ mapped.config = mapped_config;
19
+ }
20
+ return mapped;
21
+ }
22
+ function map_envelope_fields(input_data) {
14
23
  const mapped = {};
15
24
  for (const [key, value] of Object.entries(input_data)) {
16
25
  if (!INPUT_ENVELOPE_KEYS.has(key)) {
@@ -1 +1 @@
1
- {"version":3,"file":"map_contract_to_wire_shape.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/map_contract_to_wire_shape.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAGzE,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,oBAAoB,GAAG,OAAO,CAUlF"}
1
+ {"version":3,"file":"map_contract_to_wire_shape.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/map_contract_to_wire_shape.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAIzE,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,oBAAoB,GAAG,OAAO,CAKlF"}
@@ -1,42 +1,33 @@
1
- import { CONTRACT_TO_CONTAINER_WIRE, CONTRACT_TO_ITEM_WIRE } from './cargo_movement_wire_field_map.js';
1
+ import { CONTRACT_TO_AXLE_WIRE, CONTRACT_TO_CONTAINER_WIRE, CONTRACT_TO_ITEM_WIRE, CONTRACT_TO_VEHICLE_WIRE } from './cargo_movement_wire_field_map.js';
2
2
  import { omit_keys, rename_keys } from './wire_mapper_record_utils.js';
3
+ import { strip_uniquify_suffix } from './uniquify_contract_item_ids.js';
3
4
  export function map_cargo_state_to_wire(cargo_state) {
4
- const wire = {
5
+ return {
5
6
  envs: cargo_state.envs.map(map_env_to_wire)
6
7
  };
7
- if (cargo_state.config !== undefined) {
8
- wire.config = cargo_state.config;
9
- }
10
- return wire;
11
8
  }
12
9
  function map_env_to_wire(env) {
13
- const wire = { ...(env.vehicle ?? {}) };
10
+ const wire = env.vehicle === undefined
11
+ ? {}
12
+ : rename_keys(env.vehicle, CONTRACT_TO_VEHICLE_WIRE);
14
13
  wire.containers = env.containers.map(map_container_to_wire);
15
14
  if (env.axles !== undefined) {
16
- wire.eixos = env.axles;
15
+ wire.eixos = env.axles.map(axle => rename_keys(axle, CONTRACT_TO_AXLE_WIRE));
17
16
  }
18
17
  return wire;
19
18
  }
20
19
  function map_container_to_wire(container) {
21
- const modelled = omit_keys(container, ['attributes', 'items']);
22
- const wire = { ...(container.attributes ?? {}) };
23
- Object.assign(wire, rename_keys(modelled, CONTRACT_TO_CONTAINER_WIRE));
20
+ const modelled = omit_keys(container, ['items']);
21
+ const wire = rename_keys(modelled, CONTRACT_TO_CONTAINER_WIRE);
24
22
  wire.items = container.items.map(map_item_to_wire);
25
23
  return wire;
26
24
  }
27
25
  /**
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.
26
+ * Emits a contract item to CM wire keys. Position stays in contract axes
27
+ * for English items; CM `w`-shaped callers swap y/z before parse.
34
28
  * @param item - Contract item.
35
29
  * @returns Wire item.
36
30
  */
37
31
  function map_item_to_wire(item) {
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 };
32
+ return rename_keys({ ...item, item_id: strip_uniquify_suffix(item.item_id) }, CONTRACT_TO_ITEM_WIRE);
42
33
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Maps envelope plus cargo-profile algoritmo maps onto English stabilizer config.
3
+ * English config objects are returned unchanged for strict Zod checking.
4
+ * @param envelope_config - Envelope config from wire or English input.
5
+ * @param wire_cargo_state - Wire cargo state that may hold profile algoritmo.
6
+ * @returns Raw English config, or the original English object.
7
+ */
8
+ export declare function map_envelope_config(envelope_config: unknown, wire_cargo_state: unknown): unknown;
9
+ //# sourceMappingURL=map_input_config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map_input_config.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/map_input_config.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAgBhG"}
@@ -0,0 +1,40 @@
1
+ import { is_record } from './wire_mapper_record_utils.js';
2
+ import { merge_algoritmo_maps, read_raw_stabilizer_config } from '../../factory/read_stabilizer_config_helpers.js';
3
+ const ALGORITMO_PREFIX = 'cargo_stabilizer.';
4
+ /**
5
+ * Maps envelope plus cargo-profile algoritmo maps onto English stabilizer config.
6
+ * English config objects are returned unchanged for strict Zod checking.
7
+ * @param envelope_config - Envelope config from wire or English input.
8
+ * @param wire_cargo_state - Wire cargo state that may hold profile algoritmo.
9
+ * @returns Raw English config, or the original English object.
10
+ */
11
+ export function map_envelope_config(envelope_config, wire_cargo_state) {
12
+ if (envelope_config === undefined && !has_profile_algoritmo(wire_cargo_state)) {
13
+ return undefined;
14
+ }
15
+ if (is_algoritmo_shaped(envelope_config) || has_profile_algoritmo(wire_cargo_state)) {
16
+ return read_raw_stabilizer_config(merge_algoritmo_maps(as_record(envelope_config), { config: read_wire_profile_config(wire_cargo_state) }));
17
+ }
18
+ return envelope_config;
19
+ }
20
+ function is_algoritmo_shaped(config) {
21
+ if (!is_record(config)) {
22
+ return false;
23
+ }
24
+ if (is_record(config.algoritmo)) {
25
+ return true;
26
+ }
27
+ return Object.keys(config).some(key => key.startsWith(ALGORITMO_PREFIX));
28
+ }
29
+ function has_profile_algoritmo(wire_cargo_state) {
30
+ return is_record(read_wire_profile_config(wire_cargo_state)?.algoritmo);
31
+ }
32
+ function read_wire_profile_config(wire_cargo_state) {
33
+ if (!is_record(wire_cargo_state) || !is_record(wire_cargo_state.config)) {
34
+ return undefined;
35
+ }
36
+ return wire_cargo_state.config;
37
+ }
38
+ function as_record(value) {
39
+ return is_record(value) ? value : undefined;
40
+ }
@@ -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":"AAUA,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":"AAkBA,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAYnE"}
@@ -1,16 +1,19 @@
1
- import { CONTAINER_WIRE_TO_CONTRACT, ENV_WIRE_TO_CONTRACT } from './cargo_movement_wire_field_map.js';
1
+ import { AXLE_WIRE_TO_CONTRACT, CONTAINER_WIRE_TO_CONTRACT, ENV_WIRE_TO_CONTRACT, VEHICLE_WIRE_TO_CONTRACT } from './cargo_movement_wire_field_map.js';
2
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
+ import { uniquify_contract_item_ids } from './uniquify_contract_item_ids.js';
4
+ import { is_record, pick_keys, rename_keys } from './wire_mapper_record_utils.js';
5
+ const CONTAINER_CONTRACT_KEYS = [
6
+ 'sequence', 'width', 'height', 'length', 'kingpin_distance',
7
+ 'container_distance_ahead', 'max_supported_weight', 'tare', 'cargo_weight', 'grouper'
8
+ ];
9
+ const ENV_CONTRACT_KEYS = ['axles', 'vehicle'];
10
+ const VEHICLE_CONTRACT_KEYS = Object.values(VEHICLE_WIRE_TO_CONTRACT);
11
+ const AXLE_CONTRACT_KEYS = Object.values(AXLE_WIRE_TO_CONTRACT);
6
12
  export function map_cargo_state_to_contract(value) {
7
13
  if (!is_record(value)) {
8
14
  return value;
9
15
  }
10
16
  const mapped = {};
11
- if (value.config !== undefined) {
12
- mapped.config = value.config;
13
- }
14
17
  if (Array.isArray(value.envs)) {
15
18
  mapped.envs = value.envs.map(map_env_to_contract);
16
19
  }
@@ -24,6 +27,13 @@ function map_env_to_contract(value) {
24
27
  if (Array.isArray(value.containers)) {
25
28
  mapped.containers = value.containers.map(map_container_to_contract);
26
29
  }
30
+ if (Array.isArray(mapped.axles)) {
31
+ mapped.axles = mapped.axles.map(map_axle_to_contract);
32
+ }
33
+ const vehicle = map_vehicle_to_contract(value);
34
+ if (vehicle !== undefined) {
35
+ mapped.vehicle = vehicle;
36
+ }
27
37
  return pick_env_contract_keys(mapped);
28
38
  }
29
39
  function map_container_to_contract(value) {
@@ -32,29 +42,25 @@ function map_container_to_contract(value) {
32
42
  }
33
43
  const mapped = rename_keys(value, CONTAINER_WIRE_TO_CONTRACT);
34
44
  if (Array.isArray(value.items)) {
35
- mapped.items = value.items.map(map_wire_item_to_contract);
45
+ mapped.items = uniquify_contract_item_ids(value.items.map(map_wire_item_to_contract));
36
46
  }
37
- return pick_container_contract_keys(mapped);
47
+ return pick_keys(mapped, [...CONTAINER_CONTRACT_KEYS, 'items']);
38
48
  }
39
- function pick_container_contract_keys(source) {
40
- const picked = pick_keys(source, CONTAINER_CONTRACT_KEYS);
41
- if (Array.isArray(source.items)) {
42
- picked.items = source.items;
43
- }
44
- const attributes = omit_keys(source, [...CONTAINER_CONTRACT_KEYS, 'items']);
45
- if (Object.keys(attributes).length > 0) {
46
- picked.attributes = attributes;
49
+ function map_axle_to_contract(value) {
50
+ if (!is_record(value)) {
51
+ return value;
47
52
  }
48
- return picked;
53
+ return pick_keys(rename_keys(value, AXLE_WIRE_TO_CONTRACT), AXLE_CONTRACT_KEYS);
54
+ }
55
+ function map_vehicle_to_contract(env) {
56
+ const source = is_record(env.vehicle) ? env.vehicle : env;
57
+ const mapped = pick_keys(rename_keys(source, VEHICLE_WIRE_TO_CONTRACT), VEHICLE_CONTRACT_KEYS);
58
+ return Object.keys(mapped).length > 0 ? mapped : undefined;
49
59
  }
50
60
  function pick_env_contract_keys(source) {
51
61
  const picked = pick_keys(source, ENV_CONTRACT_KEYS);
52
62
  if (Array.isArray(source.containers)) {
53
63
  picked.containers = source.containers;
54
64
  }
55
- const vehicle = omit_keys(source, [...ENV_CONTRACT_KEYS, 'containers']);
56
- if (Object.keys(vehicle).length > 0) {
57
- picked.vehicle = vehicle;
58
- }
59
65
  return picked;
60
66
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Lifts nested CM stacking and restriction fields onto the contract item.
3
+ * @param contract - Contract item being filled.
4
+ * @param source - Wire or English item record.
5
+ */
6
+ export declare function assign_stacking_fields(contract: Record<string, unknown>, source: Record<string, unknown>): void;
7
+ //# sourceMappingURL=map_wire_item_stacking.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map_wire_item_stacking.d.ts","sourceRoot":"","sources":["../../../../src/core/validation/contract/map_wire_item_stacking.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,sBAAsB,CAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,IAAI,CAYN"}
@@ -0,0 +1,40 @@
1
+ import { is_record } from './wire_mapper_record_utils.js';
2
+ /**
3
+ * Lifts nested CM stacking and restriction fields onto the contract item.
4
+ * @param contract - Contract item being filled.
5
+ * @param source - Wire or English item record.
6
+ */
7
+ export function assign_stacking_fields(contract, source) {
8
+ assign_nested_stacking(contract, source.stacking);
9
+ assign_restriction_flags(contract, source.restrictions ?? source.restricoes);
10
+ if (typeof source.pesoMaxSuportado === 'number' && contract.supported_weight === undefined) {
11
+ contract.supported_weight = source.pesoMaxSuportado;
12
+ }
13
+ if (typeof source.stackingUnit === 'string' && contract.stacking_unit === undefined) {
14
+ contract.stacking_unit = source.stackingUnit;
15
+ }
16
+ }
17
+ function assign_nested_stacking(contract, stacking) {
18
+ if (!is_record(stacking)) {
19
+ return;
20
+ }
21
+ if (typeof stacking.family === 'string' && contract.family === undefined) {
22
+ contract.family = stacking.family;
23
+ }
24
+ if (Array.isArray(stacking.supported_families) && contract.supported_families === undefined) {
25
+ contract.supported_families = stacking.supported_families;
26
+ }
27
+ }
28
+ function assign_restriction_flags(contract, restrictions) {
29
+ if (!is_record(restrictions)) {
30
+ return;
31
+ }
32
+ assign_boolean_if_absent(contract, 'stack_families', restrictions.empilharFamilias);
33
+ assign_boolean_if_absent(contract, 'stack_same_item', restrictions.empilharItemIgual);
34
+ assign_boolean_if_absent(contract, 'stack_same_area', restrictions.empilharAreaIgual);
35
+ }
36
+ function assign_boolean_if_absent(contract, key, value) {
37
+ if (typeof value === 'boolean' && contract[key] === undefined) {
38
+ contract[key] = value;
39
+ }
40
+ }
@@ -1,10 +1,6 @@
1
1
  /**
2
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.
3
+ * Only modelled fields are copied; leftover SKU keys are dropped.
8
4
  * @param value - Raw wire item.
9
5
  * @returns Contract item, or the input unchanged when it is not a record.
10
6
  */
@@ -1 +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"}
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":"AAOA;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAUjE"}
@@ -1,12 +1,9 @@
1
1
  import { ITEM_CONTRACT_WIRE_KEYS, ITEM_POSITION_KEYS } from './cargo_movement_wire_field_map.js';
2
+ import { assign_stacking_fields } from './map_wire_item_stacking.js';
2
3
  import { is_record, omit_keys, read_first_present } from './wire_mapper_record_utils.js';
3
4
  /**
4
5
  * 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.
6
+ * Only modelled fields are copied; leftover SKU keys are dropped.
10
7
  * @param value - Raw wire item.
11
8
  * @returns Contract item, or the input unchanged when it is not a record.
12
9
  */
@@ -15,18 +12,11 @@ export function map_wire_item_to_contract(value) {
15
12
  return value;
16
13
  }
17
14
  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
- }
15
+ assign_stacking_fields(contract, omit_keys(value, ITEM_POSITION_KEYS));
22
16
  return contract;
23
17
  }
24
18
  function read_contract_item_fields(source) {
25
- const contract = {
26
- x: source.x,
27
- y: source.y,
28
- z: source.z
29
- };
19
+ const contract = read_contract_position(source);
30
20
  for (const [contract_key, wire_keys] of Object.entries(ITEM_CONTRACT_WIRE_KEYS)) {
31
21
  const value = read_first_present(source, wire_keys);
32
22
  if (value !== undefined) {
@@ -35,6 +25,18 @@ function read_contract_item_fields(source) {
35
25
  }
36
26
  return contract;
37
27
  }
28
+ /**
29
+ * BWA `to_json` stores length on `y` and height on `z`. Candidate geometry
30
+ * uses the opposite (y = height, z = length), so CM wire items are swapped.
31
+ * @param source - Wire or English item record.
32
+ * @returns Contract x/y/z.
33
+ */
34
+ function read_contract_position(source) {
35
+ if (typeof source.w === 'number') {
36
+ return { x: source.x, y: source.z, z: source.y };
37
+ }
38
+ return { x: source.x, y: source.y, z: source.z };
39
+ }
38
40
  /**
39
41
  * Coerces blocks-wall numeric group ids to the string contract type.
40
42
  * @param contract_key - English contract field name.