multicloud_rule_manager 1.1.49 → 1.1.51

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.
@@ -8,52 +8,58 @@ export default {
8
8
  output: { type: "string", default: "retrieve.json", describe: "File di output" }
9
9
  },
10
10
  handler: async (argv) => {
11
+ function buildMapObject(children) {
12
+ if (!Array.isArray(children) || children.length === 0) return [];
13
+
14
+ return children
15
+ .map(child => {
16
+
17
+ const items = Array.isArray(child.map_object_items)
18
+ ? child.map_object_items
19
+ .filter(item => !item.system_record)
20
+ .map(item => ({
21
+ label: item.label,
22
+ relationship_object: item.relationship_object,
23
+ relationship_target_source_field: item.relationship_target_source_field,
24
+ overridable: item.overridable,
25
+ price_model_selectable: item.price_model_selectable,
26
+ value: item.value,
27
+ engine_field: item.engine_field,
28
+ source_field: item.source_field,
29
+ type: item.type,
30
+ relationship_target_field: item.relationship_target_field,
31
+ field_type: item.field_type,
32
+ target_name: item.target_name
33
+ }))
34
+ .sort((a, b) =>
35
+ (a.target_name || "").localeCompare(b.target_name || "")
36
+ )
37
+ : [];
38
+
39
+ const childrenNodes = buildMapObject(child.map_objects)
40
+ .sort((a, b) =>
41
+ (a.name || "").localeCompare(b.name || "")
42
+ );
43
+
44
+ // ❗ se non ha né items né figli validi → scartalo
45
+ if (items.length === 0 && childrenNodes.length === 0) {
46
+ return null;
47
+ }
11
48
 
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
- }
43
-
44
- const template = {
45
- name: child.name || "NO_NAME"
46
- };
47
-
48
- if (items.length) template.map_object_items = items;
49
- if (childrenNodes.length) template.map_objects = childrenNodes;
50
-
51
- return template;
52
- })
53
- .filter(Boolean); // rimuove i null
54
- }
49
+ const template = {
50
+ name: child.name || "NO_NAME"
51
+ };
55
52
 
53
+ if (items.length) template.map_object_items = items;
54
+ if (childrenNodes.length) template.map_objects = childrenNodes;
56
55
 
56
+ return template;
57
+ })
58
+ .filter(Boolean)
59
+ .sort((a, b) =>
60
+ (a.name || "").localeCompare(b.name || "")
61
+ );
62
+ }
57
63
 
58
64
 
59
65
  try {
@@ -149,15 +155,9 @@ export default {
149
155
  };
150
156
 
151
157
  if (map) {
152
-
153
-
154
-
155
158
  if (Array.isArray(map)) {
156
- result = buildNodes(map);
159
+ result = buildMapObject(map);
157
160
  }
158
-
159
-
160
-
161
161
  if (Object.keys(result).length === 0) {
162
162
  console.warn(`⚠️ Nessun dato valido per ${record.name}`);
163
163
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multicloud_rule_manager",
3
- "version": "1.1.49",
3
+ "version": "1.1.51",
4
4
  "description": "CLI interna per retrieve/upload con token",
5
5
  "main": "index.js",
6
6
  "type": "module",