runline 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/plugins/actionNetwork/src/index.js +118 -25
- package/dist/plugins/activeCampaign/src/index.js +184 -38
- package/dist/plugins/adalo/src/index.js +40 -8
- package/dist/plugins/affinity/src/index.js +100 -20
- package/dist/plugins/agileCrm/src/index.js +115 -27
- package/dist/plugins/airtable/src/index.js +94 -19
- package/dist/plugins/airtop/src/index.js +266 -62
- package/dist/plugins/apiTemplateIo/src/index.js +25 -5
- package/dist/plugins/asana/src/index.js +195 -41
- package/dist/plugins/autopilot/src/index.js +39 -8
- package/dist/plugins/bambooHr/src/index.js +109 -22
- package/dist/plugins/bannerbear/src/index.js +36 -8
- package/dist/plugins/baserow/src/index.js +35 -7
- package/dist/plugins/beeminder/src/index.js +198 -40
- package/dist/plugins/bitly/src/index.js +46 -10
- package/dist/plugins/bitwarden/src/index.js +167 -36
- package/dist/plugins/box/src/index.js +172 -37
- package/dist/plugins/brandfetch/src/index.js +5 -1
- package/dist/plugins/brevo/src/index.js +136 -29
- package/dist/plugins/bubble/src/index.js +76 -17
- package/dist/plugins/chargebee/src/index.js +35 -7
- package/dist/plugins/circleci/src/index.js +50 -10
- package/dist/plugins/ciscoWebex/src/index.js +131 -27
- package/dist/plugins/clearbit/src/index.js +76 -17
- package/dist/plugins/clickup/src/index.js +500 -107
- package/dist/plugins/clockify/src/index.js +229 -47
- package/dist/plugins/cloudflare/src/index.js +28 -6
- package/dist/plugins/cockpit/src/index.js +54 -12
- package/dist/plugins/coda/src/index.js +81 -19
- package/dist/plugins/coingecko/src/index.js +157 -33
- package/dist/plugins/contentful/src/index.js +85 -17
- package/dist/plugins/convertkit/src/index.js +74 -18
- package/dist/plugins/copper/src/index.js +59 -11
- package/dist/plugins/cortex/src/index.js +55 -13
- package/dist/plugins/currents/src/index.js +310 -71
- package/dist/plugins/customerIo/src/index.js +112 -23
- package/dist/plugins/databricks/src/index.js +549 -115
- package/dist/plugins/deepl/src/index.js +26 -6
- package/dist/plugins/demio/src/index.js +56 -11
- package/dist/plugins/dhl/src/index.js +16 -3
- package/dist/plugins/discord/src/index.js +141 -31
- package/dist/plugins/discourse/src/index.js +136 -31
- package/dist/plugins/disqus/src/index.js +96 -20
- package/dist/plugins/docker/src/index.js +20 -4
- package/dist/plugins/drift/src/index.js +19 -5
- package/dist/plugins/dropbox/src/index.js +139 -30
- package/dist/plugins/dropcontact/src/index.js +21 -4
- package/dist/plugins/egoi/src/index.js +61 -15
- package/dist/plugins/elasticsearch/src/index.js +59 -13
- package/dist/plugins/emelia/src/index.js +95 -19
- package/dist/plugins/erpnext/src/index.js +74 -15
- package/dist/plugins/facebookGraph/src/index.js +52 -11
- package/dist/plugins/freshdesk/src/index.js +220 -48
- package/dist/plugins/freshservice/src/index.js +39 -9
- package/dist/plugins/freshworksCrm/src/index.js +58 -12
- package/dist/plugins/getresponse/src/index.js +87 -18
- package/dist/plugins/ghost/src/index.js +114 -26
- package/dist/plugins/github/src/index.js +483 -109
- package/dist/plugins/gitlab/src/index.js +193 -45
- package/dist/plugins/gong/src/index.js +68 -14
- package/dist/plugins/gotify/src/index.js +43 -9
- package/dist/plugins/gotowebinar/src/index.js +233 -47
- package/dist/plugins/grafana/src/index.js +92 -21
- package/dist/plugins/graphql/src/index.js +38 -8
- package/dist/plugins/grist/src/index.js +52 -10
- package/dist/plugins/hackernews/src/index.js +32 -6
- package/dist/plugins/halopsa/src/index.js +131 -26
- package/dist/plugins/harvest/src/index.js +182 -42
- package/dist/plugins/helpscout/src/index.js +153 -31
- package/dist/plugins/highlevel/src/index.js +291 -58
- package/dist/plugins/homeAssistant/src/index.js +124 -26
- package/dist/plugins/hubspot/src/index.js +163 -29
- package/dist/plugins/humanticAi/src/index.js +54 -5
- package/dist/plugins/hunter/src/index.js +21 -4
- package/dist/plugins/intercom/src/index.js +95 -20
- package/dist/plugins/iterable/src/index.js +96 -20
- package/dist/plugins/jenkins/src/index.js +75 -17
- package/dist/plugins/jira/src/index.js +193 -43
- package/dist/plugins/keap/src/index.js +222 -56
- package/dist/plugins/kobotoolbox/src/index.js +113 -25
- package/dist/plugins/lemlist/src/index.js +79 -18
- package/dist/plugins/linear/src/index.js +86 -19
- package/dist/plugins/lingvanex/src/index.js +38 -8
- package/dist/plugins/linkedin/src/index.js +37 -8
- package/dist/plugins/lonescale/src/index.js +41 -9
- package/dist/plugins/magento/src/index.js +98 -27
- package/dist/plugins/mailcheck/src/index.js +11 -2
- package/dist/plugins/mailchimp/src/index.js +193 -42
- package/dist/plugins/mailerlite/src/index.js +61 -12
- package/dist/plugins/mailgun/src/index.js +39 -7
- package/dist/plugins/mailjet/src/index.js +141 -30
- package/dist/plugins/mandrill/src/index.js +67 -14
- package/dist/plugins/marketstack/src/index.js +56 -10
- package/dist/plugins/matrix/src/index.js +97 -20
- package/dist/plugins/mattermost/src/index.js +124 -26
- package/dist/plugins/mautic/src/index.js +129 -26
- package/dist/plugins/medium/src/index.js +64 -13
- package/dist/plugins/messagebird/src/index.js +80 -15
- package/dist/plugins/metabase/src/index.js +57 -12
- package/dist/plugins/misp/src/index.js +135 -33
- package/dist/plugins/mocean/src/index.js +33 -7
- package/dist/plugins/monday/src/index.js +97 -23
- package/dist/plugins/monicaCrm/src/index.js +112 -23
- package/dist/plugins/msg91/src/index.js +11 -2
- package/dist/plugins/nasa/src/index.js +108 -21
- package/dist/plugins/netlify/src/index.js +28 -6
- package/dist/plugins/netscalerAdc/src/index.js +144 -29
- package/dist/plugins/nextcloud/src/index.js +103 -20
- package/dist/plugins/nocodb/src/index.js +57 -11
- package/dist/plugins/notion/src/index.js +148 -37
- package/dist/plugins/npm/src/index.js +59 -12
- package/dist/plugins/odoo/src/index.js +102 -20
- package/dist/plugins/okta/src/index.js +50 -10
- package/dist/plugins/oneSimpleApi/src/index.js +84 -17
- package/dist/plugins/onfleet/src/index.js +139 -32
- package/dist/plugins/openThesaurus/src/index.js +46 -9
- package/dist/plugins/openweathermap/src/index.js +31 -6
- package/dist/plugins/oura/src/index.js +36 -7
- package/dist/plugins/paddle/src/index.js +80 -17
- package/dist/plugins/pagerduty/src/index.js +53 -12
- package/dist/plugins/paypal/src/index.js +51 -11
- package/dist/plugins/peekalink/src/index.js +12 -3
- package/dist/plugins/phantombuster/src/index.js +39 -8
- package/dist/plugins/philipsHue/src/index.js +64 -13
- package/dist/plugins/pipedrive/src/index.js +167 -45
- package/dist/plugins/plivo/src/index.js +43 -8
- package/dist/plugins/postbin/src/index.js +9 -2
- package/dist/plugins/posthog/src/index.js +50 -13
- package/dist/plugins/profitwell/src/index.js +24 -5
- package/dist/plugins/pushbullet/src/index.js +45 -9
- package/dist/plugins/pushcut/src/index.js +31 -6
- package/dist/plugins/pushover/src/index.js +51 -10
- package/dist/plugins/quickbase/src/index.js +66 -13
- package/dist/plugins/quickbooks/src/index.js +86 -19
- package/dist/plugins/quickchart/src/index.js +35 -7
- package/dist/plugins/raindrop/src/index.js +54 -13
- package/dist/plugins/reddit/src/index.js +73 -18
- package/dist/plugins/rocketchat/src/index.js +47 -9
- package/dist/plugins/rundeck/src/index.js +26 -5
- package/dist/plugins/salesforce/src/index.js +161 -31
- package/dist/plugins/salesmate/src/index.js +75 -16
- package/dist/plugins/securityScorecard/src/index.js +73 -15
- package/dist/plugins/segment/src/index.js +21 -4
- package/dist/plugins/sendgrid/src/index.js +102 -24
- package/dist/plugins/sendy/src/index.js +54 -11
- package/dist/plugins/sentry/src/index.js +174 -34
- package/dist/plugins/servicenow/src/index.js +120 -27
- package/dist/plugins/shopify/src/index.js +53 -12
- package/dist/plugins/signl4/src/index.js +16 -3
- package/dist/plugins/slack/src/index.js +407 -105
- package/dist/plugins/sms77/src/index.js +26 -5
- package/dist/plugins/splunk/src/index.js +186 -45
- package/dist/plugins/spotify/src/index.js +265 -66
- package/dist/plugins/stackby/src/index.js +18 -6
- package/dist/plugins/storyblok/src/index.js +57 -11
- package/dist/plugins/strapi/src/index.js +63 -12
- package/dist/plugins/strava/src/index.js +58 -13
- package/dist/plugins/stripe/src/index.js +143 -30
- package/dist/plugins/supabase/src/index.js +49 -10
- package/dist/plugins/syncromsp/src/index.js +245 -67
- package/dist/plugins/tapfiliate/src/index.js +57 -14
- package/dist/plugins/telegram/src/index.js +202 -39
- package/dist/plugins/thehive/src/index.js +271 -66
- package/dist/plugins/thehiveProject/src/index.js +457 -89
- package/dist/plugins/todoist/src/index.js +326 -77
- package/dist/plugins/travisci/src/index.js +35 -8
- package/dist/plugins/trello/src/index.js +204 -46
- package/dist/plugins/twake/src/index.js +10 -2
- package/dist/plugins/twilio/src/index.js +56 -11
- package/dist/plugins/twist/src/index.js +241 -48
- package/dist/plugins/twitter/src/index.js +128 -30
- package/dist/plugins/unleashedSoftware/src/index.js +30 -6
- package/dist/plugins/uplead/src/index.js +9 -2
- package/dist/plugins/uproc/src/index.js +31 -6
- package/dist/plugins/uptimerobot/src/index.js +119 -25
- package/dist/plugins/urlscanio/src/index.js +25 -6
- package/dist/plugins/vero/src/index.js +68 -13
- package/dist/plugins/vonage/src/index.js +32 -6
- package/dist/plugins/wekan/src/index.js +297 -52
- package/dist/plugins/woocommerce/src/index.js +57 -12
- package/dist/plugins/wordpress/src/index.js +94 -18
- package/dist/plugins/xero/src/index.js +79 -13
- package/dist/plugins/yourls/src/index.js +33 -6
- package/dist/plugins/zammad/src/index.js +139 -36
- package/dist/plugins/zendesk/src/index.js +201 -48
- package/dist/plugins/zoho/src/index.js +88 -21
- package/dist/plugins/zoom/src/index.js +41 -7
- package/dist/plugins/zulip/src/index.js +101 -20
- package/package.json +1 -1
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
const API_VERSION = "v59.0";
|
|
2
2
|
function getConn(ctx) {
|
|
3
3
|
const c = ctx.connection.config;
|
|
4
|
-
return {
|
|
4
|
+
return {
|
|
5
|
+
instanceUrl: c.instanceUrl.replace(/\/$/, ""),
|
|
6
|
+
accessToken: c.accessToken,
|
|
7
|
+
};
|
|
5
8
|
}
|
|
6
9
|
async function api(conn, method, endpoint, body, qs) {
|
|
7
10
|
const url = new URL(`${conn.instanceUrl}/services/data/${API_VERSION}${endpoint}`);
|
|
@@ -11,7 +14,13 @@ async function api(conn, method, endpoint, body, qs) {
|
|
|
11
14
|
url.searchParams.set(k, String(v));
|
|
12
15
|
}
|
|
13
16
|
}
|
|
14
|
-
const init = {
|
|
17
|
+
const init = {
|
|
18
|
+
method,
|
|
19
|
+
headers: {
|
|
20
|
+
Authorization: `Bearer ${conn.accessToken}`,
|
|
21
|
+
"Content-Type": "application/json",
|
|
22
|
+
},
|
|
23
|
+
};
|
|
15
24
|
if (body && Object.keys(body).length > 0)
|
|
16
25
|
init.body = JSON.stringify(body);
|
|
17
26
|
const res = await fetch(url.toString(), init);
|
|
@@ -21,7 +30,15 @@ async function api(conn, method, endpoint, body, qs) {
|
|
|
21
30
|
throw new Error(`Salesforce error ${res.status}: ${await res.text()}`);
|
|
22
31
|
return res.json();
|
|
23
32
|
}
|
|
24
|
-
const SOBJECTS = [
|
|
33
|
+
const SOBJECTS = [
|
|
34
|
+
"Account",
|
|
35
|
+
"Contact",
|
|
36
|
+
"Lead",
|
|
37
|
+
"Opportunity",
|
|
38
|
+
"Case",
|
|
39
|
+
"Task",
|
|
40
|
+
"User",
|
|
41
|
+
];
|
|
25
42
|
const DEFAULT_FIELDS = {
|
|
26
43
|
Account: "Id,Name,Type",
|
|
27
44
|
Contact: "Id,FirstName,LastName,Email",
|
|
@@ -33,19 +50,61 @@ const DEFAULT_FIELDS = {
|
|
|
33
50
|
};
|
|
34
51
|
function registerSObject(rl, sObject, conn) {
|
|
35
52
|
const lower = sObject.toLowerCase();
|
|
36
|
-
rl.registerAction(`${lower}.create`, {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
53
|
+
rl.registerAction(`${lower}.create`, {
|
|
54
|
+
description: `Create a ${sObject}`,
|
|
55
|
+
inputSchema: {
|
|
56
|
+
data: {
|
|
57
|
+
type: "object",
|
|
58
|
+
required: true,
|
|
59
|
+
description: `${sObject} field values`,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
async execute(input, ctx) {
|
|
63
|
+
return api(conn(ctx), "POST", `/sobjects/${sObject}`, input.data);
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
rl.registerAction(`${lower}.get`, {
|
|
67
|
+
description: `Get a ${sObject} by ID`,
|
|
68
|
+
inputSchema: { id: { type: "string", required: true } },
|
|
69
|
+
async execute(input, ctx) {
|
|
70
|
+
return api(conn(ctx), "GET", `/sobjects/${sObject}/${input.id}`);
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
rl.registerAction(`${lower}.update`, {
|
|
74
|
+
description: `Update a ${sObject}`,
|
|
75
|
+
inputSchema: {
|
|
76
|
+
id: { type: "string", required: true },
|
|
77
|
+
data: { type: "object", required: true },
|
|
78
|
+
},
|
|
41
79
|
async execute(input, ctx) {
|
|
42
80
|
const p = input;
|
|
43
81
|
await api(conn(ctx), "PATCH", `/sobjects/${sObject}/${p.id}`, p.data);
|
|
44
82
|
return { success: true, id: p.id };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
rl.registerAction(`${lower}.delete`, {
|
|
86
|
+
description: `Delete a ${sObject}`,
|
|
87
|
+
inputSchema: { id: { type: "string", required: true } },
|
|
88
|
+
async execute(input, ctx) {
|
|
89
|
+
await api(conn(ctx), "DELETE", `/sobjects/${sObject}/${input.id}`);
|
|
90
|
+
return { success: true };
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
rl.registerAction(`${lower}.query`, {
|
|
94
|
+
description: `Query ${sObject}s with SOQL`,
|
|
95
|
+
inputSchema: {
|
|
96
|
+
fields: {
|
|
97
|
+
type: "string",
|
|
98
|
+
required: false,
|
|
99
|
+
description: `Comma-separated (default: ${DEFAULT_FIELDS[sObject] ?? "Id"})`,
|
|
100
|
+
},
|
|
101
|
+
where: {
|
|
102
|
+
type: "string",
|
|
103
|
+
required: false,
|
|
104
|
+
description: "SOQL WHERE clause",
|
|
105
|
+
},
|
|
106
|
+
limit: { type: "number", required: false },
|
|
107
|
+
},
|
|
49
108
|
async execute(input, ctx) {
|
|
50
109
|
const p = (input ?? {});
|
|
51
110
|
const fields = p.fields || DEFAULT_FIELDS[sObject] || "Id";
|
|
@@ -54,41 +113,112 @@ function registerSObject(rl, sObject, conn) {
|
|
|
54
113
|
q += ` WHERE ${p.where}`;
|
|
55
114
|
if (p.limit)
|
|
56
115
|
q += ` LIMIT ${p.limit}`;
|
|
57
|
-
const data = (await api(conn(ctx), "GET", "/query", undefined, {
|
|
116
|
+
const data = (await api(conn(ctx), "GET", "/query", undefined, {
|
|
117
|
+
q,
|
|
118
|
+
}));
|
|
58
119
|
return data.records;
|
|
59
|
-
}
|
|
60
|
-
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
rl.registerAction(`${lower}.upsert`, {
|
|
123
|
+
description: `Upsert a ${sObject} by external ID`,
|
|
124
|
+
inputSchema: {
|
|
125
|
+
externalIdField: { type: "string", required: true },
|
|
126
|
+
externalIdValue: { type: "string", required: true },
|
|
127
|
+
data: { type: "object", required: true },
|
|
128
|
+
},
|
|
61
129
|
async execute(input, ctx) {
|
|
62
130
|
const p = input;
|
|
63
131
|
return api(conn(ctx), "PATCH", `/sobjects/${sObject}/${p.externalIdField}/${p.externalIdValue}`, p.data);
|
|
64
|
-
}
|
|
132
|
+
},
|
|
133
|
+
});
|
|
65
134
|
}
|
|
66
135
|
export default function salesforce(rl) {
|
|
67
136
|
rl.setName("salesforce");
|
|
68
137
|
rl.setVersion("0.1.0");
|
|
69
138
|
rl.setConnectionSchema({
|
|
70
|
-
instanceUrl: {
|
|
71
|
-
|
|
139
|
+
instanceUrl: {
|
|
140
|
+
type: "string",
|
|
141
|
+
required: true,
|
|
142
|
+
description: "Salesforce instance URL (e.g. https://yourorg.my.salesforce.com)",
|
|
143
|
+
env: "SALESFORCE_INSTANCE_URL",
|
|
144
|
+
},
|
|
145
|
+
accessToken: {
|
|
146
|
+
type: "string",
|
|
147
|
+
required: true,
|
|
148
|
+
description: "Salesforce OAuth2 access token",
|
|
149
|
+
env: "SALESFORCE_ACCESS_TOKEN",
|
|
150
|
+
},
|
|
72
151
|
});
|
|
73
152
|
for (const sObject of SOBJECTS) {
|
|
74
153
|
registerSObject(rl, sObject, getConn);
|
|
75
154
|
}
|
|
76
155
|
// ── Generic sObject ─────────────────────────────────
|
|
77
|
-
rl.registerAction("sobject.create", {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
156
|
+
rl.registerAction("sobject.create", {
|
|
157
|
+
description: "Create any sObject record",
|
|
158
|
+
inputSchema: {
|
|
159
|
+
sObject: { type: "string", required: true },
|
|
160
|
+
data: { type: "object", required: true },
|
|
161
|
+
},
|
|
162
|
+
async execute(input, ctx) {
|
|
163
|
+
const p = input;
|
|
164
|
+
return api(getConn(ctx), "POST", `/sobjects/${p.sObject}`, p.data);
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
rl.registerAction("sobject.get", {
|
|
168
|
+
description: "Get any sObject record",
|
|
169
|
+
inputSchema: {
|
|
170
|
+
sObject: { type: "string", required: true },
|
|
171
|
+
id: { type: "string", required: true },
|
|
172
|
+
},
|
|
173
|
+
async execute(input, ctx) {
|
|
174
|
+
const p = input;
|
|
175
|
+
return api(getConn(ctx), "GET", `/sobjects/${p.sObject}/${p.id}`);
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
rl.registerAction("sobject.update", {
|
|
179
|
+
description: "Update any sObject record",
|
|
180
|
+
inputSchema: {
|
|
181
|
+
sObject: { type: "string", required: true },
|
|
182
|
+
id: { type: "string", required: true },
|
|
183
|
+
data: { type: "object", required: true },
|
|
184
|
+
},
|
|
185
|
+
async execute(input, ctx) {
|
|
186
|
+
const p = input;
|
|
187
|
+
await api(getConn(ctx), "PATCH", `/sobjects/${p.sObject}/${p.id}`, p.data);
|
|
188
|
+
return { success: true };
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
rl.registerAction("sobject.delete", {
|
|
192
|
+
description: "Delete any sObject record",
|
|
193
|
+
inputSchema: {
|
|
194
|
+
sObject: { type: "string", required: true },
|
|
195
|
+
id: { type: "string", required: true },
|
|
196
|
+
},
|
|
197
|
+
async execute(input, ctx) {
|
|
198
|
+
const p = input;
|
|
199
|
+
await api(getConn(ctx), "DELETE", `/sobjects/${p.sObject}/${p.id}`);
|
|
200
|
+
return { success: true };
|
|
201
|
+
},
|
|
202
|
+
});
|
|
85
203
|
// ── SOQL Query ──────────────────────────────────────
|
|
86
|
-
rl.registerAction("soql.query", {
|
|
204
|
+
rl.registerAction("soql.query", {
|
|
205
|
+
description: "Execute a raw SOQL query",
|
|
206
|
+
inputSchema: {
|
|
207
|
+
query: { type: "string", required: true, description: "Full SOQL query" },
|
|
208
|
+
},
|
|
87
209
|
async execute(input, ctx) {
|
|
88
|
-
const data = (await api(getConn(ctx), "GET", "/query", undefined, {
|
|
210
|
+
const data = (await api(getConn(ctx), "GET", "/query", undefined, {
|
|
211
|
+
q: input.query,
|
|
212
|
+
}));
|
|
89
213
|
return data.records;
|
|
90
|
-
}
|
|
214
|
+
},
|
|
215
|
+
});
|
|
91
216
|
// ── Describe ────────────────────────────────────────
|
|
92
|
-
rl.registerAction("sobject.describe", {
|
|
93
|
-
|
|
217
|
+
rl.registerAction("sobject.describe", {
|
|
218
|
+
description: "Describe an sObject's metadata/fields",
|
|
219
|
+
inputSchema: { sObject: { type: "string", required: true } },
|
|
220
|
+
async execute(input, ctx) {
|
|
221
|
+
return api(getConn(ctx), "GET", `/sobjects/${input.sObject}/describe`);
|
|
222
|
+
},
|
|
223
|
+
});
|
|
94
224
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const BASE = "https://apis.salesmate.io";
|
|
2
2
|
function getConn(ctx) {
|
|
3
|
-
return {
|
|
3
|
+
return {
|
|
4
|
+
sessionToken: ctx.connection.config.sessionToken,
|
|
5
|
+
linkname: ctx.connection.config.linkname,
|
|
6
|
+
};
|
|
4
7
|
}
|
|
5
8
|
async function api(conn, method, endpoint, body, qs) {
|
|
6
9
|
const url = new URL(`${BASE}${endpoint}`);
|
|
@@ -10,7 +13,14 @@ async function api(conn, method, endpoint, body, qs) {
|
|
|
10
13
|
url.searchParams.set(k, String(v));
|
|
11
14
|
}
|
|
12
15
|
}
|
|
13
|
-
const init = {
|
|
16
|
+
const init = {
|
|
17
|
+
method,
|
|
18
|
+
headers: {
|
|
19
|
+
sessionToken: conn.sessionToken,
|
|
20
|
+
"x-linkname": conn.linkname,
|
|
21
|
+
"Content-Type": "application/json",
|
|
22
|
+
},
|
|
23
|
+
};
|
|
14
24
|
if (body && Object.keys(body).length > 0)
|
|
15
25
|
init.body = JSON.stringify(body);
|
|
16
26
|
const res = await fetch(url.toString(), init);
|
|
@@ -19,41 +29,86 @@ async function api(conn, method, endpoint, body, qs) {
|
|
|
19
29
|
return res.json();
|
|
20
30
|
}
|
|
21
31
|
function registerCrud(rl, resource, plural, conn, createSchema) {
|
|
22
|
-
rl.registerAction(`${resource}.create`, {
|
|
32
|
+
rl.registerAction(`${resource}.create`, {
|
|
33
|
+
description: `Create a ${resource}`,
|
|
34
|
+
inputSchema: createSchema,
|
|
23
35
|
async execute(input, ctx) {
|
|
24
36
|
const data = (await api(conn(ctx), "POST", `/v1/${plural}`, input));
|
|
25
37
|
return data.Data;
|
|
26
|
-
}
|
|
27
|
-
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
rl.registerAction(`${resource}.get`, {
|
|
41
|
+
description: `Get a ${resource} by ID`,
|
|
42
|
+
inputSchema: { id: { type: "string", required: true } },
|
|
28
43
|
async execute(input, ctx) {
|
|
29
44
|
const data = (await api(conn(ctx), "GET", `/v1/${plural}/${input.id}`));
|
|
30
45
|
return data.Data;
|
|
31
|
-
}
|
|
32
|
-
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
rl.registerAction(`${resource}.list`, {
|
|
49
|
+
description: `Search/list ${plural}`,
|
|
50
|
+
inputSchema: {
|
|
51
|
+
limit: { type: "number", required: false },
|
|
52
|
+
fields: {
|
|
53
|
+
type: "object",
|
|
54
|
+
required: false,
|
|
55
|
+
description: "Array of field names to return",
|
|
56
|
+
},
|
|
57
|
+
query: {
|
|
58
|
+
type: "object",
|
|
59
|
+
required: false,
|
|
60
|
+
description: "Search query object",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
33
63
|
async execute(input, ctx) {
|
|
34
64
|
const p = (input ?? {});
|
|
35
|
-
const body = {
|
|
65
|
+
const body = {
|
|
66
|
+
fields: p.fields ?? ["name", "id"],
|
|
67
|
+
query: p.query ?? {},
|
|
68
|
+
};
|
|
36
69
|
const qs = {};
|
|
37
70
|
if (p.limit)
|
|
38
71
|
qs.rows = p.limit;
|
|
39
72
|
const data = (await api(conn(ctx), "POST", `/v2/${plural}/search`, body, qs));
|
|
40
73
|
return data.Data.data;
|
|
41
|
-
}
|
|
42
|
-
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
rl.registerAction(`${resource}.update`, {
|
|
77
|
+
description: `Update a ${resource}`,
|
|
78
|
+
inputSchema: {
|
|
79
|
+
id: { type: "string", required: true },
|
|
80
|
+
data: { type: "object", required: true },
|
|
81
|
+
},
|
|
43
82
|
async execute(input, ctx) {
|
|
44
83
|
const p = input;
|
|
45
84
|
const data = (await api(conn(ctx), "PUT", `/v1/${plural}/${p.id}`, p.data));
|
|
46
85
|
return data.Data;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
rl.registerAction(`${resource}.delete`, {
|
|
89
|
+
description: `Delete a ${resource}`,
|
|
90
|
+
inputSchema: { id: { type: "string", required: true } },
|
|
91
|
+
async execute(input, ctx) {
|
|
92
|
+
return api(conn(ctx), "DELETE", `/v1/${plural}/${input.id}`);
|
|
93
|
+
},
|
|
94
|
+
});
|
|
50
95
|
}
|
|
51
96
|
export default function salesmate(rl) {
|
|
52
97
|
rl.setName("salesmate");
|
|
53
98
|
rl.setVersion("0.1.0");
|
|
54
99
|
rl.setConnectionSchema({
|
|
55
|
-
sessionToken: {
|
|
56
|
-
|
|
100
|
+
sessionToken: {
|
|
101
|
+
type: "string",
|
|
102
|
+
required: true,
|
|
103
|
+
description: "Salesmate session token",
|
|
104
|
+
env: "SALESMATE_SESSION_TOKEN",
|
|
105
|
+
},
|
|
106
|
+
linkname: {
|
|
107
|
+
type: "string",
|
|
108
|
+
required: true,
|
|
109
|
+
description: "Salesmate workspace linkname (subdomain)",
|
|
110
|
+
env: "SALESMATE_LINKNAME",
|
|
111
|
+
},
|
|
57
112
|
});
|
|
58
113
|
registerCrud(rl, "company", "companies", getConn, {
|
|
59
114
|
name: { type: "string", required: true },
|
|
@@ -65,7 +120,11 @@ export default function salesmate(rl) {
|
|
|
65
120
|
registerCrud(rl, "activity", "activities", getConn, {
|
|
66
121
|
title: { type: "string", required: true },
|
|
67
122
|
owner: { type: "number", required: true },
|
|
68
|
-
type: {
|
|
123
|
+
type: {
|
|
124
|
+
type: "string",
|
|
125
|
+
required: true,
|
|
126
|
+
description: "e.g. call, email, task",
|
|
127
|
+
},
|
|
69
128
|
description: { type: "string", required: false },
|
|
70
129
|
dueDate: { type: "string", required: false },
|
|
71
130
|
});
|
|
@@ -7,7 +7,13 @@ async function apiRequest(token, method, endpoint, body, qs) {
|
|
|
7
7
|
url.searchParams.set(k, String(v));
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
const init = {
|
|
10
|
+
const init = {
|
|
11
|
+
method,
|
|
12
|
+
headers: {
|
|
13
|
+
Authorization: `Token ${token}`,
|
|
14
|
+
"Content-Type": "application/json",
|
|
15
|
+
},
|
|
16
|
+
};
|
|
11
17
|
if (body && Object.keys(body).length > 0)
|
|
12
18
|
init.body = JSON.stringify(body);
|
|
13
19
|
const res = await fetch(url.toString(), init);
|
|
@@ -20,7 +26,12 @@ export default function securityScorecard(rl) {
|
|
|
20
26
|
rl.setName("securityScorecard");
|
|
21
27
|
rl.setVersion("0.1.0");
|
|
22
28
|
rl.setConnectionSchema({
|
|
23
|
-
apiKey: {
|
|
29
|
+
apiKey: {
|
|
30
|
+
type: "string",
|
|
31
|
+
required: true,
|
|
32
|
+
description: "SecurityScorecard API key",
|
|
33
|
+
env: "SECURITYSCORECARD_API_KEY",
|
|
34
|
+
},
|
|
24
35
|
});
|
|
25
36
|
const key = (ctx) => ctx.connection.config.apiKey;
|
|
26
37
|
// ── Company ─────────────────────────────────────────
|
|
@@ -33,7 +44,10 @@ export default function securityScorecard(rl) {
|
|
|
33
44
|
});
|
|
34
45
|
rl.registerAction("company.getFactors", {
|
|
35
46
|
description: "Get factor scores for a company",
|
|
36
|
-
inputSchema: {
|
|
47
|
+
inputSchema: {
|
|
48
|
+
domain: { type: "string", required: true },
|
|
49
|
+
limit: { type: "number", required: false },
|
|
50
|
+
},
|
|
37
51
|
async execute(input, ctx) {
|
|
38
52
|
const p = input;
|
|
39
53
|
const data = (await apiRequest(key(ctx), "GET", `companies/${p.domain}/factors`));
|
|
@@ -47,8 +61,16 @@ export default function securityScorecard(rl) {
|
|
|
47
61
|
description: "Get historical score data for a company",
|
|
48
62
|
inputSchema: {
|
|
49
63
|
domain: { type: "string", required: true },
|
|
50
|
-
from: {
|
|
51
|
-
|
|
64
|
+
from: {
|
|
65
|
+
type: "string",
|
|
66
|
+
required: false,
|
|
67
|
+
description: "Start date YYYY-MM-DD",
|
|
68
|
+
},
|
|
69
|
+
to: {
|
|
70
|
+
type: "string",
|
|
71
|
+
required: false,
|
|
72
|
+
description: "End date YYYY-MM-DD",
|
|
73
|
+
},
|
|
52
74
|
limit: { type: "number", required: false },
|
|
53
75
|
},
|
|
54
76
|
async execute(input, ctx) {
|
|
@@ -91,11 +113,19 @@ export default function securityScorecard(rl) {
|
|
|
91
113
|
inputSchema: {
|
|
92
114
|
name: { type: "string", required: true },
|
|
93
115
|
description: { type: "string", required: true },
|
|
94
|
-
privacy: {
|
|
116
|
+
privacy: {
|
|
117
|
+
type: "string",
|
|
118
|
+
required: true,
|
|
119
|
+
description: "private or shared",
|
|
120
|
+
},
|
|
95
121
|
},
|
|
96
122
|
async execute(input, ctx) {
|
|
97
123
|
const p = input;
|
|
98
|
-
return apiRequest(key(ctx), "POST", "portfolios", {
|
|
124
|
+
return apiRequest(key(ctx), "POST", "portfolios", {
|
|
125
|
+
name: p.name,
|
|
126
|
+
description: p.description,
|
|
127
|
+
privacy: p.privacy,
|
|
128
|
+
});
|
|
99
129
|
},
|
|
100
130
|
});
|
|
101
131
|
rl.registerAction("portfolio.list", {
|
|
@@ -119,7 +149,10 @@ export default function securityScorecard(rl) {
|
|
|
119
149
|
});
|
|
120
150
|
rl.registerAction("portfolioCompany.add", {
|
|
121
151
|
description: "Add a company to a portfolio",
|
|
122
|
-
inputSchema: {
|
|
152
|
+
inputSchema: {
|
|
153
|
+
portfolioId: { type: "string", required: true },
|
|
154
|
+
domain: { type: "string", required: true },
|
|
155
|
+
},
|
|
123
156
|
async execute(input, ctx) {
|
|
124
157
|
const p = input;
|
|
125
158
|
return apiRequest(key(ctx), "PUT", `portfolios/${p.portfolioId}/companies/${p.domain}`);
|
|
@@ -127,7 +160,10 @@ export default function securityScorecard(rl) {
|
|
|
127
160
|
});
|
|
128
161
|
rl.registerAction("portfolioCompany.remove", {
|
|
129
162
|
description: "Remove a company from a portfolio",
|
|
130
|
-
inputSchema: {
|
|
163
|
+
inputSchema: {
|
|
164
|
+
portfolioId: { type: "string", required: true },
|
|
165
|
+
domain: { type: "string", required: true },
|
|
166
|
+
},
|
|
131
167
|
async execute(input, ctx) {
|
|
132
168
|
const p = input;
|
|
133
169
|
await apiRequest(key(ctx), "DELETE", `portfolios/${p.portfolioId}/companies/${p.domain}`);
|
|
@@ -136,7 +172,10 @@ export default function securityScorecard(rl) {
|
|
|
136
172
|
});
|
|
137
173
|
rl.registerAction("portfolioCompany.list", {
|
|
138
174
|
description: "List companies in a portfolio",
|
|
139
|
-
inputSchema: {
|
|
175
|
+
inputSchema: {
|
|
176
|
+
portfolioId: { type: "string", required: true },
|
|
177
|
+
limit: { type: "number", required: false },
|
|
178
|
+
},
|
|
140
179
|
async execute(input, ctx) {
|
|
141
180
|
const p = input;
|
|
142
181
|
const data = (await apiRequest(key(ctx), "GET", `portfolios/${p.portfolioId}/companies`));
|
|
@@ -158,7 +197,10 @@ export default function securityScorecard(rl) {
|
|
|
158
197
|
async execute(input, ctx) {
|
|
159
198
|
const p = input;
|
|
160
199
|
return apiRequest(key(ctx), "POST", "invitations", {
|
|
161
|
-
email: p.email,
|
|
200
|
+
email: p.email,
|
|
201
|
+
first_name: p.firstName,
|
|
202
|
+
last_name: p.lastName,
|
|
203
|
+
message: p.message,
|
|
162
204
|
});
|
|
163
205
|
},
|
|
164
206
|
});
|
|
@@ -166,10 +208,26 @@ export default function securityScorecard(rl) {
|
|
|
166
208
|
rl.registerAction("report.generate", {
|
|
167
209
|
description: "Generate a report",
|
|
168
210
|
inputSchema: {
|
|
169
|
-
reportType: {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
211
|
+
reportType: {
|
|
212
|
+
type: "string",
|
|
213
|
+
required: true,
|
|
214
|
+
description: "Report type: detailed, summary, issues, portfolio, events-json, full-scorecard-json, scorecard-footprint",
|
|
215
|
+
},
|
|
216
|
+
scorecardIdentifier: {
|
|
217
|
+
type: "string",
|
|
218
|
+
required: false,
|
|
219
|
+
description: "Company domain (for non-portfolio reports)",
|
|
220
|
+
},
|
|
221
|
+
portfolioId: {
|
|
222
|
+
type: "string",
|
|
223
|
+
required: false,
|
|
224
|
+
description: "Portfolio ID (for portfolio reports)",
|
|
225
|
+
},
|
|
226
|
+
format: {
|
|
227
|
+
type: "string",
|
|
228
|
+
required: false,
|
|
229
|
+
description: "pdf or csv (for issues/portfolio)",
|
|
230
|
+
},
|
|
173
231
|
branding: { type: "string", required: false },
|
|
174
232
|
},
|
|
175
233
|
async execute(input, ctx) {
|
|
@@ -16,15 +16,28 @@ export default function segment(rl) {
|
|
|
16
16
|
rl.setName("segment");
|
|
17
17
|
rl.setVersion("0.1.0");
|
|
18
18
|
rl.setConnectionSchema({
|
|
19
|
-
writeKey: {
|
|
19
|
+
writeKey: {
|
|
20
|
+
type: "string",
|
|
21
|
+
required: true,
|
|
22
|
+
description: "Segment source write key",
|
|
23
|
+
env: "SEGMENT_WRITE_KEY",
|
|
24
|
+
},
|
|
20
25
|
});
|
|
21
26
|
const key = (ctx) => ctx.connection.config.writeKey;
|
|
22
27
|
rl.registerAction("identify.create", {
|
|
23
28
|
description: "Identify a user (tie user to traits)",
|
|
24
29
|
inputSchema: {
|
|
25
|
-
userId: {
|
|
30
|
+
userId: {
|
|
31
|
+
type: "string",
|
|
32
|
+
required: false,
|
|
33
|
+
description: "User ID (or anonymousId will be generated)",
|
|
34
|
+
},
|
|
26
35
|
anonymousId: { type: "string", required: false },
|
|
27
|
-
traits: {
|
|
36
|
+
traits: {
|
|
37
|
+
type: "object",
|
|
38
|
+
required: false,
|
|
39
|
+
description: "User traits key-value pairs",
|
|
40
|
+
},
|
|
28
41
|
context: { type: "object", required: false },
|
|
29
42
|
integrations: { type: "object", required: false },
|
|
30
43
|
},
|
|
@@ -50,7 +63,11 @@ export default function segment(rl) {
|
|
|
50
63
|
event: { type: "string", required: true, description: "Event name" },
|
|
51
64
|
userId: { type: "string", required: false },
|
|
52
65
|
anonymousId: { type: "string", required: false },
|
|
53
|
-
properties: {
|
|
66
|
+
properties: {
|
|
67
|
+
type: "object",
|
|
68
|
+
required: false,
|
|
69
|
+
description: "Event properties",
|
|
70
|
+
},
|
|
54
71
|
context: { type: "object", required: false },
|
|
55
72
|
integrations: { type: "object", required: false },
|
|
56
73
|
},
|