multicloud_rule_manager 1.0.39 โ†’ 1.0.41

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.
@@ -41,7 +41,7 @@ export default {
41
41
  // --- SECONDA CHIAMATA: retrieve ---
42
42
  console.log("๐Ÿ”น Inizio richiesta dati API...");
43
43
  const apiResp = await fetch(
44
- `https://${cred.realm}.cloud/api/data/v1/rules`,
44
+ `https://${cred.realm}.bit2win.cloud/api/data/v1/rules`,
45
45
  {
46
46
  method: "GET",
47
47
  headers: {
@@ -52,54 +52,21 @@ export default {
52
52
  }
53
53
  );
54
54
 
55
- if (!apiResp.ok) {
56
- const errText = await apiResp.text();
57
- throw new Error(`Errore API ${apiResp.status}: ${errText}`);
58
- }
55
+ console.log("๐Ÿ”น Status risposta API:", apiResp.status);
56
+ const apiText = await apiResp.text();
57
+ console.log("๐Ÿ”น Body risposta API (raw):", apiText);
59
58
 
60
- const data = await apiResp.json();
61
- console.log("๐Ÿ”น API status:", apiResp.status);
62
-
63
-
64
-
65
- console.log("๐Ÿ”น API final URL:", data.url);
66
-
67
- // Controlla che sia array
68
- if (!Array.isArray(data)) {
69
- throw new Error("La risposta API non รจ una lista di oggetti");
59
+ if (!apiResp.ok) {
60
+ throw new Error(`Errore API ${apiResp.status}: ${apiText}`);
70
61
  }
71
62
 
72
- // Crea cartella rules se non esiste
73
- const rulesDir = "./rules";
74
- if (!fs.existsSync(rulesDir)) {
75
- fs.mkdirSync(rulesDir, { recursive: true });
76
- console.log("๐Ÿ“ Cartella 'rules' creata");
63
+ let data;
64
+ try {
65
+ data = JSON.parse(apiText);
66
+ } catch (err) {
67
+ throw new Error(`Parsing JSON fallito: ${err.message}`);
77
68
  }
78
69
 
79
- // Per ogni record genera file SOLO se dsl_internal esiste
80
- for (const record of data) {
81
-
82
- if (!record.name || !record.guid) {
83
- console.warn("โš ๏ธ Record saltato (name o guid mancanti):", record);
84
- continue;
85
- }
86
-
87
- if (!record.dsl_internal || record.dsl_internal.trim() === "") {
88
- console.log(`โš ๏ธ Record "${record.name}" saltato: dsl_internal vuoto`);
89
- continue;
90
- }
91
-
92
- const safeName = record.name.replace(/[<>:"/\\|?*]+/g, "_");
93
- const fileName = `${safeName}_${record.guid}.js`;
94
- const filePath = `${rulesDir}/${fileName}`;
95
-
96
- fs.writeFileSync(filePath, record.dsl_internal, "utf8");
97
-
98
- console.log(`๐Ÿ“ File scritto: ${fileName}`);
99
- }
100
-
101
- console.log("๐Ÿš€ Tutti i file con contenuto valido sono stati generati");
102
-
103
70
  } catch (err) {
104
71
  console.error("โŒ Errore:", err.message);
105
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multicloud_rule_manager",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "description": "CLI interna per retrieve/upload con token",
5
5
  "main": "index.js",
6
6
  "type": "module",