Skip to content

Commit 4139919

Browse files
Brandon CharlesonBrandon Charleson
authored andcommitted
feat(instantly): update all 20 step outputs to standardized format
- Wrap successful responses in { success: true, data: {...} } - Wrap errors in { success: false, error: { message: '...' } } - Follows AGENTS.md Step Output Format specification - All actions tested and verified working Actions updated: - Lead: create, get, list, update, delete, update-status, add-to-campaign - Campaign: create, get, list, update, delete, activate, pause - Account: list, get, pause, resume - Warmup: enable, disable
1 parent a488089 commit 4139919

20 files changed

+257
-200
lines changed

plugins/instantly/steps/activate-campaign.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type { InstantlyCredentials } from "../credentials";
77
const INSTANTLY_API_URL = "https://api.instantly.ai/api/v2";
88

99
type ActivateCampaignResult =
10-
| { success: true; id: string; status: string }
11-
| { success: false; error: string };
10+
| { success: true; data: { id: string; status: string } }
11+
| { success: false; error: { message: string } };
1212

1313
export type ActivateCampaignCoreInput = {
1414
campaignId: string;
@@ -26,11 +26,11 @@ async function stepHandler(
2626
const apiKey = credentials.INSTANTLY_API_KEY;
2727

2828
if (!apiKey) {
29-
return { success: false, error: "INSTANTLY_API_KEY is required" };
29+
return { success: false, error: { message: "INSTANTLY_API_KEY is required" } };
3030
}
3131

3232
if (!input.campaignId) {
33-
return { success: false, error: "Campaign ID is required" };
33+
return { success: false, error: { message: "Campaign ID is required" } };
3434
}
3535

3636
try {
@@ -46,23 +46,25 @@ async function stepHandler(
4646

4747
if (!response.ok) {
4848
if (response.status === 404) {
49-
return { success: false, error: "Campaign not found" };
49+
return { success: false, error: { message: "Campaign not found" } };
5050
}
5151
const errorText = await response.text();
5252
return {
5353
success: false,
54-
error: `Failed to activate campaign: ${response.status} - ${errorText}`,
54+
error: { message: `Failed to activate campaign: ${response.status} - ${errorText}` },
5555
};
5656
}
5757

5858
return {
5959
success: true,
60-
id: input.campaignId,
61-
status: "active",
60+
data: {
61+
id: input.campaignId,
62+
status: "active",
63+
},
6264
};
6365
} catch (error) {
6466
const message = error instanceof Error ? error.message : String(error);
65-
return { success: false, error: `Failed to activate campaign: ${message}` };
67+
return { success: false, error: { message: `Failed to activate campaign: ${message}` } };
6668
}
6769
}
6870

plugins/instantly/steps/add-lead-to-campaign.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type { InstantlyCredentials } from "../credentials";
77
const INSTANTLY_API_URL = "https://api.instantly.ai/api/v2";
88

99
type AddLeadToCampaignResult =
10-
| { success: true; id: string; campaignId: string }
11-
| { success: false; error: string };
10+
| { success: true; data: { id: string; campaignId: string } }
11+
| { success: false; error: { message: string } };
1212

1313
export type AddLeadToCampaignCoreInput = {
1414
campaignId: string;
@@ -27,15 +27,15 @@ async function stepHandler(
2727
const apiKey = credentials.INSTANTLY_API_KEY;
2828

2929
if (!apiKey) {
30-
return { success: false, error: "INSTANTLY_API_KEY is required" };
30+
return { success: false, error: { message: "INSTANTLY_API_KEY is required" } };
3131
}
3232

3333
if (!input.campaignId) {
34-
return { success: false, error: "Campaign ID is required" };
34+
return { success: false, error: { message: "Campaign ID is required" } };
3535
}
3636

3737
if (!input.email) {
38-
return { success: false, error: "Email is required" };
38+
return { success: false, error: { message: "Email is required" } };
3939
}
4040

4141
try {
@@ -56,22 +56,24 @@ async function stepHandler(
5656
const errorText = await response.text();
5757
return {
5858
success: false,
59-
error: `Failed to add lead to campaign: ${response.status} - ${errorText}`,
59+
error: { message: `Failed to add lead to campaign: ${response.status} - ${errorText}` },
6060
};
6161
}
6262

63-
const data = (await response.json()) as { id: string };
63+
const responseData = (await response.json()) as { id: string };
6464

6565
return {
6666
success: true,
67-
id: data.id || input.email,
68-
campaignId: input.campaignId,
67+
data: {
68+
id: responseData.id || input.email,
69+
campaignId: input.campaignId,
70+
},
6971
};
7072
} catch (error) {
7173
const message = error instanceof Error ? error.message : String(error);
7274
return {
7375
success: false,
74-
error: `Failed to add lead to campaign: ${message}`,
76+
error: { message: `Failed to add lead to campaign: ${message}` },
7577
};
7678
}
7779
}

plugins/instantly/steps/create-campaign.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type { InstantlyCredentials } from "../credentials";
77
const INSTANTLY_API_URL = "https://api.instantly.ai/api/v2";
88

99
type CreateCampaignResult =
10-
| { success: true; id: string; name: string }
11-
| { success: false; error: string };
10+
| { success: true; data: { id: string; name: string } }
11+
| { success: false; error: { message: string } };
1212

1313
export type CreateCampaignCoreInput = {
1414
name: string;
@@ -26,11 +26,11 @@ async function stepHandler(
2626
const apiKey = credentials.INSTANTLY_API_KEY;
2727

2828
if (!apiKey) {
29-
return { success: false, error: "INSTANTLY_API_KEY is required" };
29+
return { success: false, error: { message: "INSTANTLY_API_KEY is required" } };
3030
}
3131

3232
if (!input.name) {
33-
return { success: false, error: "Campaign name is required" };
33+
return { success: false, error: { message: "Campaign name is required" } };
3434
}
3535

3636
try {
@@ -74,20 +74,22 @@ async function stepHandler(
7474
const errorText = await response.text();
7575
return {
7676
success: false,
77-
error: `Failed to create campaign: ${response.status} - ${errorText}`,
77+
error: { message: `Failed to create campaign: ${response.status} - ${errorText}` },
7878
};
7979
}
8080

81-
const data = (await response.json()) as { id: string; name: string };
81+
const responseData = (await response.json()) as { id: string; name: string };
8282

8383
return {
8484
success: true,
85-
id: data.id,
86-
name: data.name,
85+
data: {
86+
id: responseData.id,
87+
name: responseData.name,
88+
},
8789
};
8890
} catch (error) {
8991
const message = error instanceof Error ? error.message : String(error);
90-
return { success: false, error: `Failed to create campaign: ${message}` };
92+
return { success: false, error: { message: `Failed to create campaign: ${message}` } };
9193
}
9294
}
9395

plugins/instantly/steps/create-lead.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type { InstantlyCredentials } from "../credentials";
77
const INSTANTLY_API_URL = "https://api.instantly.ai/api/v2";
88

99
type CreateLeadResult =
10-
| { success: true; id: string; email: string }
11-
| { success: false; error: string };
10+
| { success: true; data: { id: string; email: string } }
11+
| { success: false; error: { message: string } };
1212

1313
export type CreateLeadCoreInput = {
1414
campaignId: string;
@@ -34,15 +34,15 @@ async function stepHandler(
3434
const apiKey = credentials.INSTANTLY_API_KEY;
3535

3636
if (!apiKey) {
37-
return { success: false, error: "INSTANTLY_API_KEY is required" };
37+
return { success: false, error: { message: "INSTANTLY_API_KEY is required" } };
3838
}
3939

4040
if (!input.campaignId) {
41-
return { success: false, error: "Campaign ID is required" };
41+
return { success: false, error: { message: "Campaign ID is required" } };
4242
}
4343

4444
if (!input.email) {
45-
return { success: false, error: "Email is required" };
45+
return { success: false, error: { message: "Email is required" } };
4646
}
4747

4848
try {
@@ -51,7 +51,7 @@ async function stepHandler(
5151
try {
5252
customVars = JSON.parse(input.customVariables);
5353
} catch {
54-
return { success: false, error: "Invalid JSON in custom variables" };
54+
return { success: false, error: { message: "Invalid JSON in custom variables" } };
5555
}
5656
}
5757

@@ -80,20 +80,22 @@ async function stepHandler(
8080
const errorText = await response.text();
8181
return {
8282
success: false,
83-
error: `Failed to create lead: ${response.status} - ${errorText}`,
83+
error: { message: `Failed to create lead: ${response.status} - ${errorText}` },
8484
};
8585
}
8686

87-
const data = (await response.json()) as { id: string; email: string };
87+
const responseData = (await response.json()) as { id: string; email: string };
8888

8989
return {
9090
success: true,
91-
id: data.id,
92-
email: data.email,
91+
data: {
92+
id: responseData.id,
93+
email: responseData.email,
94+
},
9395
};
9496
} catch (error) {
9597
const message = error instanceof Error ? error.message : String(error);
96-
return { success: false, error: `Failed to create lead: ${message}` };
98+
return { success: false, error: { message: `Failed to create lead: ${message}` } };
9799
}
98100
}
99101

plugins/instantly/steps/delete-campaign.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type { InstantlyCredentials } from "../credentials";
77
const INSTANTLY_API_URL = "https://api.instantly.ai/api/v2";
88

99
type DeleteCampaignResult =
10-
| { success: true; deleted: boolean }
11-
| { success: false; error: string };
10+
| { success: true; data: { deleted: boolean } }
11+
| { success: false; error: { message: string } };
1212

1313
export type DeleteCampaignCoreInput = {
1414
campaignId: string;
@@ -26,11 +26,11 @@ async function stepHandler(
2626
const apiKey = credentials.INSTANTLY_API_KEY;
2727

2828
if (!apiKey) {
29-
return { success: false, error: "INSTANTLY_API_KEY is required" };
29+
return { success: false, error: { message: "INSTANTLY_API_KEY is required" } };
3030
}
3131

3232
if (!input.campaignId) {
33-
return { success: false, error: "Campaign ID is required" };
33+
return { success: false, error: { message: "Campaign ID is required" } };
3434
}
3535

3636
try {
@@ -46,22 +46,22 @@ async function stepHandler(
4646

4747
if (!response.ok) {
4848
if (response.status === 404) {
49-
return { success: false, error: "Campaign not found" };
49+
return { success: false, error: { message: "Campaign not found" } };
5050
}
5151
const errorText = await response.text();
5252
return {
5353
success: false,
54-
error: `Failed to delete campaign: ${response.status} - ${errorText}`,
54+
error: { message: `Failed to delete campaign: ${response.status} - ${errorText}` },
5555
};
5656
}
5757

5858
return {
5959
success: true,
60-
deleted: true,
60+
data: { deleted: true },
6161
};
6262
} catch (error) {
6363
const message = error instanceof Error ? error.message : String(error);
64-
return { success: false, error: `Failed to delete campaign: ${message}` };
64+
return { success: false, error: { message: `Failed to delete campaign: ${message}` } };
6565
}
6666
}
6767

plugins/instantly/steps/delete-lead.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type { InstantlyCredentials } from "../credentials";
77
const INSTANTLY_API_URL = "https://api.instantly.ai/api/v2";
88

99
type DeleteLeadResult =
10-
| { success: true; deleted: boolean }
11-
| { success: false; error: string };
10+
| { success: true; data: { deleted: boolean } }
11+
| { success: false; error: { message: string } };
1212

1313
export type DeleteLeadCoreInput = {
1414
leadId: string;
@@ -26,11 +26,11 @@ async function stepHandler(
2626
const apiKey = credentials.INSTANTLY_API_KEY;
2727

2828
if (!apiKey) {
29-
return { success: false, error: "INSTANTLY_API_KEY is required" };
29+
return { success: false, error: { message: "INSTANTLY_API_KEY is required" } };
3030
}
3131

3232
if (!input.leadId) {
33-
return { success: false, error: "Lead ID is required" };
33+
return { success: false, error: { message: "Lead ID is required" } };
3434
}
3535

3636
try {
@@ -43,22 +43,22 @@ async function stepHandler(
4343

4444
if (!response.ok) {
4545
if (response.status === 404) {
46-
return { success: false, error: "Lead not found" };
46+
return { success: false, error: { message: "Lead not found" } };
4747
}
4848
const errorText = await response.text();
4949
return {
5050
success: false,
51-
error: `Failed to delete lead: ${response.status} - ${errorText}`,
51+
error: { message: `Failed to delete lead: ${response.status} - ${errorText}` },
5252
};
5353
}
5454

5555
return {
5656
success: true,
57-
deleted: true,
57+
data: { deleted: true },
5858
};
5959
} catch (error) {
6060
const message = error instanceof Error ? error.message : String(error);
61-
return { success: false, error: `Failed to delete lead: ${message}` };
61+
return { success: false, error: { message: `Failed to delete lead: ${message}` } };
6262
}
6363
}
6464

plugins/instantly/steps/disable-warmup.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type { InstantlyCredentials } from "../credentials";
77
const INSTANTLY_API_URL = "https://api.instantly.ai/api/v2";
88

99
type DisableWarmupResult =
10-
| { success: true; disabled: boolean }
11-
| { success: false; error: string };
10+
| { success: true; data: { disabled: boolean } }
11+
| { success: false; error: { message: string } };
1212

1313
export type DisableWarmupCoreInput = {
1414
emails: string;
@@ -26,11 +26,11 @@ async function stepHandler(
2626
const apiKey = credentials.INSTANTLY_API_KEY;
2727

2828
if (!apiKey) {
29-
return { success: false, error: "INSTANTLY_API_KEY is required" };
29+
return { success: false, error: { message: "INSTANTLY_API_KEY is required" } };
3030
}
3131

3232
if (!input.emails) {
33-
return { success: false, error: "At least one email is required" };
33+
return { success: false, error: { message: "At least one email is required" } };
3434
}
3535

3636
try {
@@ -41,7 +41,7 @@ async function stepHandler(
4141
.filter((e) => e.length > 0);
4242

4343
if (emailList.length === 0) {
44-
return { success: false, error: "At least one valid email is required" };
44+
return { success: false, error: { message: "At least one valid email is required" } };
4545
}
4646

4747
const response = await fetch(
@@ -62,17 +62,17 @@ async function stepHandler(
6262
const errorText = await response.text();
6363
return {
6464
success: false,
65-
error: `Failed to disable warmup: ${response.status} - ${errorText}`,
65+
error: { message: `Failed to disable warmup: ${response.status} - ${errorText}` },
6666
};
6767
}
6868

6969
return {
7070
success: true,
71-
disabled: true,
71+
data: { disabled: true },
7272
};
7373
} catch (error) {
7474
const message = error instanceof Error ? error.message : String(error);
75-
return { success: false, error: `Failed to disable warmup: ${message}` };
75+
return { success: false, error: { message: `Failed to disable warmup: ${message}` } };
7676
}
7777
}
7878

0 commit comments

Comments
 (0)