multicloud_rule_manager 1.1.48 → 1.1.49

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.
@@ -9,48 +9,49 @@ export default {
9
9
  },
10
10
  handler: async (argv) => {
11
11
 
12
+ function buildMapObject(children) {
13
+ if (!Array.isArray(children) || children.length === 0) return [];
14
+
15
+ return children
16
+ .map(child => {
17
+
18
+ const items = Array.isArray(child.map_object_items)
19
+ ? child.map_object_items
20
+ .filter(item => !item.system_record)
21
+ .map(item => ({
22
+ label: item.label,
23
+ relationship_object: item.relationship_object,
24
+ relationship_target_source_field: item.relationship_target_source_field,
25
+ overridable: item.overridable,
26
+ price_model_selectable: item.price_model_selectable,
27
+ value: item.value,
28
+ engine_field: item.engine_field,
29
+ source_field: item.source_field,
30
+ type: item.type,
31
+ relationship_target_field: item.relationship_target_field,
32
+ field_type: item.field_type,
33
+ target_name: item.target_name
34
+ }))
35
+ : [];
36
+
37
+ const childrenNodes = buildMapObject(child.map_objects);
38
+
39
+ // ❗ se non ha né items né figli validi → scartalo
40
+ if (items.length === 0 && childrenNodes.length === 0) {
41
+ return null;
42
+ }
12
43
 
13
- function buildNodes(children) {
14
- if (!Array.isArray(children) || children.length === 0) return [];
15
-
44
+ const template = {
45
+ name: child.name || "NO_NAME"
46
+ };
16
47
 
17
- return children.map(child => {
18
- var template = {
19
- name: child.name || "NO_NAME"
20
- };
48
+ if (items.length) template.map_object_items = items;
49
+ if (childrenNodes.length) template.map_objects = childrenNodes;
21
50
 
22
- if (Array.isArray(child.map_object_items)) {
23
- for (const item of child.map_object_items) {
24
-
25
- if (!item.system_record) {
26
- var ultimoNodo = {
27
-
28
- "label": item.label,
29
- "relationship_object": item.relationship_object,
30
- "relationship_target_source_field": item.relationship_target_source_field,
31
- "overridable": item.overridable,
32
- "price_model_selectable": item.price_model_selectable,
33
- "value": item.value,
34
- "engine_field": item.engine_field,
35
- "source_field": item.source_field,
36
- "type": item.type,
37
- "relationship_target_field": item.relationship_target_field,
38
- "field_type": item.field_type,
39
- "target_name": item.target_name
40
- }
41
-
42
- template.map_object_items = (ultimoNodo);
43
- }
44
- }
45
- }
46
-
47
- if (Array.isArray(child.map_objects) && child.map_objects.length > 0) {
48
- template.map_objects = buildNodes(child.map_objects); // ricorsione
49
- }
50
-
51
- return template;
52
- });
53
- }
51
+ return template;
52
+ })
53
+ .filter(Boolean); // rimuove i null
54
+ }
54
55
 
55
56
 
56
57
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multicloud_rule_manager",
3
- "version": "1.1.48",
3
+ "version": "1.1.49",
4
4
  "description": "CLI interna per retrieve/upload con token",
5
5
  "main": "index.js",
6
6
  "type": "module",