multicloud_rule_manager 1.1.64 → 1.1.66

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.
@@ -7,32 +7,29 @@ export default {
7
7
  describe: "Recupera struttura prodotto e genera Excel",
8
8
  handler: async (argv) => {
9
9
  try {
10
- console.log("🔹 Retrieve in corso..");
11
-
10
+ console.log("🔹 Retrieve in corso..");
11
+ console.log("🔹 Recupero credenziali per alias:", argv.alias);
12
12
  const cred = getAlias(argv.alias);
13
13
 
14
- // =========================
15
- // 🔐 TOKEN
16
- // =========================
17
- const loginResp = await fetch(
18
- `https://login-eon-no-prod.bit2win.cloud/auth/realms/${cred.realm}/protocol/openid-connect/token`,
19
- {
20
- method: "POST",
21
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
22
- body: new URLSearchParams({
23
- client_id: cred.clientId,
24
- client_secret: cred.clientSecret,
25
- username: cred.username,
26
- password: cred.password,
27
- grant_type: "password"
28
- })
29
- }
30
- );
31
-
32
- const { access_token } = await loginResp.json();
14
+ // --- PRIMA CHIAMATA: token ---
15
+ console.log("🔹 Inizio richiesta token...");
16
+ const loginResp = await fetch(`https://login-eon-no-prod.bit2win.cloud/auth/realms/${cred.realm}/protocol/openid-connect/token`, {
17
+ method: "POST",
18
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
19
+ body: new URLSearchParams({
20
+ client_id: cred.clientId,
21
+ client_secret: cred.clientSecret,
22
+ username: cred.username,
23
+ password: cred.password,
24
+ grant_type: "password"
25
+ })
26
+ });
27
+
28
+ const loginData = await loginResp.json(); // leggi direttamente JSON
29
+ const access_token = loginData.access_token;
33
30
 
34
31
  if (!access_token) {
35
- throw new Error("Token non ricevuto");
32
+ throw new Error("Token non ricevuto nel campo 'access_token'");
36
33
  }
37
34
 
38
35
  const headers = {
@@ -43,6 +40,7 @@ export default {
43
40
  // =========================
44
41
  // 📦 PRODUCTS
45
42
  // =========================
43
+ console.log(" Chiamo products");
46
44
  const productsResp = await fetch(
47
45
  `https://${cred.realm}.bit2win.cloud/api/data/v1/products/`,
48
46
  { headers }
@@ -61,6 +59,8 @@ export default {
61
59
  // =========================
62
60
  // 🌳 STRUCTURE
63
61
  // =========================
62
+
63
+ console.log(" Chiamo products structure");
64
64
  const structResp = await fetch(
65
65
  `https://${cred.realm}.bit2win.cloud/api/data/v1/products_structure/`,
66
66
  { headers }
@@ -89,6 +89,8 @@ export default {
89
89
  // =========================
90
90
  // 📡 FAMILIES
91
91
  // =========================
92
+
93
+ console.log(" Chiamo famili per product");
92
94
  const getFamilies = async (productId) => {
93
95
  const resp = await fetch(
94
96
  `https://${cred.realm}.bit2win.cloud/api/catalog/v1/products/${productId}/families`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multicloud_rule_manager",
3
- "version": "1.1.64",
3
+ "version": "1.1.66",
4
4
  "description": "CLI interna per retrieve/upload con token",
5
5
  "main": "index.js",
6
6
  "type": "module",