@boltic/cli 1.0.2 → 1.0.4

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.
@@ -0,0 +1,28 @@
1
+ import { environments } from "../config/environments.js";
2
+ import { handleError } from "../helper/error.js";
3
+
4
+ const getEnvironments = () => {
5
+ try {
6
+ return environments;
7
+ } catch (error) {
8
+ handleError(error);
9
+ }
10
+ };
11
+
12
+ const setEnvironment = async (environment) => {
13
+ try {
14
+ return environments[environment];
15
+ } catch (error) {
16
+ handleError(error);
17
+ }
18
+ };
19
+
20
+ const getEnvironment = async (configData) => {
21
+ try {
22
+ return configData.environment || "uat";
23
+ } catch (error) {
24
+ handleError(error);
25
+ }
26
+ };
27
+
28
+ export { getEnvironment, getEnvironments, setEnvironment };
package/api/login.js CHANGED
@@ -31,14 +31,14 @@ const getCliSession = async (apiUrl, requestCode) => {
31
31
  }
32
32
  };
33
33
 
34
- const getCliBearerToken = async (apiUrl, account_id, session) => {
34
+ const getCliBearerToken = async (name, apiUrl, account_id, session) => {
35
35
  try {
36
36
  const response = await axios({
37
37
  method: "get",
38
38
  url: `${apiUrl}/service/web/token/${account_id}`,
39
39
  headers: {
40
40
  "Content-Type": "application/json",
41
- Cookie: `bolt.session=${session}`,
41
+ Cookie: `${name}.session=${session}`,
42
42
  },
43
43
  });
44
44
  return response;
package/cli.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import chalk from "chalk";
2
2
  import fs from "fs";
3
+ import EnvironmentCommands from "./commands/env.js";
3
4
  import IntegrationCommands from "./commands/integration.js";
4
5
  import AuthCommands from "./commands/login.js";
5
6
 
@@ -22,6 +23,10 @@ const createCLI = (consoleUrl, apiUrl, serviceName, env) => {
22
23
  description: "Logout and clear access token",
23
24
  action: AuthCommands.handleLogout,
24
25
  },
26
+ env: {
27
+ description: "Manage environment settings (list, set, show)",
28
+ action: (args) => handleEnvironment(args),
29
+ },
25
30
  help: {
26
31
  description: "Display this help guide.",
27
32
  action: () => showHelp(commands),
@@ -117,6 +122,10 @@ async function handleIntegration(args) {
117
122
  await IntegrationCommands.execute(args);
118
123
  }
119
124
 
125
+ async function handleEnvironment(args) {
126
+ await EnvironmentCommands.execute(args);
127
+ }
128
+
120
129
  async function showVersion() {
121
130
  const packageJson = JSON.parse(
122
131
  fs.readFileSync(new URL("./package.json", import.meta.url))
@@ -0,0 +1,133 @@
1
+ import { select } from "@inquirer/prompts";
2
+ import chalk from "chalk";
3
+ import { environments } from "../config/environments.js";
4
+ import { getSecret, storeSecret } from "../helper/secure-storage.js";
5
+
6
+ // Define commands and their descriptions
7
+ const commands = {
8
+ list: {
9
+ description: "List available environments",
10
+ action: handleList,
11
+ },
12
+ set: {
13
+ description: "Set the active environment",
14
+ action: handleSet,
15
+ },
16
+ show: {
17
+ description: "Show the current environment",
18
+ action: handleShow,
19
+ },
20
+ };
21
+
22
+ // Execute the environment command
23
+ const execute = async (args) => {
24
+ const subCommand = args[0];
25
+
26
+ if (!subCommand) {
27
+ showHelp();
28
+ return;
29
+ }
30
+
31
+ if (!commands[subCommand]) {
32
+ console.log(chalk.red("Unknown or missing environment sub-command.\n"));
33
+ showHelp();
34
+ return;
35
+ }
36
+
37
+ const commandObj = commands[subCommand];
38
+ await commandObj.action(args.slice(1));
39
+ };
40
+
41
+ // List available environments
42
+ async function handleList() {
43
+ console.log(chalk.bgCyan.black("\n 📋 Available Environments \n"));
44
+ Object.entries(environments).forEach(([key, env]) => {
45
+ console.log(
46
+ chalk.blue.bold(`🔹 ${key}`) +
47
+ chalk.gray(` - ${env.name}`) +
48
+ chalk.dim(` (${env.loginUrl})`)
49
+ );
50
+ });
51
+ }
52
+
53
+ // Set the active environment
54
+ async function handleSet(args) {
55
+ const currentEnv = await getSecret("environment");
56
+ let selectedEnv;
57
+
58
+ if (args[0]) {
59
+ if (environments[args[0]]) {
60
+ selectedEnv = args[0];
61
+ } else {
62
+ console.log(
63
+ chalk.yellow(
64
+ `\nInvalid environment '${args[0]}', please select from available options.\n`
65
+ )
66
+ );
67
+ selectedEnv = await select({
68
+ message: "Select environment:",
69
+ choices: Object.entries(environments).map(([key, env]) => ({
70
+ name: `${env.name} (${env.loginUrl})`,
71
+ value: key,
72
+ })),
73
+ default: currentEnv,
74
+ });
75
+ }
76
+ } else {
77
+ selectedEnv = await select({
78
+ message: "Select environment:",
79
+ choices: Object.entries(environments).map(([key, env]) => ({
80
+ name: `${env.name} (${env.loginUrl})`,
81
+ value: key,
82
+ })),
83
+ default: currentEnv,
84
+ });
85
+ }
86
+
87
+ await storeSecret("environment", selectedEnv);
88
+
89
+ if (environments[selectedEnv]) {
90
+ console.log(
91
+ chalk.bgGreen.black("\n ✅ Success! ") +
92
+ chalk.green(
93
+ ` Environment set to ${chalk.bold.white(environments[selectedEnv].name)} ${chalk.dim(`(${environments[selectedEnv].loginUrl})`)}\n`
94
+ )
95
+ );
96
+ }
97
+ }
98
+
99
+ // Show the current environment
100
+ async function handleShow() {
101
+ const currentEnv = (await getSecret("environment")) || "bolt";
102
+ const env = environments[currentEnv];
103
+
104
+ console.log(chalk.bgCyan.black("\n 🌍 Current Environment \n"));
105
+ if (env) {
106
+ console.log(chalk.blue.bold("📝 Name: ") + chalk.white(env.name));
107
+ console.log(
108
+ chalk.blue.bold("🔑 Login URL: ") + chalk.white(env.loginUrl)
109
+ );
110
+ console.log(
111
+ chalk.blue.bold("🖥️ Console URL: ") + chalk.white(env.consoleUrl)
112
+ );
113
+ console.log(chalk.blue.bold("🔌 API URL: ") + chalk.white(env.apiUrl));
114
+ } else {
115
+ console.log(chalk.bold("Name: ") + environments.bolt.name);
116
+ }
117
+ }
118
+
119
+ // Show help for environment commands
120
+ function showHelp() {
121
+ console.log(chalk.bgCyan.black("\n ⚡ Environment Commands \n"));
122
+ Object.entries(commands).forEach(([cmd, details]) => {
123
+ console.log(
124
+ chalk.blue.bold(`🔸 ${cmd}`) +
125
+ chalk.gray(` - ${details.description}`)
126
+ );
127
+ });
128
+ }
129
+
130
+ export default {
131
+ execute,
132
+ handleSet,
133
+ };
@@ -504,6 +504,12 @@ async function handleCreate() {
504
504
  return;
505
505
  }
506
506
 
507
+ const create_catalogue = await confirm({
508
+ message:
509
+ "Would you like to create authentication form for this integration?",
510
+ default: true,
511
+ });
512
+
507
513
  // Create the integration
508
514
  try {
509
515
  const integration = await saveIntegration(
@@ -527,6 +533,7 @@ async function handleCreate() {
527
533
  trigger: trigger_ai_description || "",
528
534
  },
529
535
  },
536
+ create_catalogue: create_catalogue,
530
537
  }
531
538
  );
532
539
 
package/commands/login.js CHANGED
@@ -41,7 +41,8 @@ function showHelp() {
41
41
 
42
42
  // Handle login command
43
43
  async function handleLogin(args) {
44
- const { apiUrl, loginUrl, clientId, frontendUrl } = await getCurrentEnv();
44
+ const { apiUrl, loginUrl, clientId, frontendUrl, name } =
45
+ await getCurrentEnv();
45
46
 
46
47
  const requestCode = uuidv4();
47
48
  const state = {
@@ -106,11 +107,12 @@ async function handleLogin(args) {
106
107
  try {
107
108
  await storeSecret(
108
109
  "session",
109
- `bolt.session=${encodeURIComponent(session)}`
110
+ `${name}.session=${encodeURIComponent(session)}`
110
111
  );
111
112
  await storeSecret("account_id", accountId);
112
113
 
113
114
  const token = await getCliBearerToken(
115
+ name,
114
116
  apiUrl,
115
117
  accountId,
116
118
  session
@@ -1,6 +1,24 @@
1
1
  const environments = {
2
+ fcz0: {
3
+ name: "fcz0",
4
+ consoleUrl: "https://api.central.sit.fyndx1.de",
5
+ apiUrl: "https://asia-south1.api.fcz0.de",
6
+ loginUrl: "https://central.sit.fyndx1.de",
7
+ clientId: "ad140196-7d3c-477a-98bf-343187252f01",
8
+ allowedOrigin: "*.console.fcz0.de",
9
+ frontendUrl: "https://asia-south1.console.fcz0.de",
10
+ },
11
+ fcz5: {
12
+ name: "fcz5",
13
+ consoleUrl: "https://api.console.uat.fyndx1.de",
14
+ apiUrl: "https://asia-south1.api.uat.fcz0.de",
15
+ loginUrl: "https://console.uat.fyndx1.de",
16
+ clientId: "a65052b6-eef1-42e8-88c0-b80abca8dc51",
17
+ allowedOrigin: "*.console.uat.fcz0.de",
18
+ frontendUrl: "https://asia-south1.console.uat.fcz0.de",
19
+ },
2
20
  bolt: {
3
- name: "boltic",
21
+ name: "bolt",
4
22
  consoleUrl: "https://api.console.fynd.com",
5
23
  apiUrl: "https://asia-south1.api.boltic.io",
6
24
  loginUrl: "https://console.fynd.com",
package/helper/env.js CHANGED
@@ -13,8 +13,21 @@ export const getCurrentEnv = async () => {
13
13
  acc[account] = password;
14
14
  return acc;
15
15
  }, {});
16
+ const environment = config.environment || "bolt";
17
+ return {
18
+ name: environments[environment].name,
19
+ apiUrl: environments[environment].apiUrl,
20
+ loginUrl: environments[environment].loginUrl,
21
+ consoleUrl: environments[environment].consoleUrl,
22
+ clientId: environments[environment].clientId,
23
+ token: config.token || null,
24
+ session: config.session || null,
25
+ accountId: config.account_id || null,
26
+ frontendUrl: environments[environment].frontendUrl,
27
+ };
16
28
  }
17
29
  return {
30
+ name: environments.bolt.name,
18
31
  apiUrl: environments.bolt.apiUrl,
19
32
  loginUrl: environments.bolt.loginUrl,
20
33
  consoleUrl: environments.bolt.consoleUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boltic/cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "A powerful CLI tool for managing Boltic Workflow integrations",
5
5
  "main": "index.js",
6
6
  "bin": {