@boltic/cli 0.0.1
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.
- package/README.md +149 -0
- package/api/integration.js +469 -0
- package/api/login.js +50 -0
- package/cli.js +128 -0
- package/commands/integration.js +952 -0
- package/commands/login.js +170 -0
- package/config/environments.js +13 -0
- package/helper/command-suggestions.js +54 -0
- package/helper/env.js +27 -0
- package/helper/error.js +123 -0
- package/helper/folder.js +204 -0
- package/helper/secure-storage.js +74 -0
- package/helper/verbose.js +20 -0
- package/index.js +14 -0
- package/package.json +57 -0
- package/templates/schemas.js +506 -0
- package/utils/integration.js +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# ⚡ Boltic CLI
|
|
2
|
+
|
|
3
|
+
> A powerful CLI tool for creating, managing, and publishing Boltic integrations.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@boltic/cli)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
[](https://nodejs.org/)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 📦 Installation
|
|
12
|
+
|
|
13
|
+
Install Boltic CLI globally via NPM:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g @boltic/cli
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 🔐 Authentication
|
|
22
|
+
|
|
23
|
+
To log in:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
boltic login
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Follow the interactive prompt to enter your credentials. Your token will be stored securely for future use.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 🧩 Integration Management
|
|
34
|
+
|
|
35
|
+
### ➕ Create a New Integration
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
boltic integration create
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
You’ll be prompted to enter:
|
|
42
|
+
|
|
43
|
+
- **Name**
|
|
44
|
+
- **Icon URL**
|
|
45
|
+
- **Integration Type**
|
|
46
|
+
|
|
47
|
+
- Workflow Activity or Trigger
|
|
48
|
+
|
|
49
|
+
- **Descriptions**
|
|
50
|
+
|
|
51
|
+
- Human-readable and AI-generated
|
|
52
|
+
|
|
53
|
+
- **Integration Group**
|
|
54
|
+
|
|
55
|
+
- e.g., Analytics, CRM, ERP, Marketing, Payment, Social Media, Other
|
|
56
|
+
|
|
57
|
+
### ✏️ Edit an Integration
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
boltic integration edit
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 🔄 Sync an Integration
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
boltic integration sync
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 🚀 Publish an Integration
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
boltic integration publish
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 📌 Command Reference
|
|
78
|
+
|
|
79
|
+
| Command | Description |
|
|
80
|
+
| ---------------------------- | -------------------------------------------------------- |
|
|
81
|
+
| `boltic login` | Authenticate with Boltic |
|
|
82
|
+
| `boltic integration create` | Create a new integration |
|
|
83
|
+
| `boltic integration sync` | Sync changes to your draft |
|
|
84
|
+
| `boltic integration publish` | Submit integration for review |
|
|
85
|
+
| `boltic integration pull` | Pull the latest changes of an integration from the Cloud |
|
|
86
|
+
| `boltic integration edit` | Edit an existing integration |
|
|
87
|
+
| `boltic help` | Show CLI help |
|
|
88
|
+
| `boltic version` | Display CLI version |
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 🔁 Typical Workflow
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Step 1: Authenticate
|
|
96
|
+
boltic login
|
|
97
|
+
|
|
98
|
+
# Step 2: Start a new integration
|
|
99
|
+
boltic integration create
|
|
100
|
+
|
|
101
|
+
# Step 3: Save changes
|
|
102
|
+
boltic integration sync
|
|
103
|
+
|
|
104
|
+
# Step 5: Submit for publishing and review
|
|
105
|
+
boltic integration publish
|
|
106
|
+
|
|
107
|
+
# Step 6: Pull the latest changes of a integration. Please call this command inside a integration folder.
|
|
108
|
+
boltic integration pull
|
|
109
|
+
|
|
110
|
+
# Step 7: Use this command if you don't have folder of a particular integration. Please call this command outside of any existing integration folder.
|
|
111
|
+
boltic integration edit
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## 🛠️ Troubleshooting
|
|
117
|
+
|
|
118
|
+
### Login Errors
|
|
119
|
+
|
|
120
|
+
- Make sure you're online and using valid credentials.
|
|
121
|
+
- Retry `boltic login` if your token has expired.
|
|
122
|
+
|
|
123
|
+
### Integration Issues
|
|
124
|
+
|
|
125
|
+
- Ensure all required fields (e.g., name, type, icon URL) are filled.
|
|
126
|
+
- Verify the icon URL is publicly accessible.
|
|
127
|
+
- Double-check the selected integration type and group.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 📚 Help
|
|
132
|
+
|
|
133
|
+
Get help directly in the CLI:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# View all commands
|
|
137
|
+
boltic help
|
|
138
|
+
|
|
139
|
+
# View integration command options
|
|
140
|
+
boltic integration help
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Or visit the [Boltic Docs](https://docs.boltic.io) for full documentation.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 🧾 License
|
|
148
|
+
|
|
149
|
+
MIT © [Boltic](https://boltic.io)
|
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import FormData from "form-data";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import { handleError } from "../helper/error.js";
|
|
5
|
+
import { logApi } from "../helper/verbose.js";
|
|
6
|
+
|
|
7
|
+
const getIntegrationGroups = async (apiUrl, accountId, token, session) => {
|
|
8
|
+
if (!token || !session || !accountId) {
|
|
9
|
+
console.error(
|
|
10
|
+
"\x1b[31mError:\x1b[0m Authentication credentials are required."
|
|
11
|
+
);
|
|
12
|
+
console.log("\n🔹 Please log in first using:");
|
|
13
|
+
console.log("\x1b[32m$ boltic login\x1b[0m\n");
|
|
14
|
+
process.exit(1); // Exit the CLI with an error code
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const axiosOptions = {
|
|
18
|
+
method: "get",
|
|
19
|
+
url: `${apiUrl}/service/panel/temporal/v1.0/${accountId}/integration-groups`,
|
|
20
|
+
params: {
|
|
21
|
+
page: 1,
|
|
22
|
+
per_page: 999,
|
|
23
|
+
},
|
|
24
|
+
headers: {
|
|
25
|
+
"Content-Type": "application/json",
|
|
26
|
+
Authorization: `Bearer ${token}`,
|
|
27
|
+
Cookie: session,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const response = await axios(axiosOptions);
|
|
32
|
+
logApi(axiosOptions.method, axiosOptions.url, response.status);
|
|
33
|
+
return response.data.data;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
handleError(error);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const listAllIntegrations = async (apiUrl, token, accountId, session) => {
|
|
40
|
+
if (!token || !session || !accountId) {
|
|
41
|
+
console.error(
|
|
42
|
+
"\x1b[31mError:\x1b[0m Authentication credentials are required."
|
|
43
|
+
);
|
|
44
|
+
console.log("\n🔹 Please log in first using:");
|
|
45
|
+
console.log("\x1b[32m$ boltic login\x1b[0m\n");
|
|
46
|
+
process.exit(1); // Exit the CLI with an error code
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const axiosOptions = {
|
|
50
|
+
method: "get",
|
|
51
|
+
url: `${apiUrl}/service/panel/temporal/v1.0/${accountId}/integrations`,
|
|
52
|
+
params: {
|
|
53
|
+
page: 1,
|
|
54
|
+
per_page: 999,
|
|
55
|
+
},
|
|
56
|
+
headers: {
|
|
57
|
+
"Content-Type": "application/json",
|
|
58
|
+
Authorization: `Bearer ${token}`,
|
|
59
|
+
Cookie: session,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const response = await axios(axiosOptions);
|
|
64
|
+
logApi(axiosOptions.method, axiosOptions.url, response.status);
|
|
65
|
+
return response.data.data;
|
|
66
|
+
} catch (error) {
|
|
67
|
+
handleError(error);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const saveIntegration = async (
|
|
72
|
+
apiUrl,
|
|
73
|
+
token,
|
|
74
|
+
accountId,
|
|
75
|
+
session,
|
|
76
|
+
integration
|
|
77
|
+
) => {
|
|
78
|
+
if (!token || !session || !accountId) {
|
|
79
|
+
console.error(
|
|
80
|
+
"\x1b[31mError:\x1b[0m Authentication credentials are required."
|
|
81
|
+
);
|
|
82
|
+
console.log("\n🔹 Please log in first using:");
|
|
83
|
+
console.log("\x1b[32m$ boltic login\x1b[0m\n");
|
|
84
|
+
process.exit(1); // Exit the CLI with an error code
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const response = await axios({
|
|
88
|
+
method: "post",
|
|
89
|
+
url: `${apiUrl}/service/panel/temporal/v1.0/${accountId}/integrations`,
|
|
90
|
+
data: integration,
|
|
91
|
+
headers: {
|
|
92
|
+
"Content-Type": "application/json",
|
|
93
|
+
Authorization: `Bearer ${token}`,
|
|
94
|
+
Cookie: session,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
return response.data.data;
|
|
98
|
+
} catch (error) {
|
|
99
|
+
handleError(error);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const editIntegration = async (apiUrl, token, accountId, session, payload) => {
|
|
104
|
+
if (!token || !session || !accountId) {
|
|
105
|
+
console.error(
|
|
106
|
+
"\x1b[31mError:\x1b[0m Authentication credentials are required."
|
|
107
|
+
);
|
|
108
|
+
console.log("\n🔹 Please log in first using:");
|
|
109
|
+
console.log("\x1b[32m$ boltic login\x1b[0m\n");
|
|
110
|
+
process.exit(1); // Exit the CLI with an error code
|
|
111
|
+
}
|
|
112
|
+
const { id } = payload;
|
|
113
|
+
try {
|
|
114
|
+
const response = await axios({
|
|
115
|
+
method: "post",
|
|
116
|
+
url: `${apiUrl}/service/panel/temporal/v1.0/${accountId}/integrations/${id}/edit`,
|
|
117
|
+
data: payload,
|
|
118
|
+
headers: {
|
|
119
|
+
"Content-Type": "application/json",
|
|
120
|
+
Authorization: `Bearer ${token}`,
|
|
121
|
+
Cookie: session,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
return response.data.data;
|
|
126
|
+
} catch (error) {
|
|
127
|
+
handleError(error);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const updateIntegration = async (
|
|
132
|
+
apiUrl,
|
|
133
|
+
token,
|
|
134
|
+
accountId,
|
|
135
|
+
session,
|
|
136
|
+
integration
|
|
137
|
+
) => {
|
|
138
|
+
if (!token || !session || !accountId) {
|
|
139
|
+
console.error(
|
|
140
|
+
"\x1b[31mError:\x1b[0m Authentication credentials are required."
|
|
141
|
+
);
|
|
142
|
+
console.log("\n🔹 Please log in first using:");
|
|
143
|
+
console.log("\x1b[32m$ boltic login\x1b[0m\n");
|
|
144
|
+
process.exit(1); // Exit the CLI with an error code
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
const { id, ...rest } = integration;
|
|
148
|
+
const response = await axios({
|
|
149
|
+
method: "patch",
|
|
150
|
+
url: `${apiUrl}/service/panel/temporal/v1.0/${accountId}/integrations/${id}`,
|
|
151
|
+
data: rest,
|
|
152
|
+
headers: {
|
|
153
|
+
"Content-Type": "application/json",
|
|
154
|
+
Authorization: `Bearer ${token}`,
|
|
155
|
+
Cookie: session,
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
return response.data.data;
|
|
159
|
+
} catch (error) {
|
|
160
|
+
handleError(error);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const getIntegrationById = async (
|
|
165
|
+
apiUrl,
|
|
166
|
+
token,
|
|
167
|
+
accountId,
|
|
168
|
+
session,
|
|
169
|
+
integrationId
|
|
170
|
+
) => {
|
|
171
|
+
if (!token || !session || !accountId) {
|
|
172
|
+
console.error(
|
|
173
|
+
"\x1b[31mError:\x1b[0m Authentication credentials are required."
|
|
174
|
+
);
|
|
175
|
+
console.log("\n🔹 Please log in first using:");
|
|
176
|
+
console.log("\x1b[32m$ boltic login\x1b[0m\n");
|
|
177
|
+
process.exit(1); // Exit the CLI with an error code
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
try {
|
|
181
|
+
const response = await axios({
|
|
182
|
+
method: "get",
|
|
183
|
+
url: `${apiUrl}/service/panel/temporal/v1.0/${accountId}/integrations/${integrationId}`,
|
|
184
|
+
headers: {
|
|
185
|
+
"Content-Type": "application/json",
|
|
186
|
+
Authorization: `Bearer ${token}`,
|
|
187
|
+
Cookie: session,
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
return response.data.data;
|
|
191
|
+
} catch (error) {
|
|
192
|
+
handleError(error);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const getAuthenticationByIntegrationId = async (
|
|
197
|
+
apiUrl,
|
|
198
|
+
token,
|
|
199
|
+
accountId,
|
|
200
|
+
session,
|
|
201
|
+
integrationId
|
|
202
|
+
) => {
|
|
203
|
+
if (!token || !session || !accountId) {
|
|
204
|
+
console.error(
|
|
205
|
+
"\x1b[31mError:\x1b[0m Authentication credentials are required."
|
|
206
|
+
);
|
|
207
|
+
console.log("\n🔹 Please log in first using:");
|
|
208
|
+
console.log("\x1b[32m$ boltic login\x1b[0m\n");
|
|
209
|
+
process.exit(1); // Exit the CLI with an error code
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
try {
|
|
213
|
+
const response = await axios({
|
|
214
|
+
method: "get",
|
|
215
|
+
url: `${apiUrl}/service/panel/temporal/v1.0/${accountId}integrations/${integrationId}/authentication`,
|
|
216
|
+
headers: {
|
|
217
|
+
"Content-Type": "application/json",
|
|
218
|
+
Authorization: `Bearer ${token}`,
|
|
219
|
+
Cookie: session,
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
return response.data.data;
|
|
223
|
+
} catch (error) {
|
|
224
|
+
handleError(error);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const getWebhooksByIntegrationId = async (
|
|
229
|
+
apiUrl,
|
|
230
|
+
token,
|
|
231
|
+
accountId,
|
|
232
|
+
session,
|
|
233
|
+
integrationId
|
|
234
|
+
) => {
|
|
235
|
+
if (!token || !session || !accountId) {
|
|
236
|
+
console.error(
|
|
237
|
+
"\x1b[31mError:\x1b[0m Authentication credentials are required."
|
|
238
|
+
);
|
|
239
|
+
console.log("\n🔹 Please log in first using:");
|
|
240
|
+
console.log("\x1b[32m$ boltic login\x1b[0m\n");
|
|
241
|
+
process.exit(1); // Exit the CLI with an error code
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
try {
|
|
245
|
+
const response = await axios({
|
|
246
|
+
method: "get",
|
|
247
|
+
url: `${apiUrl}/service/panel/temporal/v1.0/${accountId}integrations/${integrationId}/webhooks`,
|
|
248
|
+
headers: {
|
|
249
|
+
"Content-Type": "application/json",
|
|
250
|
+
Authorization: `Bearer ${token}`,
|
|
251
|
+
Cookie: session,
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
return response.data.data;
|
|
255
|
+
} catch (error) {
|
|
256
|
+
handleError(error);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
const getConfigurationByIntegrationId = async (
|
|
261
|
+
apiUrl,
|
|
262
|
+
token,
|
|
263
|
+
session,
|
|
264
|
+
accountId,
|
|
265
|
+
integrationId
|
|
266
|
+
) => {
|
|
267
|
+
if (!token || !session || !accountId) {
|
|
268
|
+
console.error(
|
|
269
|
+
"\x1b[31mError:\x1b[0m Authentication credentials are required."
|
|
270
|
+
);
|
|
271
|
+
console.log("\n🔹 Please log in first using:");
|
|
272
|
+
console.log("\x1b[32m$ boltic login\x1b[0m\n");
|
|
273
|
+
process.exit(1); // Exit the CLI with an error code
|
|
274
|
+
}
|
|
275
|
+
try {
|
|
276
|
+
const response = await axios({
|
|
277
|
+
method: "get",
|
|
278
|
+
url: `${apiUrl}/service/panel/temporal/v1.0/${accountId}integrations/${integrationId}/configuration`,
|
|
279
|
+
headers: {
|
|
280
|
+
"Content-Type": "application/json",
|
|
281
|
+
Authorization: `Bearer ${token}`,
|
|
282
|
+
Cookie: session,
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
return response.data.data;
|
|
286
|
+
} catch (error) {
|
|
287
|
+
handleError(error);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
const syncIntegration = async (
|
|
292
|
+
apiUrl,
|
|
293
|
+
token,
|
|
294
|
+
accountId,
|
|
295
|
+
session,
|
|
296
|
+
integration
|
|
297
|
+
) => {
|
|
298
|
+
if (!token || !session || !accountId) {
|
|
299
|
+
console.error(
|
|
300
|
+
"\x1b[31mError:\x1b[0m Authentication credentials are required."
|
|
301
|
+
);
|
|
302
|
+
console.log("\n🔹 Please log in first using:");
|
|
303
|
+
console.log("\x1b[32m$ boltic login\x1b[0m\n");
|
|
304
|
+
process.exit(1); // Exit the CLI with an error code
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
const response = await axios({
|
|
308
|
+
method: "post",
|
|
309
|
+
url: `${apiUrl}/service/panel/temporal/v1.0/${accountId}/integrations/${integration.integration_id}/deploy`,
|
|
310
|
+
data: integration,
|
|
311
|
+
headers: {
|
|
312
|
+
"Content-Type": "application/json",
|
|
313
|
+
Authorization: `Bearer ${token}`,
|
|
314
|
+
Cookie: session,
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
return response.data.data;
|
|
318
|
+
} catch (error) {
|
|
319
|
+
handleError(error);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
const sendIntegrationForReview = async (
|
|
324
|
+
apiUrl,
|
|
325
|
+
token,
|
|
326
|
+
accountId,
|
|
327
|
+
session,
|
|
328
|
+
integration
|
|
329
|
+
) => {
|
|
330
|
+
if (!token || !session || !accountId) {
|
|
331
|
+
console.error(
|
|
332
|
+
"\x1b[31mError:\x1b[0m Authentication credentials are required."
|
|
333
|
+
);
|
|
334
|
+
console.log("\n🔹 Please log in first using:");
|
|
335
|
+
console.log("\x1b[32m$ boltic login\x1b[0m\n");
|
|
336
|
+
process.exit(1); // Exit the CLI with an error code
|
|
337
|
+
}
|
|
338
|
+
try {
|
|
339
|
+
const response = await axios({
|
|
340
|
+
method: "post",
|
|
341
|
+
url: `${apiUrl}/service/panel/temporal/v1.0/${accountId}/integration-reviews`,
|
|
342
|
+
data: integration,
|
|
343
|
+
headers: {
|
|
344
|
+
"Content-Type": "application/json",
|
|
345
|
+
Authorization: `Bearer ${token}`,
|
|
346
|
+
Cookie: session,
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
return response.data.data;
|
|
350
|
+
} catch (error) {
|
|
351
|
+
handleError(error);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
const purgeCache = async (apiUrl, token, accountId, session, integration) => {
|
|
356
|
+
const { integration_id } = integration;
|
|
357
|
+
if (!token || !session || !accountId) {
|
|
358
|
+
console.error(
|
|
359
|
+
"\x1b[31mError:\x1b[0m Authentication credentials are required."
|
|
360
|
+
);
|
|
361
|
+
console.log("\n🔹 Please log in first using:");
|
|
362
|
+
console.log("\x1b[32m$ boltic login\x1b[0m\n");
|
|
363
|
+
process.exit(1); // Exit the CLI with an error code
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
try {
|
|
367
|
+
const response = await axios({
|
|
368
|
+
method: "post",
|
|
369
|
+
url: `${apiUrl}/service/panel/temporal/v1.0/${accountId}/integrations/${integration_id}/cache`,
|
|
370
|
+
data: {},
|
|
371
|
+
headers: {
|
|
372
|
+
"Content-Type": "application/json",
|
|
373
|
+
Authorization: `Bearer ${token}`,
|
|
374
|
+
Cookie: session,
|
|
375
|
+
},
|
|
376
|
+
});
|
|
377
|
+
return response.data;
|
|
378
|
+
} catch (error) {
|
|
379
|
+
handleError(error);
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
const pullIntegration = async (apiUrl, token, accountId, session, id) => {
|
|
384
|
+
if (!token || !session || !accountId) {
|
|
385
|
+
console.error(
|
|
386
|
+
"\x1b[31mError:\x1b[0m Authentication credentials are required."
|
|
387
|
+
);
|
|
388
|
+
console.log("\n🔹 Please log in first using:");
|
|
389
|
+
console.log("\x1b[32m$ boltic login\x1b[0m\n");
|
|
390
|
+
process.exit(1); // Exit the CLI with an error code
|
|
391
|
+
}
|
|
392
|
+
try {
|
|
393
|
+
const response = await axios({
|
|
394
|
+
method: "get",
|
|
395
|
+
url: `${apiUrl}/service/panel/temporal/v1.0/${accountId}/integrations/${id}/pull`,
|
|
396
|
+
headers: {
|
|
397
|
+
"Content-Type": "application/json",
|
|
398
|
+
Authorization: `Bearer ${token}`,
|
|
399
|
+
Cookie: session,
|
|
400
|
+
},
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
return response.data.data;
|
|
404
|
+
} catch (error) {
|
|
405
|
+
handleError(error);
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
const uploadFileToCloud = async (
|
|
410
|
+
apiUrl,
|
|
411
|
+
token,
|
|
412
|
+
accountId,
|
|
413
|
+
session,
|
|
414
|
+
filePath
|
|
415
|
+
) => {
|
|
416
|
+
if (!token || !session || !accountId) {
|
|
417
|
+
console.error(
|
|
418
|
+
"\x1b[31mError:\x1b[0m Authentication credentials are required."
|
|
419
|
+
);
|
|
420
|
+
console.log("\n🔹 Please log in first using:");
|
|
421
|
+
console.log("\x1b[32m$ boltic login\x1b[0m\n");
|
|
422
|
+
process.exit(1);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (!fs.existsSync(filePath)) {
|
|
426
|
+
throw new Error("File does not exist: " + filePath);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
try {
|
|
430
|
+
const form = new FormData();
|
|
431
|
+
form.append("files", fs.createReadStream(filePath));
|
|
432
|
+
|
|
433
|
+
const response = await axios.post(
|
|
434
|
+
`${apiUrl}/service/panel/temporal/v1.0/${accountId}/utility/upload`,
|
|
435
|
+
form,
|
|
436
|
+
{
|
|
437
|
+
headers: {
|
|
438
|
+
...form.getHeaders(),
|
|
439
|
+
Authorization: `Bearer ${token}`,
|
|
440
|
+
Cookie: session,
|
|
441
|
+
},
|
|
442
|
+
}
|
|
443
|
+
);
|
|
444
|
+
|
|
445
|
+
return response.data?.data?.[0];
|
|
446
|
+
} catch (error) {
|
|
447
|
+
console.error(
|
|
448
|
+
"❌ Upload failed:",
|
|
449
|
+
error?.response?.data || error.message
|
|
450
|
+
);
|
|
451
|
+
throw error;
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
export {
|
|
455
|
+
editIntegration,
|
|
456
|
+
getAuthenticationByIntegrationId,
|
|
457
|
+
getConfigurationByIntegrationId,
|
|
458
|
+
getIntegrationById,
|
|
459
|
+
getIntegrationGroups,
|
|
460
|
+
getWebhooksByIntegrationId,
|
|
461
|
+
listAllIntegrations,
|
|
462
|
+
pullIntegration,
|
|
463
|
+
purgeCache,
|
|
464
|
+
saveIntegration,
|
|
465
|
+
sendIntegrationForReview,
|
|
466
|
+
syncIntegration,
|
|
467
|
+
updateIntegration,
|
|
468
|
+
uploadFileToCloud,
|
|
469
|
+
};
|
package/api/login.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { handleError } from "../helper/error.js";
|
|
3
|
+
|
|
4
|
+
const getProductAccounts = async (consoleUrl, token, orgId) => {
|
|
5
|
+
try {
|
|
6
|
+
const response = await axios({
|
|
7
|
+
method: "get",
|
|
8
|
+
url: `${consoleUrl}/service/platform/payment/v1/productAccounts?orgId=${orgId}`,
|
|
9
|
+
headers: {
|
|
10
|
+
Cookie: `fc.session=${token}`,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
return response;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
handleError(error);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const getCliSession = async (apiUrl, requestCode) => {
|
|
20
|
+
try {
|
|
21
|
+
const response = await axios({
|
|
22
|
+
method: "get",
|
|
23
|
+
url: `${apiUrl}/service/auth/v1.0/authentication/cli/${requestCode}`,
|
|
24
|
+
headers: {
|
|
25
|
+
"Content-Type": "application/json",
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
return response;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
handleError(error);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const getCliBearerToken = async (apiUrl, account_id, session) => {
|
|
35
|
+
try {
|
|
36
|
+
const response = await axios({
|
|
37
|
+
method: "get",
|
|
38
|
+
url: `${apiUrl}/service/web/token/${account_id}`,
|
|
39
|
+
headers: {
|
|
40
|
+
"Content-Type": "application/json",
|
|
41
|
+
Cookie: `bolt.session=${session}`,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
return response;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
handleError(error);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export { getCliBearerToken, getCliSession, getProductAccounts };
|