multicloud_rule_manager 1.1.65 → 1.1.67

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.
@@ -14,7 +14,7 @@ export default {
14
14
  // --- PRIMA CHIAMATA: token ---
15
15
  console.log("🔹 Inizio richiesta token...");
16
16
  const loginResp = await fetch(`https://login-eon-no-prod.bit2win.cloud/auth/realms/${cred.realm}/protocol/openid-connect/token`, {
17
- method: "POST",
17
+ method: "POST",
18
18
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
19
19
  body: new URLSearchParams({
20
20
  client_id: cred.clientId,
@@ -25,6 +25,7 @@ export default {
25
25
  })
26
26
  });
27
27
 
28
+
28
29
  const loginData = await loginResp.json(); // leggi direttamente JSON
29
30
  const access_token = loginData.access_token;
30
31
 
@@ -32,17 +33,23 @@ export default {
32
33
  throw new Error("Token non ricevuto nel campo 'access_token'");
33
34
  }
34
35
 
35
- const headers = {
36
- Authorization: `Bearer ${access_token}`,
37
- Accept: "application/json"
38
- };
39
36
 
37
+
38
+
40
39
  // =========================
41
40
  // 📦 PRODUCTS
42
41
  // =========================
42
+ console.log(" Chiamo products");
43
43
  const productsResp = await fetch(
44
44
  `https://${cred.realm}.bit2win.cloud/api/data/v1/products/`,
45
- { headers }
45
+ {
46
+ method: "GET",
47
+ headers: {
48
+ "Authorization": `Bearer ${access_token}`,
49
+ "Accept": "application/json"
50
+ },
51
+ redirect: "manual"
52
+ }
46
53
  );
47
54
 
48
55
  const products = await productsResp.json();
@@ -58,9 +65,18 @@ export default {
58
65
  // =========================
59
66
  // 🌳 STRUCTURE
60
67
  // =========================
68
+
69
+ console.log(" Chiamo products structure");
61
70
  const structResp = await fetch(
62
71
  `https://${cred.realm}.bit2win.cloud/api/data/v1/products_structure/`,
63
- { headers }
72
+ {
73
+ method: "GET",
74
+ headers: {
75
+ "Authorization": `Bearer ${access_token}`,
76
+ "Accept": "application/json"
77
+ },
78
+ redirect: "manual"
79
+ }
64
80
  );
65
81
 
66
82
  const structure = await structResp.json();
@@ -86,11 +102,20 @@ export default {
86
102
  // =========================
87
103
  // 📡 FAMILIES
88
104
  // =========================
105
+
106
+ console.log(" Chiamo famili per product");
89
107
  const getFamilies = async (productId) => {
90
108
  const resp = await fetch(
91
109
  `https://${cred.realm}.bit2win.cloud/api/catalog/v1/products/${productId}/families`,
92
- { headers }
93
- );
110
+ {
111
+ method: "GET",
112
+ headers: {
113
+ "Authorization": `Bearer ${access_token}`,
114
+ "Accept": "application/json"
115
+ },
116
+ redirect: "manual"
117
+ }
118
+ );
94
119
 
95
120
  const data = await resp.json();
96
121
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multicloud_rule_manager",
3
- "version": "1.1.65",
3
+ "version": "1.1.67",
4
4
  "description": "CLI interna per retrieve/upload con token",
5
5
  "main": "index.js",
6
6
  "type": "module",