lua-cli 3.2.0 → 3.4.0
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/dist/api/logs.api.service.d.ts +1 -1
- package/dist/api/logs.api.service.js.map +1 -1
- package/dist/api/products.api.service.d.ts +17 -5
- package/dist/api/products.api.service.js +21 -9
- package/dist/api/products.api.service.js.map +1 -1
- package/dist/api/webhook.api.service.d.ts +4 -0
- package/dist/api/webhook.api.service.js.map +1 -1
- package/dist/api-exports.d.ts +19 -7
- package/dist/api-exports.js +20 -5
- package/dist/api-exports.js.map +1 -1
- package/dist/cli/command-definitions.js +323 -88
- package/dist/cli/command-definitions.js.map +1 -1
- package/dist/commands/apiKey.d.ts +5 -2
- package/dist/commands/apiKey.js +8 -2
- package/dist/commands/apiKey.js.map +1 -1
- package/dist/commands/channels.d.ts +4 -9
- package/dist/commands/channels.js +140 -84
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/chat.d.ts +4 -2
- package/dist/commands/chat.js +126 -32
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/chatClear.d.ts +3 -2
- package/dist/commands/chatClear.js +16 -15
- package/dist/commands/chatClear.js.map +1 -1
- package/dist/commands/compile.d.ts +5 -4
- package/dist/commands/compile.js +73 -9
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/deploy.d.ts +5 -24
- package/dist/commands/deploy.js +75 -48
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/destroy.d.ts +5 -2
- package/dist/commands/destroy.js +14 -2
- package/dist/commands/destroy.js.map +1 -1
- package/dist/commands/env.d.ts +3 -1
- package/dist/commands/env.js +322 -122
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/features.d.ts +5 -9
- package/dist/commands/features.js +249 -129
- package/dist/commands/features.js.map +1 -1
- package/dist/commands/init.d.ts +7 -1
- package/dist/commands/init.js +242 -59
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/jobs.d.ts +5 -13
- package/dist/commands/jobs.js +523 -360
- package/dist/commands/jobs.js.map +1 -1
- package/dist/commands/logs.d.ts +5 -10
- package/dist/commands/logs.js +259 -103
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/marketplace.d.ts +23 -2
- package/dist/commands/marketplace.js +530 -7
- package/dist/commands/marketplace.js.map +1 -1
- package/dist/commands/mcp.d.ts +5 -11
- package/dist/commands/mcp.js +304 -294
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/persona.d.ts +5 -9
- package/dist/commands/persona.js +349 -232
- package/dist/commands/persona.js.map +1 -1
- package/dist/commands/postprocessors.d.ts +6 -2
- package/dist/commands/postprocessors.js +387 -280
- package/dist/commands/postprocessors.js.map +1 -1
- package/dist/commands/preprocessors.d.ts +6 -2
- package/dist/commands/preprocessors.js +387 -280
- package/dist/commands/preprocessors.js.map +1 -1
- package/dist/commands/production.d.ts +5 -8
- package/dist/commands/production.js +317 -228
- package/dist/commands/production.js.map +1 -1
- package/dist/commands/push.js +385 -427
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/resources.d.ts +5 -10
- package/dist/commands/resources.js +219 -154
- package/dist/commands/resources.js.map +1 -1
- package/dist/commands/skills.d.ts +5 -9
- package/dist/commands/skills.js +435 -275
- package/dist/commands/skills.js.map +1 -1
- package/dist/commands/sync.d.ts +10 -8
- package/dist/commands/sync.js +110 -19
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/test.d.ts +1 -11
- package/dist/commands/test.js +395 -438
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/webhooks.d.ts +5 -11
- package/dist/commands/webhooks.js +431 -287
- package/dist/commands/webhooks.js.map +1 -1
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/interfaces/mcp.d.ts +39 -19
- package/dist/interfaces/mcp.js +3 -0
- package/dist/interfaces/mcp.js.map +1 -1
- package/dist/interfaces/product.d.ts +26 -0
- package/dist/interfaces/skills.d.ts +5 -0
- package/dist/types/api-contracts.d.ts +8 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/skill.d.ts +146 -35
- package/dist/types/skill.js +31 -37
- package/dist/types/skill.js.map +1 -1
- package/dist/utils/bundling.d.ts +17 -0
- package/dist/utils/bundling.js +96 -0
- package/dist/utils/bundling.js.map +1 -1
- package/dist/utils/compile.d.ts +4 -0
- package/dist/utils/compile.js +5 -0
- package/dist/utils/compile.js.map +1 -1
- package/dist/utils/dev-helpers.d.ts +3 -2
- package/dist/utils/dev-helpers.js +3 -5
- package/dist/utils/dev-helpers.js.map +1 -1
- package/dist/utils/job-management.d.ts +4 -1
- package/dist/utils/job-management.js +15 -29
- package/dist/utils/job-management.js.map +1 -1
- package/dist/utils/mcp-server-management.d.ts +5 -2
- package/dist/utils/mcp-server-management.js +27 -43
- package/dist/utils/mcp-server-management.js.map +1 -1
- package/dist/utils/push-helpers.d.ts +1 -1
- package/dist/utils/push-helpers.js +5 -1
- package/dist/utils/push-helpers.js.map +1 -1
- package/dist/utils/skill-management.d.ts +7 -2
- package/dist/utils/skill-management.js +21 -30
- package/dist/utils/skill-management.js.map +1 -1
- package/dist/utils/webhook-management.d.ts +4 -1
- package/dist/utils/webhook-management.js +15 -29
- package/dist/utils/webhook-management.js.map +1 -1
- package/package.json +1 -1
- package/template/package.json +1 -1
|
@@ -9,22 +9,23 @@ import { BASE_URLS } from '../config/constants.js';
|
|
|
9
9
|
import { safePrompt } from '../utils/prompt-handler.js';
|
|
10
10
|
import { validateConfig, validateAgentConfig, } from '../utils/dev-helpers.js';
|
|
11
11
|
import WebhookApi from '../api/webhook.api.service.js';
|
|
12
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
13
|
+
// Main Command Entry
|
|
14
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
12
15
|
/**
|
|
13
|
-
* Main webhooks command - manages agent webhooks
|
|
16
|
+
* Main webhooks command - manages agent webhooks.
|
|
14
17
|
*
|
|
15
|
-
*
|
|
16
|
-
* -
|
|
17
|
-
* -
|
|
18
|
-
* - Deploy webhook versions to production
|
|
19
|
-
* - Activate/deactivate webhooks
|
|
20
|
-
*
|
|
21
|
-
* Note: For local testing, use `lua test webhook`
|
|
22
|
-
*
|
|
23
|
-
* @returns Promise that resolves when command completes
|
|
18
|
+
* Supports both interactive and non-interactive modes:
|
|
19
|
+
* - Interactive: prompts for action and webhook selection
|
|
20
|
+
* - Non-interactive: use action argument with -i and -v flags
|
|
24
21
|
*/
|
|
25
|
-
export async function webhooksCommand() {
|
|
22
|
+
export async function webhooksCommand(action, cmdObj) {
|
|
26
23
|
return withErrorHandling(async () => {
|
|
27
|
-
|
|
24
|
+
const options = {
|
|
25
|
+
webhookName: cmdObj?.webhookName || null,
|
|
26
|
+
webhookVersion: cmdObj?.webhookVersion || null,
|
|
27
|
+
};
|
|
28
|
+
// Step 1: Load configuration
|
|
28
29
|
const config = readSkillConfig();
|
|
29
30
|
validateConfig(config);
|
|
30
31
|
validateAgentConfig(config);
|
|
@@ -42,14 +43,331 @@ export async function webhooksCommand() {
|
|
|
42
43
|
agentId,
|
|
43
44
|
apiKey,
|
|
44
45
|
};
|
|
45
|
-
//
|
|
46
|
-
|
|
46
|
+
// Determine mode
|
|
47
|
+
if (action) {
|
|
48
|
+
await executeNonInteractive(context, config, action, options);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
await manageWebhooksInteractive(context, config);
|
|
52
|
+
}
|
|
47
53
|
}, "webhooks");
|
|
48
54
|
}
|
|
55
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
56
|
+
// Shared Core Functions
|
|
57
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
58
|
+
/**
|
|
59
|
+
* Displays all webhooks with their current status.
|
|
60
|
+
*/
|
|
61
|
+
async function displayWebhooksCore(context, webhooks) {
|
|
62
|
+
console.log("\n" + "=".repeat(60));
|
|
63
|
+
console.log("⚙️ Production Webhooks");
|
|
64
|
+
console.log("=".repeat(60) + "\n");
|
|
65
|
+
const webhookApi = new WebhookApi(BASE_URLS.API, context.apiKey, context.agentId);
|
|
66
|
+
for (const webhook of webhooks) {
|
|
67
|
+
try {
|
|
68
|
+
const response = await webhookApi.getWebhookVersions(webhook.webhookId);
|
|
69
|
+
if (response.success && response.data) {
|
|
70
|
+
const versions = response.data.versions || [];
|
|
71
|
+
const activeVersionId = response.data.activeVersionId;
|
|
72
|
+
const activeVersion = versions.find((v) => v.webhookId === activeVersionId);
|
|
73
|
+
console.log(`🪝 ${webhook.name}`);
|
|
74
|
+
console.log(` Webhook ID: ${webhook.webhookId}`);
|
|
75
|
+
if (activeVersion) {
|
|
76
|
+
console.log(` Deployed Version: ${activeVersion.version} ⭐`);
|
|
77
|
+
console.log(` Deployed: ${new Date(activeVersion.createdAt).toLocaleString()}`);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
console.log(` Deployed Version: Not deployed`);
|
|
81
|
+
}
|
|
82
|
+
console.log(` Total Versions: ${versions.length}`);
|
|
83
|
+
console.log();
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
displayWebhookError(webhook, "Unable to fetch version info");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
displayWebhookError(webhook, "Error loading versions");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
console.log("=".repeat(60));
|
|
94
|
+
}
|
|
95
|
+
function displayWebhookError(webhook, status) {
|
|
96
|
+
console.log(`🪝 ${webhook.name}`);
|
|
97
|
+
console.log(` Webhook ID: ${webhook.webhookId}`);
|
|
98
|
+
console.log(` Status: ${status}`);
|
|
99
|
+
console.log();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Fetches and returns sorted webhook versions.
|
|
103
|
+
*/
|
|
104
|
+
async function fetchVersionsCore(context, webhook) {
|
|
105
|
+
const webhookApi = new WebhookApi(BASE_URLS.API, context.apiKey, context.agentId);
|
|
106
|
+
const response = await webhookApi.getWebhookVersions(webhook.webhookId);
|
|
107
|
+
if (!response.success || !response.data) {
|
|
108
|
+
console.error(`❌ Failed to fetch versions: ${response.error?.message || 'Unknown error'}`);
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
const versions = (response.data.versions || []).sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
|
|
112
|
+
return { versions, activeVersionId: response.data.activeVersionId };
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Displays versions for a webhook.
|
|
116
|
+
*/
|
|
117
|
+
function displayVersionsCore(webhook, versions, activeVersionId) {
|
|
118
|
+
console.log("\n" + "=".repeat(60));
|
|
119
|
+
console.log(`📜 Versions for ${webhook.name}`);
|
|
120
|
+
console.log("=".repeat(60) + "\n");
|
|
121
|
+
versions.forEach((version, index) => {
|
|
122
|
+
const isActive = version.webhookId === activeVersionId;
|
|
123
|
+
console.log(`${index + 1}. Version ${version.version}${isActive ? ' ⭐ DEPLOYED' : ''}`);
|
|
124
|
+
console.log(` Created: ${new Date(version.createdAt).toLocaleString()}`);
|
|
125
|
+
console.log(` Version ID: ${version.webhookId}`);
|
|
126
|
+
console.log();
|
|
127
|
+
});
|
|
128
|
+
console.log("=".repeat(60));
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Deploys a specific version of a webhook.
|
|
132
|
+
*/
|
|
133
|
+
async function deployVersionCore(context, webhook, version) {
|
|
134
|
+
writeProgress(`🔄 Deploying version ${version} of "${webhook.name}"...`);
|
|
135
|
+
const webhookApi = new WebhookApi(BASE_URLS.API, context.apiKey, context.agentId);
|
|
136
|
+
const deployResponse = await webhookApi.publishWebhookVersion(webhook.webhookId, version);
|
|
137
|
+
if (!deployResponse.success) {
|
|
138
|
+
console.error(`❌ Deploy Error: ${deployResponse.error?.message || 'Unknown error'}`);
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
writeSuccess(`✅ Version ${version} of "${webhook.name}" deployed successfully`);
|
|
142
|
+
writeInfo("💡 The new version is now active for all users.");
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Activates a webhook.
|
|
147
|
+
*/
|
|
148
|
+
async function activateWebhookCore(context, webhook) {
|
|
149
|
+
writeProgress(`🔄 Activating webhook "${webhook.name}"...`);
|
|
150
|
+
const webhookApi = new WebhookApi(BASE_URLS.API, context.apiKey, context.agentId);
|
|
151
|
+
const response = await webhookApi.activateWebhook(webhook.webhookId);
|
|
152
|
+
if (response.success) {
|
|
153
|
+
writeSuccess(`✅ Webhook "${webhook.name}" activated successfully`);
|
|
154
|
+
writeInfo("💡 The webhook is now enabled and can receive requests.");
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
console.error(`❌ Failed to activate webhook: ${response.error?.message || 'Unknown error'}`);
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Deactivates a webhook.
|
|
164
|
+
*/
|
|
165
|
+
async function deactivateWebhookCore(context, webhook) {
|
|
166
|
+
writeProgress(`🔄 Deactivating webhook "${webhook.name}"...`);
|
|
167
|
+
const webhookApi = new WebhookApi(BASE_URLS.API, context.apiKey, context.agentId);
|
|
168
|
+
const response = await webhookApi.deactivateWebhook(webhook.webhookId);
|
|
169
|
+
if (response.success) {
|
|
170
|
+
writeSuccess(`✅ Webhook "${webhook.name}" deactivated successfully`);
|
|
171
|
+
writeInfo("💡 The webhook is now disabled and will not receive requests.");
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
console.error(`❌ Failed to deactivate webhook: ${response.error?.message || 'Unknown error'}`);
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Deletes a webhook from the server.
|
|
181
|
+
* If the webhook has versions, it will be deactivated instead of deleted.
|
|
182
|
+
*/
|
|
183
|
+
async function deleteWebhookCore(context, webhook) {
|
|
184
|
+
writeProgress(`🗑️ Deleting webhook "${webhook.name}"...`);
|
|
185
|
+
const webhookApi = new WebhookApi(BASE_URLS.API, context.apiKey, context.agentId);
|
|
186
|
+
const response = await webhookApi.deleteWebhook(webhook.webhookId);
|
|
187
|
+
if (!response.success || !response.data) {
|
|
188
|
+
console.error(`❌ Delete Error: ${response.error?.message || 'Unknown error'}`);
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
if (response.data.deleted) {
|
|
192
|
+
writeSuccess(`✅ Webhook "${webhook.name}" deleted successfully`);
|
|
193
|
+
writeInfo("💡 Remove this webhook from your lua.skill.yaml to keep it in sync.");
|
|
194
|
+
}
|
|
195
|
+
else if (response.data.deactivated) {
|
|
196
|
+
writeSuccess(`⚠️ Webhook "${webhook.name}" has versions and was deactivated instead of deleted`);
|
|
197
|
+
writeInfo("💡 The webhook is now inactive and won't receive requests.");
|
|
198
|
+
}
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Resolves a version string to an actual version, supporting "latest".
|
|
203
|
+
*/
|
|
204
|
+
function resolveVersion(versions, versionArg) {
|
|
205
|
+
if (versionArg.toLowerCase() === 'latest') {
|
|
206
|
+
return versions[0].version;
|
|
207
|
+
}
|
|
208
|
+
const exists = versions.some((v) => v.version === versionArg);
|
|
209
|
+
if (!exists) {
|
|
210
|
+
console.error(`❌ Version "${versionArg}" not found`);
|
|
211
|
+
console.log('\nAvailable versions:');
|
|
212
|
+
versions.slice(0, 5).forEach((v) => console.log(` - ${v.version}`));
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
return versionArg;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Prompts user to select a webhook from a list.
|
|
219
|
+
*/
|
|
220
|
+
async function promptWebhookSelection(webhooks, message) {
|
|
221
|
+
const answer = await safePrompt([
|
|
222
|
+
{
|
|
223
|
+
type: 'list',
|
|
224
|
+
name: 'selectedWebhook',
|
|
225
|
+
message,
|
|
226
|
+
choices: webhooks.map((webhook) => ({
|
|
227
|
+
name: `${webhook.name} (${webhook.webhookId})`,
|
|
228
|
+
value: webhook
|
|
229
|
+
}))
|
|
230
|
+
}
|
|
231
|
+
]);
|
|
232
|
+
return answer?.selectedWebhook || null;
|
|
233
|
+
}
|
|
49
234
|
/**
|
|
50
|
-
*
|
|
235
|
+
* Prompts user to select a version from a list.
|
|
51
236
|
*/
|
|
52
|
-
async function
|
|
237
|
+
async function promptVersionSelection(versions, activeVersionId) {
|
|
238
|
+
const answer = await safePrompt([
|
|
239
|
+
{
|
|
240
|
+
type: 'list',
|
|
241
|
+
name: 'selectedVersion',
|
|
242
|
+
message: 'Select a version to deploy:',
|
|
243
|
+
choices: versions.map((version) => {
|
|
244
|
+
const isActive = version.webhookId === activeVersionId;
|
|
245
|
+
return {
|
|
246
|
+
name: `Version ${version.version} (${new Date(version.createdAt).toLocaleDateString()})${isActive ? ' ⭐ CURRENT' : ''}`,
|
|
247
|
+
value: version
|
|
248
|
+
};
|
|
249
|
+
})
|
|
250
|
+
}
|
|
251
|
+
]);
|
|
252
|
+
return answer?.selectedVersion || null;
|
|
253
|
+
}
|
|
254
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
255
|
+
// Non-Interactive Mode
|
|
256
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
257
|
+
async function executeNonInteractive(context, config, action, options) {
|
|
258
|
+
const validActions = ['view', 'versions', 'deploy', 'activate', 'deactivate', 'delete'];
|
|
259
|
+
const normalizedAction = action.toLowerCase();
|
|
260
|
+
if (!validActions.includes(normalizedAction)) {
|
|
261
|
+
console.error(`❌ Invalid action: "${action}"`);
|
|
262
|
+
console.log('\nValid actions: view, versions, deploy, activate, deactivate, delete');
|
|
263
|
+
console.log('\nExamples:');
|
|
264
|
+
console.log(' lua webhooks view List all webhooks');
|
|
265
|
+
console.log(' lua webhooks activate -i myWebhook Activate a webhook');
|
|
266
|
+
console.log(' lua webhooks deploy -i myWebhook -v 1.0.3 Deploy specific version');
|
|
267
|
+
console.log(' lua webhooks delete -i myWebhook Delete a webhook');
|
|
268
|
+
process.exit(1);
|
|
269
|
+
}
|
|
270
|
+
const webhooks = config.webhooks || [];
|
|
271
|
+
// View action doesn't require webhook selection
|
|
272
|
+
if (normalizedAction === 'view') {
|
|
273
|
+
if (webhooks.length === 0) {
|
|
274
|
+
console.log("ℹ️ No webhooks found in configuration.");
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
await displayWebhooksCore(context, webhooks);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
// All other actions require webhook selection
|
|
281
|
+
if (!options.webhookName) {
|
|
282
|
+
console.error(`❌ --webhook-name is required for action "${normalizedAction}"`);
|
|
283
|
+
console.log(`\nUsage: lua webhooks ${normalizedAction} --webhook-name <name>`);
|
|
284
|
+
process.exit(1);
|
|
285
|
+
}
|
|
286
|
+
let selectedWebhook = webhooks.find((w) => w.webhookId === options.webhookName || w.name === options.webhookName);
|
|
287
|
+
// For delete action, also check server webhooks (for orphaned webhooks not in local YAML)
|
|
288
|
+
if (!selectedWebhook && normalizedAction === 'delete') {
|
|
289
|
+
const webhookApi = new WebhookApi(BASE_URLS.API, context.apiKey, context.agentId);
|
|
290
|
+
const serverResponse = await webhookApi.getWebhooks();
|
|
291
|
+
if (serverResponse.success && serverResponse.data?.webhooks) {
|
|
292
|
+
const serverWebhook = serverResponse.data.webhooks.find((w) => w.id === options.webhookName || w.name === options.webhookName);
|
|
293
|
+
if (serverWebhook) {
|
|
294
|
+
// Map server webhook format to local format for deleteWebhookCore
|
|
295
|
+
selectedWebhook = {
|
|
296
|
+
name: serverWebhook.name,
|
|
297
|
+
webhookId: serverWebhook.id,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
if (!selectedWebhook) {
|
|
303
|
+
console.error(`❌ Webhook "${options.webhookName}" not found`);
|
|
304
|
+
console.log('\nAvailable webhooks in local config:');
|
|
305
|
+
webhooks.forEach((w) => console.log(` - ${w.name} (${w.webhookId})`));
|
|
306
|
+
if (normalizedAction === 'delete') {
|
|
307
|
+
console.log('\n💡 Tip: The webhook may have already been deleted from the server.');
|
|
308
|
+
}
|
|
309
|
+
process.exit(1);
|
|
310
|
+
}
|
|
311
|
+
switch (normalizedAction) {
|
|
312
|
+
case 'versions': {
|
|
313
|
+
const data = await fetchVersionsCore(context, selectedWebhook);
|
|
314
|
+
if (!data)
|
|
315
|
+
process.exit(1);
|
|
316
|
+
if (data.versions.length === 0) {
|
|
317
|
+
console.log(`ℹ️ No versions found for ${selectedWebhook.name}.`);
|
|
318
|
+
console.log("💡 Push a version first using 'lua push webhook'.");
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
displayVersionsCore(selectedWebhook, data.versions, data.activeVersionId);
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
case 'deploy': {
|
|
325
|
+
if (!options.webhookVersion) {
|
|
326
|
+
console.error('❌ --webhook-version is required for deploy action');
|
|
327
|
+
console.log('\nUsage: lua webhooks deploy --webhook-name myWebhook --webhook-version 1.0.3');
|
|
328
|
+
console.log(' lua webhooks deploy -i myWebhook -v latest');
|
|
329
|
+
process.exit(1);
|
|
330
|
+
}
|
|
331
|
+
const data = await fetchVersionsCore(context, selectedWebhook);
|
|
332
|
+
if (!data)
|
|
333
|
+
process.exit(1);
|
|
334
|
+
if (data.versions.length === 0) {
|
|
335
|
+
console.error(`❌ No versions found for ${selectedWebhook.name}.`);
|
|
336
|
+
console.log("💡 Push a version first using 'lua push webhook'.");
|
|
337
|
+
process.exit(1);
|
|
338
|
+
}
|
|
339
|
+
const resolvedVersion = resolveVersion(data.versions, options.webhookVersion);
|
|
340
|
+
if (!resolvedVersion)
|
|
341
|
+
process.exit(1);
|
|
342
|
+
const success = await deployVersionCore(context, selectedWebhook, resolvedVersion);
|
|
343
|
+
if (!success)
|
|
344
|
+
process.exit(1);
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
case 'activate': {
|
|
348
|
+
const success = await activateWebhookCore(context, selectedWebhook);
|
|
349
|
+
if (!success)
|
|
350
|
+
process.exit(1);
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
case 'deactivate': {
|
|
354
|
+
const success = await deactivateWebhookCore(context, selectedWebhook);
|
|
355
|
+
if (!success)
|
|
356
|
+
process.exit(1);
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
case 'delete': {
|
|
360
|
+
const success = await deleteWebhookCore(context, selectedWebhook);
|
|
361
|
+
if (!success)
|
|
362
|
+
process.exit(1);
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
368
|
+
// Interactive Mode
|
|
369
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
370
|
+
async function manageWebhooksInteractive(context, config) {
|
|
53
371
|
let continueManaging = true;
|
|
54
372
|
while (continueManaging) {
|
|
55
373
|
console.log("\n" + "=".repeat(60));
|
|
@@ -66,6 +384,7 @@ async function manageProductionWebhooks(context, config) {
|
|
|
66
384
|
{ name: '🚀 Deploy a version', value: 'deploy' },
|
|
67
385
|
{ name: '✅ Activate a webhook', value: 'activate' },
|
|
68
386
|
{ name: '🚫 Deactivate a webhook', value: 'deactivate' },
|
|
387
|
+
{ name: '🗑️ Delete a webhook', value: 'delete' },
|
|
69
388
|
{ name: '❌ Exit', value: 'exit' }
|
|
70
389
|
]
|
|
71
390
|
}
|
|
@@ -75,19 +394,22 @@ async function manageProductionWebhooks(context, config) {
|
|
|
75
394
|
const { action } = actionAnswer;
|
|
76
395
|
switch (action) {
|
|
77
396
|
case 'view':
|
|
78
|
-
await
|
|
397
|
+
await viewWebhooksInteractive(context, config);
|
|
79
398
|
break;
|
|
80
399
|
case 'versions':
|
|
81
|
-
await
|
|
400
|
+
await viewVersionsInteractive(context, config);
|
|
82
401
|
break;
|
|
83
402
|
case 'deploy':
|
|
84
|
-
await
|
|
403
|
+
await deployVersionInteractive(context, config);
|
|
85
404
|
break;
|
|
86
405
|
case 'activate':
|
|
87
|
-
await
|
|
406
|
+
await activateWebhookInteractive(context, config);
|
|
88
407
|
break;
|
|
89
408
|
case 'deactivate':
|
|
90
|
-
await
|
|
409
|
+
await deactivateWebhookInteractive(context, config);
|
|
410
|
+
break;
|
|
411
|
+
case 'delete':
|
|
412
|
+
await deleteWebhookInteractive(context, config);
|
|
91
413
|
break;
|
|
92
414
|
case 'exit':
|
|
93
415
|
continueManaging = false;
|
|
@@ -96,303 +418,112 @@ async function manageProductionWebhooks(context, config) {
|
|
|
96
418
|
}
|
|
97
419
|
}
|
|
98
420
|
}
|
|
99
|
-
|
|
100
|
-
* View deployed webhooks in production
|
|
101
|
-
*/
|
|
102
|
-
async function viewDeployedWebhooks(context, config) {
|
|
421
|
+
async function viewWebhooksInteractive(context, config) {
|
|
103
422
|
writeProgress("🔄 Loading webhook information...");
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
console.log("\nℹ️ No webhooks found in configuration.\n");
|
|
108
|
-
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
console.log("\n" + "=".repeat(60));
|
|
112
|
-
console.log("⚙️ Production Webhooks");
|
|
113
|
-
console.log("=".repeat(60) + "\n");
|
|
114
|
-
const webhookApi = new WebhookApi(BASE_URLS.API, context.apiKey, context.agentId);
|
|
115
|
-
// Fetch version info for each webhook
|
|
116
|
-
for (const webhook of webhooks) {
|
|
117
|
-
try {
|
|
118
|
-
const response = await webhookApi.getWebhookVersions(webhook.webhookId);
|
|
119
|
-
if (response.success && response.data) {
|
|
120
|
-
const versions = response.data.versions || [];
|
|
121
|
-
const activeVersionId = response.data.activeVersionId;
|
|
122
|
-
// Find active version
|
|
123
|
-
const activeVersion = versions.find((v) => v.webhookId === activeVersionId);
|
|
124
|
-
console.log(`🪝 ${webhook.name}`);
|
|
125
|
-
console.log(` Webhook ID: ${webhook.webhookId}`);
|
|
126
|
-
if (activeVersion) {
|
|
127
|
-
console.log(` Deployed Version: ${activeVersion.version} ⭐`);
|
|
128
|
-
const date = new Date(activeVersion.createdAt);
|
|
129
|
-
console.log(` Deployed: ${date.toLocaleString()}`);
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
console.log(` Deployed Version: Not deployed`);
|
|
133
|
-
}
|
|
134
|
-
console.log(` Total Versions: ${versions.length}`);
|
|
135
|
-
console.log();
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
console.log(`🪝 ${webhook.name}`);
|
|
139
|
-
console.log(` Webhook ID: ${webhook.webhookId}`);
|
|
140
|
-
console.log(` Status: Unable to fetch version info`);
|
|
141
|
-
console.log();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
catch (error) {
|
|
145
|
-
console.log(`🪝 ${webhook.name}`);
|
|
146
|
-
console.log(` Webhook ID: ${webhook.webhookId}`);
|
|
147
|
-
console.log(` Status: Error loading versions`);
|
|
148
|
-
console.log();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
console.log("=".repeat(60) + "\n");
|
|
152
|
-
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
423
|
+
const webhooks = config.webhooks || [];
|
|
424
|
+
if (webhooks.length === 0) {
|
|
425
|
+
console.log("\nℹ️ No webhooks found in configuration.\n");
|
|
153
426
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
427
|
+
else {
|
|
428
|
+
await displayWebhooksCore(context, webhooks);
|
|
429
|
+
console.log();
|
|
157
430
|
}
|
|
431
|
+
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
158
432
|
}
|
|
159
|
-
|
|
160
|
-
* View versions for a specific webhook
|
|
161
|
-
*/
|
|
162
|
-
async function viewWebhookVersions(context, config) {
|
|
433
|
+
async function viewVersionsInteractive(context, config) {
|
|
163
434
|
const webhooks = config.webhooks || [];
|
|
164
435
|
if (webhooks.length === 0) {
|
|
165
436
|
console.log("\nℹ️ No webhooks found in configuration.\n");
|
|
166
437
|
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
167
438
|
return;
|
|
168
439
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
{
|
|
172
|
-
type: 'list',
|
|
173
|
-
name: 'selectedWebhook',
|
|
174
|
-
message: 'Select a webhook to view versions:',
|
|
175
|
-
choices: webhooks.map((webhook) => ({
|
|
176
|
-
name: `${webhook.name} (${webhook.webhookId})`,
|
|
177
|
-
value: webhook
|
|
178
|
-
}))
|
|
179
|
-
}
|
|
180
|
-
]);
|
|
181
|
-
if (!webhookAnswer)
|
|
440
|
+
const selectedWebhook = await promptWebhookSelection(webhooks, 'Select a webhook to view versions:');
|
|
441
|
+
if (!selectedWebhook)
|
|
182
442
|
return;
|
|
183
|
-
const selectedWebhook = webhookAnswer.selectedWebhook;
|
|
184
443
|
writeProgress(`🔄 Loading versions for ${selectedWebhook.name}...`);
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
method: 'GET',
|
|
188
|
-
headers: {
|
|
189
|
-
'Authorization': `Bearer ${context.apiKey}`,
|
|
190
|
-
'Content-Type': 'application/json'
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
if (!response.ok) {
|
|
194
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
195
|
-
}
|
|
196
|
-
const data = await response.json();
|
|
197
|
-
const versions = data.data?.versions || data.versions || [];
|
|
198
|
-
const activeVersionId = data.data?.activeVersionId || data.activeVersionId;
|
|
199
|
-
if (versions.length === 0) {
|
|
200
|
-
console.log(`\nℹ️ No versions found for ${selectedWebhook.name}.\n`);
|
|
201
|
-
console.log("💡 Push a version first using 'lua push webhook'.\n");
|
|
202
|
-
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
console.log("\n" + "=".repeat(60));
|
|
206
|
-
console.log(`📜 Versions for ${selectedWebhook.name}`);
|
|
207
|
-
console.log("=".repeat(60) + "\n");
|
|
208
|
-
// Sort versions by date (newest first)
|
|
209
|
-
const sortedVersions = versions.sort((a, b) => {
|
|
210
|
-
const dateA = new Date(a.createdAt).getTime();
|
|
211
|
-
const dateB = new Date(b.createdAt).getTime();
|
|
212
|
-
return dateB - dateA;
|
|
213
|
-
});
|
|
214
|
-
sortedVersions.forEach((version, index) => {
|
|
215
|
-
const isActive = version.webhookId === activeVersionId;
|
|
216
|
-
const date = new Date(version.createdAt);
|
|
217
|
-
console.log(`${index + 1}. Version ${version.version}${isActive ? ' ⭐ DEPLOYED' : ''}`);
|
|
218
|
-
console.log(` Created: ${date.toLocaleString()}`);
|
|
219
|
-
console.log(` Version ID: ${version.webhookId}`);
|
|
220
|
-
console.log();
|
|
221
|
-
});
|
|
222
|
-
console.log("=".repeat(60) + "\n");
|
|
444
|
+
const data = await fetchVersionsCore(context, selectedWebhook);
|
|
445
|
+
if (!data) {
|
|
223
446
|
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
447
|
+
return;
|
|
224
448
|
}
|
|
225
|
-
|
|
226
|
-
console.
|
|
227
|
-
|
|
449
|
+
if (data.versions.length === 0) {
|
|
450
|
+
console.log(`\nℹ️ No versions found for ${selectedWebhook.name}.\n`);
|
|
451
|
+
console.log("💡 Push a version first using 'lua push webhook'.\n");
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
displayVersionsCore(selectedWebhook, data.versions, data.activeVersionId);
|
|
455
|
+
console.log();
|
|
228
456
|
}
|
|
457
|
+
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
229
458
|
}
|
|
230
|
-
|
|
231
|
-
* Deploy a webhook version to production
|
|
232
|
-
*/
|
|
233
|
-
async function deployWebhookVersion(context, config) {
|
|
459
|
+
async function deployVersionInteractive(context, config) {
|
|
234
460
|
const webhooks = config.webhooks || [];
|
|
235
461
|
if (webhooks.length === 0) {
|
|
236
462
|
console.log("\nℹ️ No webhooks found in configuration.\n");
|
|
237
463
|
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
238
464
|
return;
|
|
239
465
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
{
|
|
243
|
-
type: 'list',
|
|
244
|
-
name: 'selectedWebhook',
|
|
245
|
-
message: 'Select a webhook to deploy:',
|
|
246
|
-
choices: webhooks.map((webhook) => ({
|
|
247
|
-
name: `${webhook.name} (${webhook.webhookId})`,
|
|
248
|
-
value: webhook
|
|
249
|
-
}))
|
|
250
|
-
}
|
|
251
|
-
]);
|
|
252
|
-
if (!webhookAnswer)
|
|
466
|
+
const selectedWebhook = await promptWebhookSelection(webhooks, 'Select a webhook to deploy:');
|
|
467
|
+
if (!selectedWebhook)
|
|
253
468
|
return;
|
|
254
|
-
const selectedWebhook = webhookAnswer.selectedWebhook;
|
|
255
469
|
writeProgress(`🔄 Loading versions for ${selectedWebhook.name}...`);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const response = await webhookApi.getWebhookVersions(selectedWebhook.webhookId);
|
|
259
|
-
if (!response.success || !response.data) {
|
|
260
|
-
throw new Error(response.error?.message || 'Failed to fetch versions');
|
|
261
|
-
}
|
|
262
|
-
const versions = response.data.versions || [];
|
|
263
|
-
const activeVersionId = response.data.activeVersionId;
|
|
264
|
-
if (versions.length === 0) {
|
|
265
|
-
console.log(`\nℹ️ No versions found for ${selectedWebhook.name}.\n`);
|
|
266
|
-
console.log("💡 Push a version first using 'lua push webhook'.\n");
|
|
267
|
-
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
// Sort versions by date (newest first)
|
|
271
|
-
const sortedVersions = versions.sort((a, b) => {
|
|
272
|
-
const dateA = new Date(a.createdAt).getTime();
|
|
273
|
-
const dateB = new Date(b.createdAt).getTime();
|
|
274
|
-
return dateB - dateA;
|
|
275
|
-
});
|
|
276
|
-
// Prompt to select a version
|
|
277
|
-
const versionAnswer = await safePrompt([
|
|
278
|
-
{
|
|
279
|
-
type: 'list',
|
|
280
|
-
name: 'selectedVersion',
|
|
281
|
-
message: 'Select a version to deploy:',
|
|
282
|
-
choices: sortedVersions.map((version) => {
|
|
283
|
-
const isActive = version.webhookId === activeVersionId;
|
|
284
|
-
const date = new Date(version.createdAt);
|
|
285
|
-
return {
|
|
286
|
-
name: `Version ${version.version} (${date.toLocaleDateString()})${isActive ? ' ⭐ CURRENT' : ''}`,
|
|
287
|
-
value: version
|
|
288
|
-
};
|
|
289
|
-
})
|
|
290
|
-
}
|
|
291
|
-
]);
|
|
292
|
-
if (!versionAnswer)
|
|
293
|
-
return;
|
|
294
|
-
const selectedVersion = versionAnswer.selectedVersion;
|
|
295
|
-
// Show warning
|
|
296
|
-
console.log("\n⚠️ WARNING: You are about to deploy to PRODUCTION!");
|
|
297
|
-
console.log("⚠️ This will affect ALL users immediately.\n");
|
|
298
|
-
console.log(`Webhook: ${selectedWebhook.name}`);
|
|
299
|
-
console.log(`Version: ${selectedVersion.version}\n`);
|
|
300
|
-
const confirmAnswer = await safePrompt([
|
|
301
|
-
{
|
|
302
|
-
type: 'confirm',
|
|
303
|
-
name: 'confirm',
|
|
304
|
-
message: 'Are you absolutely sure you want to deploy this version?',
|
|
305
|
-
default: false
|
|
306
|
-
}
|
|
307
|
-
]);
|
|
308
|
-
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
309
|
-
console.log("\n❌ Deployment cancelled.\n");
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
writeProgress("🔄 Deploying version...");
|
|
313
|
-
// Reuse the same webhookApi instance
|
|
314
|
-
const deployResponse = await webhookApi.publishWebhookVersion(selectedWebhook.webhookId, selectedVersion.version);
|
|
315
|
-
if (!deployResponse.success) {
|
|
316
|
-
console.error(`\n❌ Deploy Error: ${deployResponse.error?.message || 'Unknown error'}\n`);
|
|
317
|
-
throw new Error(deployResponse.error?.message || 'Failed to publish webhook version');
|
|
318
|
-
}
|
|
319
|
-
writeSuccess(`\n✅ Version ${selectedVersion.version} of "${selectedWebhook.name}" deployed successfully to production\n`);
|
|
320
|
-
writeInfo("💡 The new version is now active for all users.");
|
|
470
|
+
const data = await fetchVersionsCore(context, selectedWebhook);
|
|
471
|
+
if (!data) {
|
|
321
472
|
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
473
|
+
return;
|
|
322
474
|
}
|
|
323
|
-
|
|
324
|
-
console.
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* Activate a webhook
|
|
330
|
-
*/
|
|
331
|
-
async function activateWebhook(context, config) {
|
|
332
|
-
const webhooks = config.webhooks || [];
|
|
333
|
-
if (webhooks.length === 0) {
|
|
334
|
-
console.log("\nℹ️ No webhooks found in configuration.\n");
|
|
475
|
+
if (data.versions.length === 0) {
|
|
476
|
+
console.log(`\nℹ️ No versions found for ${selectedWebhook.name}.\n`);
|
|
477
|
+
console.log("💡 Push a version first using 'lua push webhook'.\n");
|
|
335
478
|
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
336
479
|
return;
|
|
337
480
|
}
|
|
338
|
-
|
|
339
|
-
|
|
481
|
+
const selectedVersion = await promptVersionSelection(data.versions, data.activeVersionId);
|
|
482
|
+
if (!selectedVersion)
|
|
483
|
+
return;
|
|
484
|
+
// Show warning and confirm
|
|
485
|
+
console.log("\n⚠️ WARNING: You are about to deploy to PRODUCTION!");
|
|
486
|
+
console.log("⚠️ This will affect ALL users immediately.\n");
|
|
487
|
+
console.log(`Webhook: ${selectedWebhook.name}`);
|
|
488
|
+
console.log(`Version: ${selectedVersion.version}\n`);
|
|
489
|
+
const confirmAnswer = await safePrompt([
|
|
340
490
|
{
|
|
341
|
-
type: '
|
|
342
|
-
name: '
|
|
343
|
-
message: '
|
|
344
|
-
|
|
345
|
-
name: `${webhook.name} (${webhook.webhookId})`,
|
|
346
|
-
value: webhook
|
|
347
|
-
}))
|
|
491
|
+
type: 'confirm',
|
|
492
|
+
name: 'confirm',
|
|
493
|
+
message: 'Are you absolutely sure you want to deploy this version?',
|
|
494
|
+
default: false
|
|
348
495
|
}
|
|
349
496
|
]);
|
|
350
|
-
if (!
|
|
497
|
+
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
498
|
+
console.log("\n❌ Deployment cancelled.\n");
|
|
351
499
|
return;
|
|
352
|
-
const selectedWebhook = webhookAnswer.selectedWebhook;
|
|
353
|
-
writeProgress(`🔄 Activating webhook "${selectedWebhook.name}"...`);
|
|
354
|
-
try {
|
|
355
|
-
const webhookApi = new WebhookApi(BASE_URLS.API, context.apiKey, context.agentId);
|
|
356
|
-
const response = await webhookApi.activateWebhook(selectedWebhook.webhookId);
|
|
357
|
-
if (!response.success) {
|
|
358
|
-
console.error(`\n❌ Error: ${response.error?.message || 'Unknown error'}\n`);
|
|
359
|
-
throw new Error(response.error?.message || 'Failed to activate webhook');
|
|
360
|
-
}
|
|
361
|
-
writeSuccess(`\n✅ Webhook "${selectedWebhook.name}" activated successfully\n`);
|
|
362
|
-
writeInfo("💡 The webhook is now enabled and can receive requests.");
|
|
363
|
-
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
364
500
|
}
|
|
365
|
-
|
|
366
|
-
|
|
501
|
+
await deployVersionCore(context, selectedWebhook, selectedVersion.version);
|
|
502
|
+
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
503
|
+
}
|
|
504
|
+
async function activateWebhookInteractive(context, config) {
|
|
505
|
+
const webhooks = config.webhooks || [];
|
|
506
|
+
if (webhooks.length === 0) {
|
|
507
|
+
console.log("\nℹ️ No webhooks found in configuration.\n");
|
|
367
508
|
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
509
|
+
return;
|
|
368
510
|
}
|
|
511
|
+
const selectedWebhook = await promptWebhookSelection(webhooks, 'Select a webhook to activate:');
|
|
512
|
+
if (!selectedWebhook)
|
|
513
|
+
return;
|
|
514
|
+
await activateWebhookCore(context, selectedWebhook);
|
|
515
|
+
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
369
516
|
}
|
|
370
|
-
|
|
371
|
-
* Deactivate a webhook
|
|
372
|
-
*/
|
|
373
|
-
async function deactivateWebhook(context, config) {
|
|
517
|
+
async function deactivateWebhookInteractive(context, config) {
|
|
374
518
|
const webhooks = config.webhooks || [];
|
|
375
519
|
if (webhooks.length === 0) {
|
|
376
520
|
console.log("\nℹ️ No webhooks found in configuration.\n");
|
|
377
521
|
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
378
522
|
return;
|
|
379
523
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
{
|
|
383
|
-
type: 'list',
|
|
384
|
-
name: 'selectedWebhook',
|
|
385
|
-
message: 'Select a webhook to deactivate:',
|
|
386
|
-
choices: webhooks.map((webhook) => ({
|
|
387
|
-
name: `${webhook.name} (${webhook.webhookId})`,
|
|
388
|
-
value: webhook
|
|
389
|
-
}))
|
|
390
|
-
}
|
|
391
|
-
]);
|
|
392
|
-
if (!webhookAnswer)
|
|
524
|
+
const selectedWebhook = await promptWebhookSelection(webhooks, 'Select a webhook to deactivate:');
|
|
525
|
+
if (!selectedWebhook)
|
|
393
526
|
return;
|
|
394
|
-
const selectedWebhook = webhookAnswer.selectedWebhook;
|
|
395
|
-
// Confirm deactivation
|
|
396
527
|
const confirmAnswer = await safePrompt([
|
|
397
528
|
{
|
|
398
529
|
type: 'confirm',
|
|
@@ -405,21 +536,34 @@ async function deactivateWebhook(context, config) {
|
|
|
405
536
|
console.log("\n❌ Deactivation cancelled.\n");
|
|
406
537
|
return;
|
|
407
538
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}
|
|
416
|
-
writeSuccess(`\n✅ Webhook "${selectedWebhook.name}" deactivated successfully\n`);
|
|
417
|
-
writeInfo("💡 The webhook is now disabled and will not receive requests.");
|
|
539
|
+
await deactivateWebhookCore(context, selectedWebhook);
|
|
540
|
+
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
541
|
+
}
|
|
542
|
+
async function deleteWebhookInteractive(context, config) {
|
|
543
|
+
const webhooks = config.webhooks || [];
|
|
544
|
+
if (webhooks.length === 0) {
|
|
545
|
+
console.log("\nℹ️ No webhooks found in configuration.\n");
|
|
418
546
|
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
547
|
+
return;
|
|
419
548
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
549
|
+
const selectedWebhook = await promptWebhookSelection(webhooks, 'Select a webhook to delete:');
|
|
550
|
+
if (!selectedWebhook)
|
|
551
|
+
return;
|
|
552
|
+
console.log("\n⚠️ WARNING: You are about to delete a webhook!");
|
|
553
|
+
console.log("⚠️ If the webhook has versions, it will be deactivated instead.\n");
|
|
554
|
+
const confirmAnswer = await safePrompt([
|
|
555
|
+
{
|
|
556
|
+
type: 'confirm',
|
|
557
|
+
name: 'confirm',
|
|
558
|
+
message: `Are you sure you want to delete "${selectedWebhook.name}"?`,
|
|
559
|
+
default: false
|
|
560
|
+
}
|
|
561
|
+
]);
|
|
562
|
+
if (!confirmAnswer || !confirmAnswer.confirm) {
|
|
563
|
+
console.log("\n❌ Deletion cancelled.\n");
|
|
564
|
+
return;
|
|
423
565
|
}
|
|
566
|
+
await deleteWebhookCore(context, selectedWebhook);
|
|
567
|
+
await safePrompt([{ type: 'input', name: 'continue', message: 'Press Enter to continue...' }]);
|
|
424
568
|
}
|
|
425
569
|
//# sourceMappingURL=webhooks.js.map
|