@griffin-app/griffin-cli 1.0.21 → 1.0.23
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IntegrationCategory, Provider } from "@griffin-app/griffin-ts/types";
|
|
2
|
+
import type { IntegrationConfig, ProviderDefinition } from "@griffin-app/griffin-hub-sdk";
|
|
2
3
|
export interface IntegrationsListOptions {
|
|
3
4
|
category?: IntegrationCategory;
|
|
4
5
|
provider?: Provider;
|
|
@@ -16,7 +17,7 @@ export interface IntegrationsAddOptions {
|
|
|
16
17
|
category: IntegrationCategory;
|
|
17
18
|
provider: Provider;
|
|
18
19
|
name: string;
|
|
19
|
-
config?:
|
|
20
|
+
config?: IntegrationConfig;
|
|
20
21
|
environment: string;
|
|
21
22
|
enabled?: boolean;
|
|
22
23
|
json?: boolean;
|
|
@@ -25,7 +26,7 @@ export declare const executeIntegrationsAdd: (options: IntegrationsAddOptions) =
|
|
|
25
26
|
export interface IntegrationsUpdateOptions {
|
|
26
27
|
id: string;
|
|
27
28
|
name?: string;
|
|
28
|
-
config?:
|
|
29
|
+
config?: IntegrationConfig;
|
|
29
30
|
environment: string;
|
|
30
31
|
enabled?: boolean;
|
|
31
32
|
json?: boolean;
|
|
@@ -43,5 +44,5 @@ export interface IntegrationsConnectOptions {
|
|
|
43
44
|
environment: string;
|
|
44
45
|
json?: boolean;
|
|
45
46
|
}
|
|
46
|
-
export declare function printConnectHelp(): void;
|
|
47
|
+
export declare function printConnectHelp(providers: ProviderDefinition[]): void;
|
|
47
48
|
export declare function executeIntegrationsConnect(options: IntegrationsConnectOptions): Promise<void>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { loadState, resolveEnvironment } from "../../core/state.js";
|
|
2
2
|
import { terminal } from "../../utils/terminal.js";
|
|
3
|
-
import { getProvider, getProviders, getCategories, getAllProvidersByCategory, } from "../../providers/registry.js";
|
|
4
3
|
import { createSdkFromState, createSdkWithCredentials, } from "../../core/sdk.js";
|
|
5
4
|
import { withSDKErrorHandling } from "../../utils/sdk-error.js";
|
|
6
5
|
import { withCommandErrorHandler, outputJsonOrContinue, } from "../../utils/command-wrapper.js";
|
|
@@ -62,7 +61,7 @@ export const executeIntegrationsShow = withCommandErrorHandler(async (options) =
|
|
|
62
61
|
terminal.log(`Environment: ${integration.environment ?? "(all)"}`);
|
|
63
62
|
terminal.log(`Enabled: ${integration.enabled ? "Yes" : "No"}`);
|
|
64
63
|
terminal.log(`Has credentials: ${integration.hasCredentials ? "Yes" : "No"}`);
|
|
65
|
-
if (
|
|
64
|
+
if (integration?.config) {
|
|
66
65
|
terminal.log("Config: " + JSON.stringify(integration.config));
|
|
67
66
|
}
|
|
68
67
|
});
|
|
@@ -73,7 +72,7 @@ export const executeIntegrationsAdd = withCommandErrorHandler(async (options) =>
|
|
|
73
72
|
category: options.category,
|
|
74
73
|
provider: options.provider,
|
|
75
74
|
name: options.name,
|
|
76
|
-
config: options.config
|
|
75
|
+
config: options.config,
|
|
77
76
|
environment: env,
|
|
78
77
|
enabled: options.enabled ?? true,
|
|
79
78
|
};
|
|
@@ -131,15 +130,34 @@ export const executeIntegrationsRemove = withCommandErrorHandler(async (options)
|
|
|
131
130
|
const POLL_INITIAL_MS = 2000;
|
|
132
131
|
const POLL_MAX_MS = 10000;
|
|
133
132
|
const POLL_TIMEOUT_MS = 15 * 60 * 1000; // 15 minutes
|
|
134
|
-
|
|
133
|
+
/** Fetch provider catalog from hub. */
|
|
134
|
+
async function getProvidersFromHub() {
|
|
135
|
+
const sdk = await createSdkFromState();
|
|
136
|
+
const response = await withSDKErrorHandling(() => sdk.getIntegrationsProviders(), "Failed to load providers");
|
|
137
|
+
const data = response?.data;
|
|
138
|
+
if (!data?.providers)
|
|
139
|
+
return [];
|
|
140
|
+
return data.providers;
|
|
141
|
+
}
|
|
142
|
+
function buildProvidersByCategory(providers) {
|
|
143
|
+
const map = new Map();
|
|
144
|
+
for (const p of providers) {
|
|
145
|
+
const list = map.get(p.category) ?? [];
|
|
146
|
+
list.push(p);
|
|
147
|
+
map.set(p.category, list);
|
|
148
|
+
}
|
|
149
|
+
return map;
|
|
150
|
+
}
|
|
151
|
+
export function printConnectHelp(providers) {
|
|
135
152
|
terminal.log("Usage: griffin integrations connect <category> <provider> [options]");
|
|
136
153
|
terminal.blank();
|
|
137
154
|
terminal.log("Categories and Providers:");
|
|
138
|
-
const byCategory =
|
|
139
|
-
|
|
140
|
-
|
|
155
|
+
const byCategory = buildProvidersByCategory(providers);
|
|
156
|
+
const categories = [...byCategory.keys()].sort();
|
|
157
|
+
for (const category of categories) {
|
|
158
|
+
const list = byCategory.get(category) ?? [];
|
|
141
159
|
terminal.log(` ${category}`);
|
|
142
|
-
for (const p of
|
|
160
|
+
for (const p of list) {
|
|
143
161
|
terminal.log(` ${p.provider.padEnd(14)} ${p.displayName}`);
|
|
144
162
|
}
|
|
145
163
|
terminal.blank();
|
|
@@ -221,6 +239,26 @@ async function connectOAuth(options, _provider) {
|
|
|
221
239
|
terminal.exit(1);
|
|
222
240
|
}
|
|
223
241
|
}
|
|
242
|
+
function buildIntegrationConfig(provider, config) {
|
|
243
|
+
if (provider.provider === "resend") {
|
|
244
|
+
const fromAddress = config.fromAddress;
|
|
245
|
+
if (!fromAddress)
|
|
246
|
+
return undefined;
|
|
247
|
+
return {
|
|
248
|
+
providerType: "email",
|
|
249
|
+
fromAddress,
|
|
250
|
+
fromName: config.fromName,
|
|
251
|
+
replyTo: config.replyTo,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
if (provider.provider === "aws") {
|
|
255
|
+
const region = config.region;
|
|
256
|
+
if (!region)
|
|
257
|
+
return undefined;
|
|
258
|
+
return { providerType: "aws", region };
|
|
259
|
+
}
|
|
260
|
+
return undefined;
|
|
261
|
+
}
|
|
224
262
|
async function connectCredentials(options, provider) {
|
|
225
263
|
const env = await resolveEnvironment(options.environment);
|
|
226
264
|
const config = {};
|
|
@@ -245,11 +283,12 @@ async function connectCredentials(options, provider) {
|
|
|
245
283
|
if (value?.trim())
|
|
246
284
|
credentials[field.key] = value.trim();
|
|
247
285
|
}
|
|
286
|
+
const integrationConfig = buildIntegrationConfig(provider, config);
|
|
248
287
|
const body = {
|
|
249
288
|
category: options.category,
|
|
250
289
|
provider: options.provider,
|
|
251
290
|
name: options.name ?? provider.displayName,
|
|
252
|
-
config,
|
|
291
|
+
config: integrationConfig,
|
|
253
292
|
credentials: Object.keys(credentials).length > 0 ? credentials : undefined,
|
|
254
293
|
environment: env,
|
|
255
294
|
enabled: true,
|
|
@@ -257,7 +296,7 @@ async function connectCredentials(options, provider) {
|
|
|
257
296
|
const state = await loadState();
|
|
258
297
|
const sdk = await createSdkWithCredentials(state.hub.baseUrl);
|
|
259
298
|
const result = await sdk.postIntegrations({
|
|
260
|
-
body
|
|
299
|
+
body,
|
|
261
300
|
});
|
|
262
301
|
const integration = result.data?.data;
|
|
263
302
|
if (!integration) {
|
|
@@ -269,14 +308,15 @@ async function connectCredentials(options, provider) {
|
|
|
269
308
|
terminal.success(`Integration connected: ${integration.name} (${integration.id})`);
|
|
270
309
|
}
|
|
271
310
|
export async function executeIntegrationsConnect(options) {
|
|
311
|
+
const providers = await getProvidersFromHub();
|
|
272
312
|
if (!options.category || !options.provider) {
|
|
273
|
-
printConnectHelp();
|
|
313
|
+
printConnectHelp(providers);
|
|
274
314
|
return terminal.exit(0);
|
|
275
315
|
}
|
|
276
|
-
const providerDef =
|
|
316
|
+
const providerDef = providers.find((p) => p.category === options.category && p.provider === options.provider);
|
|
277
317
|
if (!providerDef) {
|
|
278
318
|
terminal.error(`Unknown provider: ${options.category}/${options.provider}`);
|
|
279
|
-
const providersForCategory =
|
|
319
|
+
const providersForCategory = providers.filter((p) => p.category === options.category);
|
|
280
320
|
if (providersForCategory.length > 0) {
|
|
281
321
|
terminal.info(`Available providers for ${options.category}:`);
|
|
282
322
|
for (const p of providersForCategory) {
|
|
@@ -284,7 +324,8 @@ export async function executeIntegrationsConnect(options) {
|
|
|
284
324
|
}
|
|
285
325
|
}
|
|
286
326
|
else {
|
|
287
|
-
|
|
327
|
+
const categories = [...new Set(providers.map((p) => p.category))].sort();
|
|
328
|
+
terminal.info("Available categories: " + categories.join(", "));
|
|
288
329
|
}
|
|
289
330
|
return terminal.exit(1);
|
|
290
331
|
}
|
|
@@ -40,7 +40,7 @@ export const executeNotificationsList = withCommandErrorHandler(async (options)
|
|
|
40
40
|
const enabled = rule.enabled ? "✓" : "✗";
|
|
41
41
|
table.push([
|
|
42
42
|
rule.id.substring(0, 8) + "...",
|
|
43
|
-
rule.
|
|
43
|
+
rule.monitor.name ?? "-",
|
|
44
44
|
rule.integrationName ?? "-",
|
|
45
45
|
triggerDesc,
|
|
46
46
|
enabled,
|
|
@@ -36,7 +36,7 @@ export const executeRuns = withCommandErrorHandler(async (options) => {
|
|
|
36
36
|
? `${(run.duration_ms / 1000).toFixed(2)}s`
|
|
37
37
|
: "-";
|
|
38
38
|
const started = new Date(run.startedAt).toLocaleString();
|
|
39
|
-
table.push([statusIcon, run.
|
|
39
|
+
table.push([statusIcon, run.monitor.name || "-", duration, started]);
|
|
40
40
|
}
|
|
41
41
|
catch (error) {
|
|
42
42
|
terminal.error(`Error processing run ${run.id}: ${error.message}`);
|
|
@@ -57,7 +57,7 @@ export const executeRuns = withCommandErrorHandler(async (options) => {
|
|
|
57
57
|
terminal.warn("Runs with errors:");
|
|
58
58
|
terminal.blank();
|
|
59
59
|
for (const run of runsWithErrors) {
|
|
60
|
-
terminal.log(`${terminal.colors.red("✗")} ${terminal.colors.cyan(run.
|
|
60
|
+
terminal.log(`${terminal.colors.red("✗")} ${terminal.colors.cyan(run.monitor.name)}`);
|
|
61
61
|
if (Array.isArray(run.errors) && run.errors.length > 0) {
|
|
62
62
|
const errorsToShow = run.errors.slice(0, 3);
|
|
63
63
|
for (const error of errorsToShow) {
|
|
@@ -24,35 +24,21 @@ const providers = [
|
|
|
24
24
|
authMethod: "credentials",
|
|
25
25
|
configFields: [{ key: "url", label: "Webhook URL", required: true }],
|
|
26
26
|
},
|
|
27
|
-
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
category: "notifications",
|
|
43
|
-
provider: "email",
|
|
44
|
-
displayName: "Email (SES)",
|
|
45
|
-
authMethod: "credentials",
|
|
46
|
-
configFields: [
|
|
47
|
-
{ key: "fromAddress", label: "From Address", required: true },
|
|
48
|
-
{ key: "sesRegion", label: "SES Region", required: true },
|
|
49
|
-
{
|
|
50
|
-
key: "toAddresses",
|
|
51
|
-
label: "To Addresses (comma-separated)",
|
|
52
|
-
required: true,
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
},
|
|
27
|
+
//{
|
|
28
|
+
// category: "notifications",
|
|
29
|
+
// provider: "email",
|
|
30
|
+
// displayName: "Email (SES)",
|
|
31
|
+
// authMethod: "credentials",
|
|
32
|
+
// configFields: [
|
|
33
|
+
// { key: "fromAddress", label: "From Address", required: true },
|
|
34
|
+
// { key: "sesRegion", label: "SES Region", required: true },
|
|
35
|
+
// {
|
|
36
|
+
// key: "toAddresses",
|
|
37
|
+
// label: "To Addresses (comma-separated)",
|
|
38
|
+
// required: true,
|
|
39
|
+
// },
|
|
40
|
+
// ],
|
|
41
|
+
//},
|
|
56
42
|
// Secrets - Credentials
|
|
57
43
|
{
|
|
58
44
|
category: "secrets",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griffin-app/griffin-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "CLI tool for running and managing griffin API tests",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"author": "",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@griffin-app/griffin-hub-sdk": "1.0.
|
|
28
|
-
"@griffin-app/griffin-plan-executor": "0.1.
|
|
29
|
-
"@griffin-app/griffin-ts": "0.1.
|
|
27
|
+
"@griffin-app/griffin-hub-sdk": "1.0.25",
|
|
28
|
+
"@griffin-app/griffin-plan-executor": "0.1.29",
|
|
29
|
+
"@griffin-app/griffin-ts": "0.1.27",
|
|
30
30
|
"better-auth": "^1.4.17",
|
|
31
31
|
"cli-table3": "^0.6.5",
|
|
32
32
|
"commander": "^12.1.0",
|