runline 0.1.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/.pi/extensions/runline-context/index.ts +135 -0
- package/.pi/extensions/runline-context/package.json +17 -0
- package/README.md +273 -0
- package/dist/commands/actions.d.ts +3 -0
- package/dist/commands/actions.js +43 -0
- package/dist/commands/connection.d.ts +11 -0
- package/dist/commands/connection.js +56 -0
- package/dist/commands/exec.d.ts +5 -0
- package/dist/commands/exec.js +46 -0
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.js +26 -0
- package/dist/commands/plugin.d.ts +10 -0
- package/dist/commands/plugin.js +57 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +2 -0
- package/dist/config/loader.d.ts +11 -0
- package/dist/config/loader.js +82 -0
- package/dist/config/types.d.ts +9 -0
- package/dist/config/types.js +5 -0
- package/dist/core/engine.d.ts +21 -0
- package/dist/core/engine.js +280 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +9 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +127 -0
- package/dist/plugin/api.d.ts +32 -0
- package/dist/plugin/api.js +68 -0
- package/dist/plugin/installer.d.ts +27 -0
- package/dist/plugin/installer.js +181 -0
- package/dist/plugin/loader.d.ts +13 -0
- package/dist/plugin/loader.js +164 -0
- package/dist/plugin/registry.d.ts +18 -0
- package/dist/plugin/registry.js +43 -0
- package/dist/plugin/types.d.ts +40 -0
- package/dist/plugin/types.js +1 -0
- package/dist/plugins/actionNetwork/src/index.js +353 -0
- package/dist/plugins/activeCampaign/src/index.js +711 -0
- package/dist/plugins/adalo/src/index.js +131 -0
- package/dist/plugins/affinity/src/index.js +279 -0
- package/dist/plugins/agileCrm/src/index.js +415 -0
- package/dist/plugins/airtable/src/index.js +280 -0
- package/dist/plugins/airtop/src/index.js +527 -0
- package/dist/plugins/apiTemplateIo/src/index.js +86 -0
- package/dist/plugins/asana/src/index.js +413 -0
- package/dist/plugins/autopilot/src/index.js +203 -0
- package/dist/plugins/bambooHr/src/index.js +252 -0
- package/dist/plugins/bannerbear/src/index.js +100 -0
- package/dist/plugins/baserow/src/index.js +180 -0
- package/dist/plugins/beeminder/src/index.js +298 -0
- package/dist/plugins/bitly/src/index.js +107 -0
- package/dist/plugins/bitwarden/src/index.js +383 -0
- package/dist/plugins/box/src/index.js +300 -0
- package/dist/plugins/brandfetch/src/index.js +80 -0
- package/dist/plugins/brevo/src/index.js +305 -0
- package/dist/plugins/bubble/src/index.js +181 -0
- package/dist/plugins/chargebee/src/index.js +126 -0
- package/dist/plugins/circleci/src/index.js +111 -0
- package/dist/plugins/ciscoWebex/src/index.js +245 -0
- package/dist/plugins/clearbit/src/index.js +103 -0
- package/dist/plugins/clickup/src/index.js +1043 -0
- package/dist/plugins/clockify/src/index.js +443 -0
- package/dist/plugins/cloudflare/src/index.js +93 -0
- package/dist/plugins/cockpit/src/index.js +131 -0
- package/dist/plugins/coda/src/index.js +327 -0
- package/dist/plugins/coingecko/src/index.js +244 -0
- package/dist/plugins/contentful/src/index.js +146 -0
- package/dist/plugins/convertkit/src/index.js +270 -0
- package/dist/plugins/copper/src/index.js +140 -0
- package/dist/plugins/cortex/src/index.js +147 -0
- package/dist/plugins/currents/src/index.js +405 -0
- package/dist/plugins/customerIo/src/index.js +184 -0
- package/dist/plugins/databricks/src/index.js +342 -0
- package/dist/plugins/deepl/src/index.js +87 -0
- package/dist/plugins/demio/src/index.js +111 -0
- package/dist/plugins/dhl/src/index.js +40 -0
- package/dist/plugins/discord/src/index.js +275 -0
- package/dist/plugins/discourse/src/index.js +273 -0
- package/dist/plugins/disqus/src/index.js +145 -0
- package/dist/plugins/docker/src/index.js +76 -0
- package/dist/plugins/drift/src/index.js +89 -0
- package/dist/plugins/dropbox/src/index.js +159 -0
- package/dist/plugins/dropcontact/src/index.js +59 -0
- package/dist/plugins/egoi/src/index.js +151 -0
- package/dist/plugins/elasticsearch/src/index.js +157 -0
- package/dist/plugins/emelia/src/index.js +174 -0
- package/dist/plugins/erpnext/src/index.js +121 -0
- package/dist/plugins/facebookGraph/src/index.js +57 -0
- package/dist/plugins/freshdesk/src/index.js +320 -0
- package/dist/plugins/freshservice/src/index.js +146 -0
- package/dist/plugins/freshworksCrm/src/index.js +149 -0
- package/dist/plugins/getresponse/src/index.js +140 -0
- package/dist/plugins/ghost/src/index.js +192 -0
- package/dist/plugins/github/src/index.js +630 -0
- package/dist/plugins/gitlab/src/index.js +358 -0
- package/dist/plugins/gong/src/index.js +126 -0
- package/dist/plugins/gotify/src/index.js +77 -0
- package/dist/plugins/gotowebinar/src/index.js +316 -0
- package/dist/plugins/grafana/src/index.js +250 -0
- package/dist/plugins/graphql/src/index.js +78 -0
- package/dist/plugins/grist/src/index.js +106 -0
- package/dist/plugins/hackernews/src/index.js +89 -0
- package/dist/plugins/halopsa/src/index.js +79 -0
- package/dist/plugins/harvest/src/index.js +163 -0
- package/dist/plugins/helpscout/src/index.js +176 -0
- package/dist/plugins/highlevel/src/index.js +172 -0
- package/dist/plugins/homeAssistant/src/index.js +148 -0
- package/dist/plugins/hubspot/src/index.js +176 -0
- package/dist/plugins/humanticAi/src/index.js +60 -0
- package/dist/plugins/hunter/src/index.js +59 -0
- package/dist/plugins/intercom/src/index.js +156 -0
- package/dist/plugins/iterable/src/index.js +139 -0
- package/dist/plugins/jenkins/src/index.js +132 -0
- package/dist/plugins/jira/src/index.js +229 -0
- package/dist/plugins/keap/src/index.js +502 -0
- package/dist/plugins/kobotoolbox/src/index.js +281 -0
- package/dist/plugins/lemlist/src/index.js +231 -0
- package/dist/plugins/linear/src/index.js +133 -0
- package/dist/plugins/lingvanex/src/index.js +31 -0
- package/dist/plugins/linkedin/src/index.js +80 -0
- package/dist/plugins/lonescale/src/index.js +119 -0
- package/dist/plugins/magento/src/index.js +300 -0
- package/dist/plugins/mailcheck/src/index.js +27 -0
- package/dist/plugins/mailchimp/src/index.js +321 -0
- package/dist/plugins/mailerlite/src/index.js +123 -0
- package/dist/plugins/mailgun/src/index.js +48 -0
- package/dist/plugins/mailjet/src/index.js +155 -0
- package/dist/plugins/mandrill/src/index.js +145 -0
- package/dist/plugins/marketstack/src/index.js +97 -0
- package/dist/plugins/matrix/src/index.js +194 -0
- package/dist/plugins/mattermost/src/index.js +331 -0
- package/dist/plugins/mautic/src/index.js +311 -0
- package/dist/plugins/medium/src/index.js +77 -0
- package/dist/plugins/messagebird/src/index.js +57 -0
- package/dist/plugins/metabase/src/index.js +130 -0
- package/dist/plugins/misp/src/index.js +476 -0
- package/dist/plugins/mocean/src/index.js +67 -0
- package/dist/plugins/monday/src/index.js +231 -0
- package/dist/plugins/monicaCrm/src/index.js +52 -0
- package/dist/plugins/msg91/src/index.js +31 -0
- package/dist/plugins/nasa/src/index.js +146 -0
- package/dist/plugins/netlify/src/index.js +151 -0
- package/dist/plugins/netscalerAdc/src/index.js +131 -0
- package/dist/plugins/nextcloud/src/index.js +263 -0
- package/dist/plugins/nocodb/src/index.js +130 -0
- package/dist/plugins/notion/src/index.js +112 -0
- package/dist/plugins/npm/src/index.js +104 -0
- package/dist/plugins/odoo/src/index.js +157 -0
- package/dist/plugins/okta/src/index.js +141 -0
- package/dist/plugins/oneSimpleApi/src/index.js +155 -0
- package/dist/plugins/onfleet/src/index.js +254 -0
- package/dist/plugins/openThesaurus/src/index.js +32 -0
- package/dist/plugins/openweathermap/src/index.js +60 -0
- package/dist/plugins/oura/src/index.js +62 -0
- package/dist/plugins/paddle/src/index.js +247 -0
- package/dist/plugins/pagerduty/src/index.js +201 -0
- package/dist/plugins/paypal/src/index.js +106 -0
- package/dist/plugins/peekalink/src/index.js +35 -0
- package/dist/plugins/phantombuster/src/index.js +94 -0
- package/dist/plugins/philipsHue/src/index.js +98 -0
- package/dist/plugins/pipedrive/src/index.js +169 -0
- package/dist/plugins/plivo/src/index.js +66 -0
- package/dist/plugins/postbin/src/index.js +93 -0
- package/dist/plugins/posthog/src/index.js +113 -0
- package/dist/plugins/profitwell/src/index.js +50 -0
- package/dist/plugins/pushbullet/src/index.js +102 -0
- package/dist/plugins/pushcut/src/index.js +39 -0
- package/dist/plugins/pushover/src/index.js +65 -0
- package/dist/plugins/quickbase/src/index.js +153 -0
- package/dist/plugins/quickbooks/src/index.js +73 -0
- package/dist/plugins/quickchart/src/index.js +36 -0
- package/dist/plugins/raindrop/src/index.js +209 -0
- package/dist/plugins/reddit/src/index.js +185 -0
- package/dist/plugins/rocketchat/src/index.js +53 -0
- package/dist/plugins/rundeck/src/index.js +62 -0
- package/dist/plugins/salesforce/src/index.js +94 -0
- package/dist/plugins/salesmate/src/index.js +83 -0
- package/dist/plugins/securityScorecard/src/index.js +200 -0
- package/dist/plugins/segment/src/index.js +125 -0
- package/dist/plugins/sendgrid/src/index.js +187 -0
- package/dist/plugins/sendy/src/index.js +138 -0
- package/dist/plugins/sentry/src/index.js +233 -0
- package/dist/plugins/servicenow/src/index.js +108 -0
- package/dist/plugins/shopify/src/index.js +222 -0
- package/dist/plugins/signl4/src/index.js +61 -0
- package/dist/plugins/slack/src/index.js +236 -0
- package/dist/plugins/sms77/src/index.js +63 -0
- package/dist/plugins/splunk/src/index.js +207 -0
- package/dist/plugins/spotify/src/index.js +188 -0
- package/dist/plugins/stackby/src/index.js +82 -0
- package/dist/plugins/storyblok/src/index.js +141 -0
- package/dist/plugins/strapi/src/index.js +152 -0
- package/dist/plugins/strava/src/index.js +137 -0
- package/dist/plugins/stripe/src/index.js +222 -0
- package/dist/plugins/supabase/src/index.js +121 -0
- package/dist/plugins/syncromsp/src/index.js +255 -0
- package/dist/plugins/tapfiliate/src/index.js +125 -0
- package/dist/plugins/telegram/src/index.js +233 -0
- package/dist/plugins/thehive/src/index.js +142 -0
- package/dist/plugins/thehiveProject/src/index.js +194 -0
- package/dist/plugins/todoist/src/index.js +244 -0
- package/dist/plugins/travisci/src/index.js +71 -0
- package/dist/plugins/trello/src/index.js +341 -0
- package/dist/plugins/twake/src/index.js +40 -0
- package/dist/plugins/twilio/src/index.js +75 -0
- package/dist/plugins/twist/src/index.js +90 -0
- package/dist/plugins/twitter/src/index.js +123 -0
- package/dist/plugins/unleashedSoftware/src/index.js +84 -0
- package/dist/plugins/uplead/src/index.js +59 -0
- package/dist/plugins/uproc/src/index.js +34 -0
- package/dist/plugins/uptimerobot/src/index.js +264 -0
- package/dist/plugins/urlscanio/src/index.js +64 -0
- package/dist/plugins/vero/src/index.js +80 -0
- package/dist/plugins/vonage/src/index.js +42 -0
- package/dist/plugins/wekan/src/index.js +91 -0
- package/dist/plugins/woocommerce/src/index.js +92 -0
- package/dist/plugins/wordpress/src/index.js +121 -0
- package/dist/plugins/xero/src/index.js +136 -0
- package/dist/plugins/yourls/src/index.js +56 -0
- package/dist/plugins/zammad/src/index.js +91 -0
- package/dist/plugins/zendesk/src/index.js +137 -0
- package/dist/plugins/zoho/src/index.js +85 -0
- package/dist/plugins/zoom/src/index.js +122 -0
- package/dist/plugins/zulip/src/index.js +170 -0
- package/dist/sdk.d.ts +38 -0
- package/dist/sdk.js +105 -0
- package/dist/utils/cli.d.ts +13 -0
- package/dist/utils/cli.js +32 -0
- package/dist/utils/output.d.ts +4 -0
- package/dist/utils/output.js +13 -0
- package/package.json +57 -0
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
const BASE_URL = "https://api.infusionsoft.com/crm/rest/v1";
|
|
2
|
+
async function apiRequest(token, method, endpoint, body, qs) {
|
|
3
|
+
const url = new URL(`${BASE_URL}${endpoint}`);
|
|
4
|
+
if (qs) {
|
|
5
|
+
for (const [k, v] of Object.entries(qs)) {
|
|
6
|
+
if (v !== undefined && v !== null)
|
|
7
|
+
url.searchParams.set(k, String(v));
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const opts = { method, headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" } };
|
|
11
|
+
if (body && Object.keys(body).length > 0 && method !== "GET" && method !== "DELETE")
|
|
12
|
+
opts.body = JSON.stringify(body);
|
|
13
|
+
const res = await fetch(url.toString(), opts);
|
|
14
|
+
if (!res.ok)
|
|
15
|
+
throw new Error(`Keap API error ${res.status}: ${await res.text()}`);
|
|
16
|
+
if (res.status === 204)
|
|
17
|
+
return { success: true };
|
|
18
|
+
return res.json();
|
|
19
|
+
}
|
|
20
|
+
async function apiRequestAllItems(token, propertyName, method, endpoint, qs = {}) {
|
|
21
|
+
const all = [];
|
|
22
|
+
let uri;
|
|
23
|
+
qs.limit = 50;
|
|
24
|
+
let data;
|
|
25
|
+
do {
|
|
26
|
+
data = (uri
|
|
27
|
+
? await apiRequest(token, method, "", undefined, { ...qs })
|
|
28
|
+
: await apiRequest(token, method, endpoint, undefined, qs));
|
|
29
|
+
const items = data[propertyName];
|
|
30
|
+
if (Array.isArray(items))
|
|
31
|
+
all.push(...items);
|
|
32
|
+
uri = data.next;
|
|
33
|
+
} while (all.length < (data.count ?? all.length + 1) && uri);
|
|
34
|
+
return all;
|
|
35
|
+
}
|
|
36
|
+
export default function keap(rl) {
|
|
37
|
+
rl.setName("keap");
|
|
38
|
+
rl.setVersion("0.1.0");
|
|
39
|
+
rl.setConnectionSchema({
|
|
40
|
+
accessToken: { type: "string", required: true, description: "Keap OAuth2 access token", env: "KEAP_ACCESS_TOKEN" },
|
|
41
|
+
});
|
|
42
|
+
const tok = (ctx) => ctx.connection.config.accessToken;
|
|
43
|
+
// ── Company ─────────────────────────────────────────
|
|
44
|
+
rl.registerAction("company.create", {
|
|
45
|
+
description: "Create a company",
|
|
46
|
+
inputSchema: {
|
|
47
|
+
companyName: { type: "string", required: true, description: "Company name" },
|
|
48
|
+
address: { type: "object", required: false, description: "Address object (line1, line2, locality, region, zip_code, country_code)" },
|
|
49
|
+
phone: { type: "object", required: false, description: "Phone object (number, field, type)" },
|
|
50
|
+
fax: { type: "object", required: false, description: "Fax object (number, type)" },
|
|
51
|
+
additionalFields: { type: "object", required: false, description: "Additional company fields (email_address, website, notes, etc.)" },
|
|
52
|
+
},
|
|
53
|
+
async execute(input, ctx) {
|
|
54
|
+
const { companyName, address, phone, fax, additionalFields } = input;
|
|
55
|
+
const body = { company_name: companyName };
|
|
56
|
+
if (additionalFields)
|
|
57
|
+
Object.assign(body, additionalFields);
|
|
58
|
+
if (address)
|
|
59
|
+
body.address = address;
|
|
60
|
+
if (phone)
|
|
61
|
+
body.phone_number = phone;
|
|
62
|
+
if (fax)
|
|
63
|
+
body.fax_number = fax;
|
|
64
|
+
return apiRequest(tok(ctx), "POST", "/companies", body);
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
rl.registerAction("company.list", {
|
|
68
|
+
description: "List companies",
|
|
69
|
+
inputSchema: {
|
|
70
|
+
limit: { type: "number", required: false, description: "Max results (default 50)" },
|
|
71
|
+
offset: { type: "number", required: false },
|
|
72
|
+
optionalProperties: { type: "string", required: false, description: "Comma-separated optional fields to include" },
|
|
73
|
+
},
|
|
74
|
+
async execute(input, ctx) {
|
|
75
|
+
const { limit, offset, optionalProperties } = (input ?? {});
|
|
76
|
+
const qs = {};
|
|
77
|
+
if (limit)
|
|
78
|
+
qs.limit = limit;
|
|
79
|
+
if (offset)
|
|
80
|
+
qs.offset = offset;
|
|
81
|
+
if (optionalProperties)
|
|
82
|
+
qs.optional_properties = optionalProperties;
|
|
83
|
+
const data = await apiRequest(tok(ctx), "GET", "/companies", undefined, qs);
|
|
84
|
+
return data.companies;
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
// ── Contact ─────────────────────────────────────────
|
|
88
|
+
rl.registerAction("contact.upsert", {
|
|
89
|
+
description: "Create or update a contact (PUT). Duplicate matching is controlled by duplicate_option.",
|
|
90
|
+
inputSchema: {
|
|
91
|
+
duplicateOption: { type: "string", required: true, description: "How to handle duplicates: 'Email', 'EmailAndName', 'EmailAndNameAndCompany'" },
|
|
92
|
+
emailAddresses: { type: "array", required: false, description: "Array of {email, field} objects (field: EMAIL1, EMAIL2, EMAIL3)" },
|
|
93
|
+
givenName: { type: "string", required: false },
|
|
94
|
+
familyName: { type: "string", required: false },
|
|
95
|
+
phoneNumbers: { type: "array", required: false, description: "Array of {number, field, type} objects" },
|
|
96
|
+
addresses: { type: "array", required: false, description: "Array of address objects (line1, line2, locality, region, zip_code, country_code, field)" },
|
|
97
|
+
faxNumbers: { type: "array", required: false, description: "Array of {number, type} objects" },
|
|
98
|
+
socialAccounts: { type: "array", required: false, description: "Array of {name, type} objects" },
|
|
99
|
+
additionalFields: { type: "object", required: false, description: "Additional fields: contact_type, job_title, lead_source_id, middle_name, opt_in_reason, owner_id, preferred_locale, preferred_name, source_type, spouse_name, time_zone, website, anniversary, company (as {id: number}), origin (as {ip_address: string})" },
|
|
100
|
+
},
|
|
101
|
+
async execute(input, ctx) {
|
|
102
|
+
const { duplicateOption, emailAddresses, givenName, familyName, phoneNumbers, addresses, faxNumbers, socialAccounts, additionalFields } = input;
|
|
103
|
+
const body = { duplicate_option: duplicateOption };
|
|
104
|
+
if (givenName)
|
|
105
|
+
body.given_name = givenName;
|
|
106
|
+
if (familyName)
|
|
107
|
+
body.family_name = familyName;
|
|
108
|
+
if (emailAddresses)
|
|
109
|
+
body.email_addresses = emailAddresses;
|
|
110
|
+
if (phoneNumbers)
|
|
111
|
+
body.phone_numbers = phoneNumbers;
|
|
112
|
+
if (addresses)
|
|
113
|
+
body.addresses = addresses;
|
|
114
|
+
if (faxNumbers)
|
|
115
|
+
body.fax_numbers = faxNumbers;
|
|
116
|
+
if (socialAccounts)
|
|
117
|
+
body.social_accounts = socialAccounts;
|
|
118
|
+
if (additionalFields)
|
|
119
|
+
Object.assign(body, additionalFields);
|
|
120
|
+
return apiRequest(tok(ctx), "PUT", "/contacts", body);
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
rl.registerAction("contact.get", {
|
|
124
|
+
description: "Get a contact by ID",
|
|
125
|
+
inputSchema: {
|
|
126
|
+
contactId: { type: "number", required: true },
|
|
127
|
+
optionalProperties: { type: "string", required: false, description: "Comma-separated optional fields" },
|
|
128
|
+
},
|
|
129
|
+
async execute(input, ctx) {
|
|
130
|
+
const { contactId, optionalProperties } = input;
|
|
131
|
+
const qs = {};
|
|
132
|
+
if (optionalProperties)
|
|
133
|
+
qs.optional_properties = optionalProperties;
|
|
134
|
+
return apiRequest(tok(ctx), "GET", `/contacts/${contactId}`, undefined, qs);
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
rl.registerAction("contact.list", {
|
|
138
|
+
description: "List contacts",
|
|
139
|
+
inputSchema: {
|
|
140
|
+
limit: { type: "number", required: false },
|
|
141
|
+
email: { type: "string", required: false },
|
|
142
|
+
givenName: { type: "string", required: false },
|
|
143
|
+
familyName: { type: "string", required: false },
|
|
144
|
+
order: { type: "string", required: false },
|
|
145
|
+
orderDirection: { type: "string", required: false, description: "ASCENDING or DESCENDING" },
|
|
146
|
+
since: { type: "string", required: false, description: "ISO date" },
|
|
147
|
+
until: { type: "string", required: false, description: "ISO date" },
|
|
148
|
+
},
|
|
149
|
+
async execute(input, ctx) {
|
|
150
|
+
const p = (input ?? {});
|
|
151
|
+
const qs = {};
|
|
152
|
+
if (p.limit)
|
|
153
|
+
qs.limit = p.limit;
|
|
154
|
+
if (p.email)
|
|
155
|
+
qs.email = p.email;
|
|
156
|
+
if (p.givenName)
|
|
157
|
+
qs.given_name = p.givenName;
|
|
158
|
+
if (p.familyName)
|
|
159
|
+
qs.family_name = p.familyName;
|
|
160
|
+
if (p.order)
|
|
161
|
+
qs.order = p.order;
|
|
162
|
+
if (p.orderDirection)
|
|
163
|
+
qs.order_direction = p.orderDirection;
|
|
164
|
+
if (p.since)
|
|
165
|
+
qs.since = p.since;
|
|
166
|
+
if (p.until)
|
|
167
|
+
qs.until = p.until;
|
|
168
|
+
const data = await apiRequest(tok(ctx), "GET", "/contacts", undefined, qs);
|
|
169
|
+
return data.contacts;
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
rl.registerAction("contact.delete", {
|
|
173
|
+
description: "Delete a contact",
|
|
174
|
+
inputSchema: { contactId: { type: "number", required: true } },
|
|
175
|
+
async execute(input, ctx) {
|
|
176
|
+
await apiRequest(tok(ctx), "DELETE", `/contacts/${input.contactId}`);
|
|
177
|
+
return { success: true };
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
// ── Contact Note ────────────────────────────────────
|
|
181
|
+
rl.registerAction("contactNote.create", {
|
|
182
|
+
description: "Create a note on a contact",
|
|
183
|
+
inputSchema: {
|
|
184
|
+
userId: { type: "number", required: true, description: "Keap user ID who is creating the note" },
|
|
185
|
+
contactId: { type: "number", required: true },
|
|
186
|
+
body: { type: "string", required: false, description: "Note body text" },
|
|
187
|
+
title: { type: "string", required: false },
|
|
188
|
+
type: { type: "string", required: false, description: "Appointment, Call, Email, Fax, Letter, Other" },
|
|
189
|
+
},
|
|
190
|
+
async execute(input, ctx) {
|
|
191
|
+
const { userId, contactId, body: noteBody, title, type } = input;
|
|
192
|
+
const b = { user_id: userId, contact_id: contactId };
|
|
193
|
+
if (noteBody)
|
|
194
|
+
b.body = noteBody;
|
|
195
|
+
if (title)
|
|
196
|
+
b.title = title;
|
|
197
|
+
if (type)
|
|
198
|
+
b.type = type;
|
|
199
|
+
return apiRequest(tok(ctx), "POST", "/notes", b);
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
rl.registerAction("contactNote.get", {
|
|
203
|
+
description: "Get a note",
|
|
204
|
+
inputSchema: { noteId: { type: "number", required: true } },
|
|
205
|
+
async execute(input, ctx) { return apiRequest(tok(ctx), "GET", `/notes/${input.noteId}`); },
|
|
206
|
+
});
|
|
207
|
+
rl.registerAction("contactNote.list", {
|
|
208
|
+
description: "List notes (optionally filtered by contact_id, user_id)",
|
|
209
|
+
inputSchema: {
|
|
210
|
+
limit: { type: "number", required: false },
|
|
211
|
+
contactId: { type: "number", required: false, description: "Filter by contact" },
|
|
212
|
+
userId: { type: "number", required: false, description: "Filter by user" },
|
|
213
|
+
},
|
|
214
|
+
async execute(input, ctx) {
|
|
215
|
+
const p = (input ?? {});
|
|
216
|
+
const qs = {};
|
|
217
|
+
if (p.limit)
|
|
218
|
+
qs.limit = p.limit;
|
|
219
|
+
if (p.contactId)
|
|
220
|
+
qs.contact_id = p.contactId;
|
|
221
|
+
if (p.userId)
|
|
222
|
+
qs.user_id = p.userId;
|
|
223
|
+
const data = await apiRequest(tok(ctx), "GET", "/notes", undefined, qs);
|
|
224
|
+
return data.notes;
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
rl.registerAction("contactNote.update", {
|
|
228
|
+
description: "Update a note",
|
|
229
|
+
inputSchema: {
|
|
230
|
+
noteId: { type: "number", required: true },
|
|
231
|
+
body: { type: "string", required: false },
|
|
232
|
+
title: { type: "string", required: false },
|
|
233
|
+
type: { type: "string", required: false },
|
|
234
|
+
},
|
|
235
|
+
async execute(input, ctx) {
|
|
236
|
+
const { noteId, body: b, title, type } = input;
|
|
237
|
+
const bd = {};
|
|
238
|
+
if (b)
|
|
239
|
+
bd.body = b;
|
|
240
|
+
if (title)
|
|
241
|
+
bd.title = title;
|
|
242
|
+
if (type)
|
|
243
|
+
bd.type = type;
|
|
244
|
+
return apiRequest(tok(ctx), "PATCH", `/notes/${noteId}`, bd);
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
rl.registerAction("contactNote.delete", {
|
|
248
|
+
description: "Delete a note",
|
|
249
|
+
inputSchema: { noteId: { type: "number", required: true } },
|
|
250
|
+
async execute(input, ctx) {
|
|
251
|
+
await apiRequest(tok(ctx), "DELETE", `/notes/${input.noteId}`);
|
|
252
|
+
return { success: true };
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
// ── Contact Tag ─────────────────────────────────────
|
|
256
|
+
rl.registerAction("contactTag.add", {
|
|
257
|
+
description: "Apply tags to a contact",
|
|
258
|
+
inputSchema: {
|
|
259
|
+
contactId: { type: "number", required: true },
|
|
260
|
+
tagIds: { type: "array", required: true, description: "Array of tag IDs to apply" },
|
|
261
|
+
},
|
|
262
|
+
async execute(input, ctx) {
|
|
263
|
+
const { contactId, tagIds } = input;
|
|
264
|
+
return apiRequest(tok(ctx), "POST", `/contacts/${contactId}/tags`, { tagIds });
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
rl.registerAction("contactTag.remove", {
|
|
268
|
+
description: "Remove tags from a contact",
|
|
269
|
+
inputSchema: {
|
|
270
|
+
contactId: { type: "number", required: true },
|
|
271
|
+
tagIds: { type: "string", required: true, description: "Comma-separated tag IDs to remove" },
|
|
272
|
+
},
|
|
273
|
+
async execute(input, ctx) {
|
|
274
|
+
const { contactId, tagIds } = input;
|
|
275
|
+
await apiRequest(tok(ctx), "DELETE", `/contacts/${contactId}/tags`, undefined, { ids: tagIds });
|
|
276
|
+
return { success: true };
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
rl.registerAction("contactTag.list", {
|
|
280
|
+
description: "List tags on a contact",
|
|
281
|
+
inputSchema: {
|
|
282
|
+
contactId: { type: "number", required: true },
|
|
283
|
+
limit: { type: "number", required: false },
|
|
284
|
+
},
|
|
285
|
+
async execute(input, ctx) {
|
|
286
|
+
const { contactId, limit } = input;
|
|
287
|
+
const qs = {};
|
|
288
|
+
if (limit)
|
|
289
|
+
qs.limit = limit;
|
|
290
|
+
const data = await apiRequest(tok(ctx), "GET", `/contacts/${contactId}/tags`, undefined, qs);
|
|
291
|
+
return data.tags;
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
// ── E-commerce Order ────────────────────────────────
|
|
295
|
+
rl.registerAction("order.create", {
|
|
296
|
+
description: "Create an order",
|
|
297
|
+
inputSchema: {
|
|
298
|
+
contactId: { type: "number", required: true },
|
|
299
|
+
orderDate: { type: "string", required: true, description: "ISO date" },
|
|
300
|
+
orderTitle: { type: "string", required: true },
|
|
301
|
+
orderType: { type: "string", required: true, description: "Online, Offline, etc." },
|
|
302
|
+
orderItems: { type: "array", required: true, description: "Array of order item objects (product_id, quantity, price, etc.)" },
|
|
303
|
+
shippingAddress: { type: "object", required: false },
|
|
304
|
+
additionalFields: { type: "object", required: false, description: "promo_codes (array), lead_affiliate_id, sale_affiliate_id, etc." },
|
|
305
|
+
},
|
|
306
|
+
async execute(input, ctx) {
|
|
307
|
+
const { contactId, orderDate, orderTitle, orderType, orderItems, shippingAddress, additionalFields } = input;
|
|
308
|
+
const body = {
|
|
309
|
+
contact_id: contactId,
|
|
310
|
+
order_date: orderDate,
|
|
311
|
+
order_title: orderTitle,
|
|
312
|
+
order_type: orderType,
|
|
313
|
+
order_items: orderItems,
|
|
314
|
+
};
|
|
315
|
+
if (shippingAddress)
|
|
316
|
+
body.shipping_address = shippingAddress;
|
|
317
|
+
if (additionalFields)
|
|
318
|
+
Object.assign(body, additionalFields);
|
|
319
|
+
return apiRequest(tok(ctx), "POST", "/orders", body);
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
rl.registerAction("order.get", {
|
|
323
|
+
description: "Get an order",
|
|
324
|
+
inputSchema: { orderId: { type: "number", required: true } },
|
|
325
|
+
async execute(input, ctx) { return apiRequest(tok(ctx), "GET", `/orders/${input.orderId}`); },
|
|
326
|
+
});
|
|
327
|
+
rl.registerAction("order.list", {
|
|
328
|
+
description: "List orders",
|
|
329
|
+
inputSchema: {
|
|
330
|
+
limit: { type: "number", required: false },
|
|
331
|
+
contactId: { type: "number", required: false },
|
|
332
|
+
since: { type: "string", required: false },
|
|
333
|
+
until: { type: "string", required: false },
|
|
334
|
+
},
|
|
335
|
+
async execute(input, ctx) {
|
|
336
|
+
const p = (input ?? {});
|
|
337
|
+
const qs = {};
|
|
338
|
+
if (p.limit)
|
|
339
|
+
qs.limit = p.limit;
|
|
340
|
+
if (p.contactId)
|
|
341
|
+
qs.contact_id = p.contactId;
|
|
342
|
+
if (p.since)
|
|
343
|
+
qs.since = p.since;
|
|
344
|
+
if (p.until)
|
|
345
|
+
qs.until = p.until;
|
|
346
|
+
const data = await apiRequest(tok(ctx), "GET", "/orders", undefined, qs);
|
|
347
|
+
return data.orders;
|
|
348
|
+
},
|
|
349
|
+
});
|
|
350
|
+
rl.registerAction("order.delete", {
|
|
351
|
+
description: "Delete an order",
|
|
352
|
+
inputSchema: { orderId: { type: "number", required: true } },
|
|
353
|
+
async execute(input, ctx) {
|
|
354
|
+
await apiRequest(tok(ctx), "DELETE", `/orders/${input.orderId}`);
|
|
355
|
+
return { success: true };
|
|
356
|
+
},
|
|
357
|
+
});
|
|
358
|
+
// ── E-commerce Product ──────────────────────────────
|
|
359
|
+
rl.registerAction("product.create", {
|
|
360
|
+
description: "Create a product",
|
|
361
|
+
inputSchema: {
|
|
362
|
+
productName: { type: "string", required: true },
|
|
363
|
+
additionalFields: { type: "object", required: false, description: "product_price, product_desc, sku, etc." },
|
|
364
|
+
},
|
|
365
|
+
async execute(input, ctx) {
|
|
366
|
+
const { productName, additionalFields } = input;
|
|
367
|
+
const body = { product_name: productName };
|
|
368
|
+
if (additionalFields)
|
|
369
|
+
Object.assign(body, additionalFields);
|
|
370
|
+
return apiRequest(tok(ctx), "POST", "/products", body);
|
|
371
|
+
},
|
|
372
|
+
});
|
|
373
|
+
rl.registerAction("product.get", {
|
|
374
|
+
description: "Get a product",
|
|
375
|
+
inputSchema: { productId: { type: "number", required: true } },
|
|
376
|
+
async execute(input, ctx) { return apiRequest(tok(ctx), "GET", `/products/${input.productId}`); },
|
|
377
|
+
});
|
|
378
|
+
rl.registerAction("product.list", {
|
|
379
|
+
description: "List products",
|
|
380
|
+
inputSchema: { limit: { type: "number", required: false } },
|
|
381
|
+
async execute(input, ctx) {
|
|
382
|
+
const qs = {};
|
|
383
|
+
if (input?.limit)
|
|
384
|
+
qs.limit = input.limit;
|
|
385
|
+
const data = await apiRequest(tok(ctx), "GET", "/products", undefined, qs);
|
|
386
|
+
return data.products;
|
|
387
|
+
},
|
|
388
|
+
});
|
|
389
|
+
rl.registerAction("product.delete", {
|
|
390
|
+
description: "Delete a product",
|
|
391
|
+
inputSchema: { productId: { type: "number", required: true } },
|
|
392
|
+
async execute(input, ctx) {
|
|
393
|
+
await apiRequest(tok(ctx), "DELETE", `/products/${input.productId}`);
|
|
394
|
+
return { success: true };
|
|
395
|
+
},
|
|
396
|
+
});
|
|
397
|
+
// ── Email ───────────────────────────────────────────
|
|
398
|
+
rl.registerAction("email.createRecord", {
|
|
399
|
+
description: "Create an email record (log a sent email)",
|
|
400
|
+
inputSchema: {
|
|
401
|
+
sentFromAddress: { type: "string", required: true },
|
|
402
|
+
sentToAddress: { type: "string", required: true },
|
|
403
|
+
additionalFields: { type: "object", required: false, description: "subject, sent_date, received_date, headers, html_content, plain_content, etc." },
|
|
404
|
+
},
|
|
405
|
+
async execute(input, ctx) {
|
|
406
|
+
const { sentFromAddress, sentToAddress, additionalFields } = input;
|
|
407
|
+
const body = { sent_to_address: sentToAddress, sent_from_address: sentFromAddress };
|
|
408
|
+
if (additionalFields)
|
|
409
|
+
Object.assign(body, additionalFields);
|
|
410
|
+
return apiRequest(tok(ctx), "POST", "/emails", body);
|
|
411
|
+
},
|
|
412
|
+
});
|
|
413
|
+
rl.registerAction("email.delete", {
|
|
414
|
+
description: "Delete an email record",
|
|
415
|
+
inputSchema: { emailRecordId: { type: "number", required: true } },
|
|
416
|
+
async execute(input, ctx) {
|
|
417
|
+
await apiRequest(tok(ctx), "DELETE", `/emails/${input.emailRecordId}`);
|
|
418
|
+
return { success: true };
|
|
419
|
+
},
|
|
420
|
+
});
|
|
421
|
+
rl.registerAction("email.list", {
|
|
422
|
+
description: "List email records",
|
|
423
|
+
inputSchema: {
|
|
424
|
+
limit: { type: "number", required: false },
|
|
425
|
+
contactId: { type: "number", required: false },
|
|
426
|
+
email: { type: "string", required: false },
|
|
427
|
+
sinceDate: { type: "string", required: false },
|
|
428
|
+
},
|
|
429
|
+
async execute(input, ctx) {
|
|
430
|
+
const p = (input ?? {});
|
|
431
|
+
const qs = {};
|
|
432
|
+
if (p.limit)
|
|
433
|
+
qs.limit = p.limit;
|
|
434
|
+
if (p.contactId)
|
|
435
|
+
qs.contact_id = p.contactId;
|
|
436
|
+
if (p.email)
|
|
437
|
+
qs.email = p.email;
|
|
438
|
+
if (p.sinceDate)
|
|
439
|
+
qs.since_sent_date = p.sinceDate;
|
|
440
|
+
const data = await apiRequest(tok(ctx), "GET", "/emails", undefined, qs);
|
|
441
|
+
return data.emails;
|
|
442
|
+
},
|
|
443
|
+
});
|
|
444
|
+
rl.registerAction("email.send", {
|
|
445
|
+
description: "Queue an email to be sent",
|
|
446
|
+
inputSchema: {
|
|
447
|
+
userId: { type: "number", required: true, description: "Keap user ID sending the email" },
|
|
448
|
+
contactIds: { type: "array", required: true, description: "Array of contact IDs to send to" },
|
|
449
|
+
subject: { type: "string", required: true },
|
|
450
|
+
htmlContent: { type: "string", required: false },
|
|
451
|
+
plainContent: { type: "string", required: false },
|
|
452
|
+
attachments: { type: "array", required: false, description: "Array of {file_data, file_name} objects" },
|
|
453
|
+
},
|
|
454
|
+
async execute(input, ctx) {
|
|
455
|
+
const { userId, contactIds, subject, htmlContent, plainContent, attachments } = input;
|
|
456
|
+
const body = { user_id: userId, contacts: contactIds, subject };
|
|
457
|
+
if (htmlContent)
|
|
458
|
+
body.html_content = htmlContent;
|
|
459
|
+
if (plainContent)
|
|
460
|
+
body.plain_content = plainContent;
|
|
461
|
+
if (attachments)
|
|
462
|
+
body.attachments = attachments;
|
|
463
|
+
await apiRequest(tok(ctx), "POST", "/emails/queue", body);
|
|
464
|
+
return { success: true };
|
|
465
|
+
},
|
|
466
|
+
});
|
|
467
|
+
// ── File ────────────────────────────────────────────
|
|
468
|
+
rl.registerAction("file.delete", {
|
|
469
|
+
description: "Delete a file",
|
|
470
|
+
inputSchema: { fileId: { type: "number", required: true } },
|
|
471
|
+
async execute(input, ctx) {
|
|
472
|
+
await apiRequest(tok(ctx), "DELETE", `/files/${input.fileId}`);
|
|
473
|
+
return { success: true };
|
|
474
|
+
},
|
|
475
|
+
});
|
|
476
|
+
rl.registerAction("file.list", {
|
|
477
|
+
description: "List files",
|
|
478
|
+
inputSchema: {
|
|
479
|
+
limit: { type: "number", required: false },
|
|
480
|
+
permission: { type: "string", required: false, description: "USER, COMPANY" },
|
|
481
|
+
type: { type: "string", required: false, description: "Application, Image, Fax, Attachment, Ticket, Contact, Digital Product, Import, Hidden, Webform, Styled Cart, Logo, Resampled, Template Thumbnail, Funnel" },
|
|
482
|
+
viewable: { type: "string", required: false, description: "PUBLIC, PRIVATE, BOTH" },
|
|
483
|
+
contactId: { type: "number", required: false },
|
|
484
|
+
},
|
|
485
|
+
async execute(input, ctx) {
|
|
486
|
+
const p = (input ?? {});
|
|
487
|
+
const qs = {};
|
|
488
|
+
if (p.limit)
|
|
489
|
+
qs.limit = p.limit;
|
|
490
|
+
if (p.permission)
|
|
491
|
+
qs.permission = p.permission.toUpperCase();
|
|
492
|
+
if (p.type)
|
|
493
|
+
qs.type = p.type;
|
|
494
|
+
if (p.viewable)
|
|
495
|
+
qs.viewable = p.viewable.toUpperCase();
|
|
496
|
+
if (p.contactId)
|
|
497
|
+
qs.contact_id = p.contactId;
|
|
498
|
+
const data = await apiRequest(tok(ctx), "GET", "/files", undefined, qs);
|
|
499
|
+
return data.files;
|
|
500
|
+
},
|
|
501
|
+
});
|
|
502
|
+
}
|