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.
Files changed (230) hide show
  1. package/.pi/extensions/runline-context/index.ts +135 -0
  2. package/.pi/extensions/runline-context/package.json +17 -0
  3. package/README.md +273 -0
  4. package/dist/commands/actions.d.ts +3 -0
  5. package/dist/commands/actions.js +43 -0
  6. package/dist/commands/connection.d.ts +11 -0
  7. package/dist/commands/connection.js +56 -0
  8. package/dist/commands/exec.d.ts +5 -0
  9. package/dist/commands/exec.js +46 -0
  10. package/dist/commands/init.d.ts +4 -0
  11. package/dist/commands/init.js +26 -0
  12. package/dist/commands/plugin.d.ts +10 -0
  13. package/dist/commands/plugin.js +57 -0
  14. package/dist/config/index.d.ts +3 -0
  15. package/dist/config/index.js +2 -0
  16. package/dist/config/loader.d.ts +11 -0
  17. package/dist/config/loader.js +82 -0
  18. package/dist/config/types.d.ts +9 -0
  19. package/dist/config/types.js +5 -0
  20. package/dist/core/engine.d.ts +21 -0
  21. package/dist/core/engine.js +280 -0
  22. package/dist/index.d.ts +16 -0
  23. package/dist/index.js +9 -0
  24. package/dist/main.d.ts +2 -0
  25. package/dist/main.js +127 -0
  26. package/dist/plugin/api.d.ts +32 -0
  27. package/dist/plugin/api.js +68 -0
  28. package/dist/plugin/installer.d.ts +27 -0
  29. package/dist/plugin/installer.js +181 -0
  30. package/dist/plugin/loader.d.ts +13 -0
  31. package/dist/plugin/loader.js +164 -0
  32. package/dist/plugin/registry.d.ts +18 -0
  33. package/dist/plugin/registry.js +43 -0
  34. package/dist/plugin/types.d.ts +40 -0
  35. package/dist/plugin/types.js +1 -0
  36. package/dist/plugins/actionNetwork/src/index.js +353 -0
  37. package/dist/plugins/activeCampaign/src/index.js +711 -0
  38. package/dist/plugins/adalo/src/index.js +131 -0
  39. package/dist/plugins/affinity/src/index.js +279 -0
  40. package/dist/plugins/agileCrm/src/index.js +415 -0
  41. package/dist/plugins/airtable/src/index.js +280 -0
  42. package/dist/plugins/airtop/src/index.js +527 -0
  43. package/dist/plugins/apiTemplateIo/src/index.js +86 -0
  44. package/dist/plugins/asana/src/index.js +413 -0
  45. package/dist/plugins/autopilot/src/index.js +203 -0
  46. package/dist/plugins/bambooHr/src/index.js +252 -0
  47. package/dist/plugins/bannerbear/src/index.js +100 -0
  48. package/dist/plugins/baserow/src/index.js +180 -0
  49. package/dist/plugins/beeminder/src/index.js +298 -0
  50. package/dist/plugins/bitly/src/index.js +107 -0
  51. package/dist/plugins/bitwarden/src/index.js +383 -0
  52. package/dist/plugins/box/src/index.js +300 -0
  53. package/dist/plugins/brandfetch/src/index.js +80 -0
  54. package/dist/plugins/brevo/src/index.js +305 -0
  55. package/dist/plugins/bubble/src/index.js +181 -0
  56. package/dist/plugins/chargebee/src/index.js +126 -0
  57. package/dist/plugins/circleci/src/index.js +111 -0
  58. package/dist/plugins/ciscoWebex/src/index.js +245 -0
  59. package/dist/plugins/clearbit/src/index.js +103 -0
  60. package/dist/plugins/clickup/src/index.js +1043 -0
  61. package/dist/plugins/clockify/src/index.js +443 -0
  62. package/dist/plugins/cloudflare/src/index.js +93 -0
  63. package/dist/plugins/cockpit/src/index.js +131 -0
  64. package/dist/plugins/coda/src/index.js +327 -0
  65. package/dist/plugins/coingecko/src/index.js +244 -0
  66. package/dist/plugins/contentful/src/index.js +146 -0
  67. package/dist/plugins/convertkit/src/index.js +270 -0
  68. package/dist/plugins/copper/src/index.js +140 -0
  69. package/dist/plugins/cortex/src/index.js +147 -0
  70. package/dist/plugins/currents/src/index.js +405 -0
  71. package/dist/plugins/customerIo/src/index.js +184 -0
  72. package/dist/plugins/databricks/src/index.js +342 -0
  73. package/dist/plugins/deepl/src/index.js +87 -0
  74. package/dist/plugins/demio/src/index.js +111 -0
  75. package/dist/plugins/dhl/src/index.js +40 -0
  76. package/dist/plugins/discord/src/index.js +275 -0
  77. package/dist/plugins/discourse/src/index.js +273 -0
  78. package/dist/plugins/disqus/src/index.js +145 -0
  79. package/dist/plugins/docker/src/index.js +76 -0
  80. package/dist/plugins/drift/src/index.js +89 -0
  81. package/dist/plugins/dropbox/src/index.js +159 -0
  82. package/dist/plugins/dropcontact/src/index.js +59 -0
  83. package/dist/plugins/egoi/src/index.js +151 -0
  84. package/dist/plugins/elasticsearch/src/index.js +157 -0
  85. package/dist/plugins/emelia/src/index.js +174 -0
  86. package/dist/plugins/erpnext/src/index.js +121 -0
  87. package/dist/plugins/facebookGraph/src/index.js +57 -0
  88. package/dist/plugins/freshdesk/src/index.js +320 -0
  89. package/dist/plugins/freshservice/src/index.js +146 -0
  90. package/dist/plugins/freshworksCrm/src/index.js +149 -0
  91. package/dist/plugins/getresponse/src/index.js +140 -0
  92. package/dist/plugins/ghost/src/index.js +192 -0
  93. package/dist/plugins/github/src/index.js +630 -0
  94. package/dist/plugins/gitlab/src/index.js +358 -0
  95. package/dist/plugins/gong/src/index.js +126 -0
  96. package/dist/plugins/gotify/src/index.js +77 -0
  97. package/dist/plugins/gotowebinar/src/index.js +316 -0
  98. package/dist/plugins/grafana/src/index.js +250 -0
  99. package/dist/plugins/graphql/src/index.js +78 -0
  100. package/dist/plugins/grist/src/index.js +106 -0
  101. package/dist/plugins/hackernews/src/index.js +89 -0
  102. package/dist/plugins/halopsa/src/index.js +79 -0
  103. package/dist/plugins/harvest/src/index.js +163 -0
  104. package/dist/plugins/helpscout/src/index.js +176 -0
  105. package/dist/plugins/highlevel/src/index.js +172 -0
  106. package/dist/plugins/homeAssistant/src/index.js +148 -0
  107. package/dist/plugins/hubspot/src/index.js +176 -0
  108. package/dist/plugins/humanticAi/src/index.js +60 -0
  109. package/dist/plugins/hunter/src/index.js +59 -0
  110. package/dist/plugins/intercom/src/index.js +156 -0
  111. package/dist/plugins/iterable/src/index.js +139 -0
  112. package/dist/plugins/jenkins/src/index.js +132 -0
  113. package/dist/plugins/jira/src/index.js +229 -0
  114. package/dist/plugins/keap/src/index.js +502 -0
  115. package/dist/plugins/kobotoolbox/src/index.js +281 -0
  116. package/dist/plugins/lemlist/src/index.js +231 -0
  117. package/dist/plugins/linear/src/index.js +133 -0
  118. package/dist/plugins/lingvanex/src/index.js +31 -0
  119. package/dist/plugins/linkedin/src/index.js +80 -0
  120. package/dist/plugins/lonescale/src/index.js +119 -0
  121. package/dist/plugins/magento/src/index.js +300 -0
  122. package/dist/plugins/mailcheck/src/index.js +27 -0
  123. package/dist/plugins/mailchimp/src/index.js +321 -0
  124. package/dist/plugins/mailerlite/src/index.js +123 -0
  125. package/dist/plugins/mailgun/src/index.js +48 -0
  126. package/dist/plugins/mailjet/src/index.js +155 -0
  127. package/dist/plugins/mandrill/src/index.js +145 -0
  128. package/dist/plugins/marketstack/src/index.js +97 -0
  129. package/dist/plugins/matrix/src/index.js +194 -0
  130. package/dist/plugins/mattermost/src/index.js +331 -0
  131. package/dist/plugins/mautic/src/index.js +311 -0
  132. package/dist/plugins/medium/src/index.js +77 -0
  133. package/dist/plugins/messagebird/src/index.js +57 -0
  134. package/dist/plugins/metabase/src/index.js +130 -0
  135. package/dist/plugins/misp/src/index.js +476 -0
  136. package/dist/plugins/mocean/src/index.js +67 -0
  137. package/dist/plugins/monday/src/index.js +231 -0
  138. package/dist/plugins/monicaCrm/src/index.js +52 -0
  139. package/dist/plugins/msg91/src/index.js +31 -0
  140. package/dist/plugins/nasa/src/index.js +146 -0
  141. package/dist/plugins/netlify/src/index.js +151 -0
  142. package/dist/plugins/netscalerAdc/src/index.js +131 -0
  143. package/dist/plugins/nextcloud/src/index.js +263 -0
  144. package/dist/plugins/nocodb/src/index.js +130 -0
  145. package/dist/plugins/notion/src/index.js +112 -0
  146. package/dist/plugins/npm/src/index.js +104 -0
  147. package/dist/plugins/odoo/src/index.js +157 -0
  148. package/dist/plugins/okta/src/index.js +141 -0
  149. package/dist/plugins/oneSimpleApi/src/index.js +155 -0
  150. package/dist/plugins/onfleet/src/index.js +254 -0
  151. package/dist/plugins/openThesaurus/src/index.js +32 -0
  152. package/dist/plugins/openweathermap/src/index.js +60 -0
  153. package/dist/plugins/oura/src/index.js +62 -0
  154. package/dist/plugins/paddle/src/index.js +247 -0
  155. package/dist/plugins/pagerduty/src/index.js +201 -0
  156. package/dist/plugins/paypal/src/index.js +106 -0
  157. package/dist/plugins/peekalink/src/index.js +35 -0
  158. package/dist/plugins/phantombuster/src/index.js +94 -0
  159. package/dist/plugins/philipsHue/src/index.js +98 -0
  160. package/dist/plugins/pipedrive/src/index.js +169 -0
  161. package/dist/plugins/plivo/src/index.js +66 -0
  162. package/dist/plugins/postbin/src/index.js +93 -0
  163. package/dist/plugins/posthog/src/index.js +113 -0
  164. package/dist/plugins/profitwell/src/index.js +50 -0
  165. package/dist/plugins/pushbullet/src/index.js +102 -0
  166. package/dist/plugins/pushcut/src/index.js +39 -0
  167. package/dist/plugins/pushover/src/index.js +65 -0
  168. package/dist/plugins/quickbase/src/index.js +153 -0
  169. package/dist/plugins/quickbooks/src/index.js +73 -0
  170. package/dist/plugins/quickchart/src/index.js +36 -0
  171. package/dist/plugins/raindrop/src/index.js +209 -0
  172. package/dist/plugins/reddit/src/index.js +185 -0
  173. package/dist/plugins/rocketchat/src/index.js +53 -0
  174. package/dist/plugins/rundeck/src/index.js +62 -0
  175. package/dist/plugins/salesforce/src/index.js +94 -0
  176. package/dist/plugins/salesmate/src/index.js +83 -0
  177. package/dist/plugins/securityScorecard/src/index.js +200 -0
  178. package/dist/plugins/segment/src/index.js +125 -0
  179. package/dist/plugins/sendgrid/src/index.js +187 -0
  180. package/dist/plugins/sendy/src/index.js +138 -0
  181. package/dist/plugins/sentry/src/index.js +233 -0
  182. package/dist/plugins/servicenow/src/index.js +108 -0
  183. package/dist/plugins/shopify/src/index.js +222 -0
  184. package/dist/plugins/signl4/src/index.js +61 -0
  185. package/dist/plugins/slack/src/index.js +236 -0
  186. package/dist/plugins/sms77/src/index.js +63 -0
  187. package/dist/plugins/splunk/src/index.js +207 -0
  188. package/dist/plugins/spotify/src/index.js +188 -0
  189. package/dist/plugins/stackby/src/index.js +82 -0
  190. package/dist/plugins/storyblok/src/index.js +141 -0
  191. package/dist/plugins/strapi/src/index.js +152 -0
  192. package/dist/plugins/strava/src/index.js +137 -0
  193. package/dist/plugins/stripe/src/index.js +222 -0
  194. package/dist/plugins/supabase/src/index.js +121 -0
  195. package/dist/plugins/syncromsp/src/index.js +255 -0
  196. package/dist/plugins/tapfiliate/src/index.js +125 -0
  197. package/dist/plugins/telegram/src/index.js +233 -0
  198. package/dist/plugins/thehive/src/index.js +142 -0
  199. package/dist/plugins/thehiveProject/src/index.js +194 -0
  200. package/dist/plugins/todoist/src/index.js +244 -0
  201. package/dist/plugins/travisci/src/index.js +71 -0
  202. package/dist/plugins/trello/src/index.js +341 -0
  203. package/dist/plugins/twake/src/index.js +40 -0
  204. package/dist/plugins/twilio/src/index.js +75 -0
  205. package/dist/plugins/twist/src/index.js +90 -0
  206. package/dist/plugins/twitter/src/index.js +123 -0
  207. package/dist/plugins/unleashedSoftware/src/index.js +84 -0
  208. package/dist/plugins/uplead/src/index.js +59 -0
  209. package/dist/plugins/uproc/src/index.js +34 -0
  210. package/dist/plugins/uptimerobot/src/index.js +264 -0
  211. package/dist/plugins/urlscanio/src/index.js +64 -0
  212. package/dist/plugins/vero/src/index.js +80 -0
  213. package/dist/plugins/vonage/src/index.js +42 -0
  214. package/dist/plugins/wekan/src/index.js +91 -0
  215. package/dist/plugins/woocommerce/src/index.js +92 -0
  216. package/dist/plugins/wordpress/src/index.js +121 -0
  217. package/dist/plugins/xero/src/index.js +136 -0
  218. package/dist/plugins/yourls/src/index.js +56 -0
  219. package/dist/plugins/zammad/src/index.js +91 -0
  220. package/dist/plugins/zendesk/src/index.js +137 -0
  221. package/dist/plugins/zoho/src/index.js +85 -0
  222. package/dist/plugins/zoom/src/index.js +122 -0
  223. package/dist/plugins/zulip/src/index.js +170 -0
  224. package/dist/sdk.d.ts +38 -0
  225. package/dist/sdk.js +105 -0
  226. package/dist/utils/cli.d.ts +13 -0
  227. package/dist/utils/cli.js +32 -0
  228. package/dist/utils/output.d.ts +4 -0
  229. package/dist/utils/output.js +13 -0
  230. package/package.json +57 -0
@@ -0,0 +1,255 @@
1
+ function getConn(ctx) {
2
+ const subdomain = ctx.connection.config.subdomain;
3
+ const apiKey = ctx.connection.config.apiKey;
4
+ return { base: `https://${subdomain}.syncromsp.com/api/v1`, apiKey };
5
+ }
6
+ async function api(base, apiKey, method, endpoint, body, qs) {
7
+ const url = new URL(`${base}/${endpoint}`);
8
+ url.searchParams.set("api_key", apiKey);
9
+ if (qs) {
10
+ for (const [k, v] of Object.entries(qs)) {
11
+ if (v !== undefined && v !== null)
12
+ url.searchParams.set(k, String(v));
13
+ }
14
+ }
15
+ const init = { method, headers: { "Content-Type": "application/json" } };
16
+ if (body && Object.keys(body).length > 0)
17
+ init.body = JSON.stringify(body);
18
+ const res = await fetch(url.toString(), init);
19
+ if (!res.ok)
20
+ throw new Error(`SyncroMSP error ${res.status}: ${await res.text()}`);
21
+ const text = await res.text();
22
+ return text ? JSON.parse(text) : { success: true };
23
+ }
24
+ async function paginate(base, apiKey, endpoint, key, qs = {}) {
25
+ const results = [];
26
+ let page = 1;
27
+ let batch;
28
+ do {
29
+ qs.page = page;
30
+ const res = await api(base, apiKey, "GET", endpoint, undefined, qs);
31
+ batch = (res[key] ?? []);
32
+ results.push(...batch);
33
+ page++;
34
+ } while (batch.length > 0);
35
+ return results;
36
+ }
37
+ export default function syncromsp(rl) {
38
+ rl.setName("syncromsp");
39
+ rl.setVersion("0.1.0");
40
+ rl.setConnectionSchema({
41
+ subdomain: { type: "string", required: true, description: "SyncroMSP subdomain", env: "SYNCROMSP_SUBDOMAIN" },
42
+ apiKey: { type: "string", required: true, description: "API key", env: "SYNCROMSP_API_KEY" },
43
+ });
44
+ // ── Customer ────────────────────────────────────────
45
+ rl.registerAction("customer.create", { description: "Create a customer",
46
+ inputSchema: { email: { type: "string", required: true }, businessName: { type: "string", required: false }, firstName: { type: "string", required: false }, lastname: { type: "string", required: false }, phone: { type: "string", required: false }, notes: { type: "string", required: false }, address: { type: "string", required: false }, city: { type: "string", required: false }, state: { type: "string", required: false }, zip: { type: "string", required: false } },
47
+ async execute(input, ctx) {
48
+ const { base, apiKey } = getConn(ctx);
49
+ const p = input;
50
+ const body = { email: p.email };
51
+ if (p.businessName)
52
+ body.business_name = p.businessName;
53
+ if (p.firstName)
54
+ body.firstname = p.firstName;
55
+ if (p.lastname)
56
+ body.lastname = p.lastname;
57
+ if (p.phone)
58
+ body.phone = p.phone;
59
+ if (p.notes)
60
+ body.notes = p.notes;
61
+ if (p.address)
62
+ body.address = p.address;
63
+ if (p.city)
64
+ body.city = p.city;
65
+ if (p.state)
66
+ body.state = p.state;
67
+ if (p.zip)
68
+ body.zip = p.zip;
69
+ const res = await api(base, apiKey, "POST", "customers", body);
70
+ return res.customer ?? res;
71
+ } });
72
+ rl.registerAction("customer.get", { description: "Get a customer", inputSchema: { id: { type: "string", required: true } },
73
+ async execute(input, ctx) { const { base, apiKey } = getConn(ctx); const res = await api(base, apiKey, "GET", `customers/${input.id}`); return res.customer ?? res; } });
74
+ rl.registerAction("customer.list", { description: "List customers",
75
+ inputSchema: { limit: { type: "number", required: false }, businessName: { type: "string", required: false }, includeDisabled: { type: "boolean", required: false } },
76
+ async execute(input, ctx) {
77
+ const { base, apiKey } = getConn(ctx);
78
+ const p = (input ?? {});
79
+ const qs = {};
80
+ if (p.businessName)
81
+ qs.business_name = p.businessName;
82
+ if (p.includeDisabled)
83
+ qs.include_disabled = true;
84
+ if (p.limit) {
85
+ qs.per_page = p.limit;
86
+ const res = await api(base, apiKey, "GET", "customers", undefined, qs);
87
+ return res.customers ?? res;
88
+ }
89
+ return paginate(base, apiKey, "customers", "customers", qs);
90
+ } });
91
+ rl.registerAction("customer.update", { description: "Update a customer",
92
+ inputSchema: { id: { type: "string", required: true }, email: { type: "string", required: false }, businessName: { type: "string", required: false }, firstName: { type: "string", required: false }, lastname: { type: "string", required: false }, phone: { type: "string", required: false }, notes: { type: "string", required: false } },
93
+ async execute(input, ctx) {
94
+ const { base, apiKey } = getConn(ctx);
95
+ const { id, ...fields } = input;
96
+ const body = {};
97
+ if (fields.email)
98
+ body.email = fields.email;
99
+ if (fields.businessName)
100
+ body.business_name = fields.businessName;
101
+ if (fields.firstName)
102
+ body.firstname = fields.firstName;
103
+ if (fields.lastname)
104
+ body.lastname = fields.lastname;
105
+ if (fields.phone)
106
+ body.phone = fields.phone;
107
+ if (fields.notes)
108
+ body.notes = fields.notes;
109
+ const res = await api(base, apiKey, "PUT", `customers/${id}`, body);
110
+ return res.customer ?? res;
111
+ } });
112
+ rl.registerAction("customer.delete", { description: "Delete a customer", inputSchema: { id: { type: "string", required: true } },
113
+ async execute(input, ctx) { const { base, apiKey } = getConn(ctx); await api(base, apiKey, "DELETE", `customers/${input.id}`); return { success: true }; } });
114
+ // ── Contact ─────────────────────────────────────────
115
+ rl.registerAction("contact.create", { description: "Create a contact",
116
+ inputSchema: { customerId: { type: "string", required: true }, email: { type: "string", required: true }, name: { type: "string", required: false }, phone: { type: "string", required: false }, notes: { type: "string", required: false } },
117
+ async execute(input, ctx) {
118
+ const { base, apiKey } = getConn(ctx);
119
+ const p = input;
120
+ const body = { customer_id: p.customerId, email: p.email };
121
+ if (p.name)
122
+ body.name = p.name;
123
+ if (p.phone)
124
+ body.phone = p.phone;
125
+ if (p.notes)
126
+ body.notes = p.notes;
127
+ return api(base, apiKey, "POST", "contacts", body);
128
+ } });
129
+ rl.registerAction("contact.get", { description: "Get a contact", inputSchema: { id: { type: "string", required: true } },
130
+ async execute(input, ctx) { const { base, apiKey } = getConn(ctx); return api(base, apiKey, "GET", `contacts/${input.id}`); } });
131
+ rl.registerAction("contact.list", { description: "List contacts",
132
+ inputSchema: { limit: { type: "number", required: false } },
133
+ async execute(input, ctx) {
134
+ const { base, apiKey } = getConn(ctx);
135
+ const p = (input ?? {});
136
+ if (p.limit) {
137
+ const res = await api(base, apiKey, "GET", "contacts");
138
+ return (res.contacts ?? []).slice(0, p.limit);
139
+ }
140
+ return paginate(base, apiKey, "contacts", "contacts");
141
+ } });
142
+ rl.registerAction("contact.update", { description: "Update a contact",
143
+ inputSchema: { id: { type: "string", required: true }, customerId: { type: "string", required: false }, email: { type: "string", required: false }, name: { type: "string", required: false }, phone: { type: "string", required: false }, notes: { type: "string", required: false } },
144
+ async execute(input, ctx) {
145
+ const { base, apiKey } = getConn(ctx);
146
+ const { id, ...fields } = input;
147
+ const body = {};
148
+ if (fields.customerId)
149
+ body.customer_id = fields.customerId;
150
+ if (fields.email)
151
+ body.email = fields.email;
152
+ if (fields.name)
153
+ body.name = fields.name;
154
+ if (fields.phone)
155
+ body.phone = fields.phone;
156
+ if (fields.notes)
157
+ body.notes = fields.notes;
158
+ return api(base, apiKey, "PUT", `contacts/${id}`, body);
159
+ } });
160
+ rl.registerAction("contact.delete", { description: "Delete a contact", inputSchema: { id: { type: "string", required: true } },
161
+ async execute(input, ctx) { const { base, apiKey } = getConn(ctx); await api(base, apiKey, "DELETE", `contacts/${input.id}`); return { success: true }; } });
162
+ // ── Ticket ──────────────────────────────────────────
163
+ rl.registerAction("ticket.create", { description: "Create a ticket",
164
+ inputSchema: { customerId: { type: "string", required: true }, subject: { type: "string", required: true }, issueType: { type: "string", required: false }, status: { type: "string", required: false }, assetId: { type: "string", required: false }, contactId: { type: "string", required: false } },
165
+ async execute(input, ctx) {
166
+ const { base, apiKey } = getConn(ctx);
167
+ const p = input;
168
+ const body = { customer_id: p.customerId, subject: p.subject };
169
+ if (p.issueType)
170
+ body.problem_type = p.issueType;
171
+ if (p.status)
172
+ body.status = p.status;
173
+ if (p.assetId)
174
+ body.asset_id = p.assetId;
175
+ if (p.contactId)
176
+ body.contact_id = p.contactId;
177
+ const res = await api(base, apiKey, "POST", "tickets", body);
178
+ return res.ticket ?? res;
179
+ } });
180
+ rl.registerAction("ticket.get", { description: "Get a ticket", inputSchema: { id: { type: "string", required: true } },
181
+ async execute(input, ctx) { const { base, apiKey } = getConn(ctx); const res = await api(base, apiKey, "GET", `tickets/${input.id}`); return res.ticket ?? res; } });
182
+ rl.registerAction("ticket.list", { description: "List tickets",
183
+ inputSchema: { limit: { type: "number", required: false }, status: { type: "string", required: false } },
184
+ async execute(input, ctx) {
185
+ const { base, apiKey } = getConn(ctx);
186
+ const p = (input ?? {});
187
+ const qs = {};
188
+ if (p.status)
189
+ qs.status = p.status;
190
+ if (p.limit) {
191
+ qs.per_page = p.limit;
192
+ const res = await api(base, apiKey, "GET", "tickets", undefined, qs);
193
+ return res.tickets ?? res;
194
+ }
195
+ return paginate(base, apiKey, "tickets", "tickets", qs);
196
+ } });
197
+ rl.registerAction("ticket.update", { description: "Update a ticket",
198
+ inputSchema: { id: { type: "string", required: true }, subject: { type: "string", required: false }, status: { type: "string", required: false }, issueType: { type: "string", required: false }, customerId: { type: "string", required: false }, assetId: { type: "string", required: false }, dueDate: { type: "string", required: false }, contactId: { type: "string", required: false } },
199
+ async execute(input, ctx) {
200
+ const { base, apiKey } = getConn(ctx);
201
+ const { id, ...fields } = input;
202
+ const body = {};
203
+ if (fields.subject)
204
+ body.subject = fields.subject;
205
+ if (fields.status)
206
+ body.status = fields.status;
207
+ if (fields.issueType)
208
+ body.problem_type = fields.issueType;
209
+ if (fields.customerId)
210
+ body.customer_id = fields.customerId;
211
+ if (fields.assetId)
212
+ body.asset_id = fields.assetId;
213
+ if (fields.dueDate)
214
+ body.due_date = fields.dueDate;
215
+ if (fields.contactId)
216
+ body.contact_id = fields.contactId;
217
+ const res = await api(base, apiKey, "PUT", `tickets/${id}`, body);
218
+ return res.ticket ?? res;
219
+ } });
220
+ rl.registerAction("ticket.delete", { description: "Delete a ticket", inputSchema: { id: { type: "string", required: true } },
221
+ async execute(input, ctx) { const { base, apiKey } = getConn(ctx); await api(base, apiKey, "DELETE", `tickets/${input.id}`); return { success: true }; } });
222
+ // ── RMM Alerts ──────────────────────────────────────
223
+ rl.registerAction("rmmAlert.create", { description: "Create an RMM alert",
224
+ inputSchema: { customerId: { type: "string", required: true }, assetId: { type: "string", required: true }, description: { type: "string", required: true } },
225
+ async execute(input, ctx) {
226
+ const { base, apiKey } = getConn(ctx);
227
+ const p = input;
228
+ const res = await api(base, apiKey, "POST", "rmm_alerts", { customer_id: p.customerId, asset_id: p.assetId, description: p.description });
229
+ return res.alert ?? res;
230
+ } });
231
+ rl.registerAction("rmmAlert.get", { description: "Get an RMM alert", inputSchema: { id: { type: "string", required: true } },
232
+ async execute(input, ctx) { const { base, apiKey } = getConn(ctx); const res = await api(base, apiKey, "GET", `rmm_alerts/${input.id}`); return res.rmm_alert ?? res; } });
233
+ rl.registerAction("rmmAlert.list", { description: "List RMM alerts",
234
+ inputSchema: { limit: { type: "number", required: false }, status: { type: "string", required: false, description: "all, active, or resolved" } },
235
+ async execute(input, ctx) {
236
+ const { base, apiKey } = getConn(ctx);
237
+ const p = (input ?? {});
238
+ const qs = { status: p.status ?? "all" };
239
+ if (p.limit) {
240
+ qs.per_page = p.limit;
241
+ const res = await api(base, apiKey, "GET", "rmm_alerts", undefined, qs);
242
+ return res.rmm_alerts ?? res;
243
+ }
244
+ return paginate(base, apiKey, "rmm_alerts", "rmm_alerts", qs);
245
+ } });
246
+ rl.registerAction("rmmAlert.delete", { description: "Delete an RMM alert", inputSchema: { id: { type: "string", required: true } },
247
+ async execute(input, ctx) { const { base, apiKey } = getConn(ctx); await api(base, apiKey, "DELETE", `rmm_alerts/${input.id}`); return { success: true }; } });
248
+ rl.registerAction("rmmAlert.mute", { description: "Mute an RMM alert",
249
+ inputSchema: { id: { type: "string", required: true }, muteFor: { type: "string", required: true, description: "Duration to mute, e.g. 1_hour, 1_day, forever" } },
250
+ async execute(input, ctx) {
251
+ const { base, apiKey } = getConn(ctx);
252
+ const p = input;
253
+ return api(base, apiKey, "POST", `rmm_alerts/${p.id}/mute`, { id: p.id, mute_for: p.muteFor });
254
+ } });
255
+ }
@@ -0,0 +1,125 @@
1
+ const BASE = "https://api.tapfiliate.com/1.6";
2
+ async function apiRequest(apiKey, method, endpoint, body, qs) {
3
+ const url = new URL(`${BASE}${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 init = { method, headers: { "Api-Key": apiKey, "Content-Type": "application/json" } };
11
+ if (body && Object.keys(body).length > 0)
12
+ init.body = JSON.stringify(body);
13
+ const res = await fetch(url.toString(), init);
14
+ if (!res.ok)
15
+ throw new Error(`Tapfiliate error ${res.status}: ${await res.text()}`);
16
+ const text = await res.text();
17
+ return text ? JSON.parse(text) : {};
18
+ }
19
+ export default function tapfiliate(rl) {
20
+ rl.setName("tapfiliate");
21
+ rl.setVersion("0.1.0");
22
+ rl.setConnectionSchema({ apiKey: { type: "string", required: true, description: "Tapfiliate API key", env: "TAPFILIATE_API_KEY" } });
23
+ const key = (ctx) => ctx.connection.config.apiKey;
24
+ // ── Affiliate ───────────────────────────────────────
25
+ rl.registerAction("affiliate.create", {
26
+ description: "Create an affiliate",
27
+ inputSchema: {
28
+ firstname: { type: "string", required: true }, lastname: { type: "string", required: true },
29
+ email: { type: "string", required: true }, companyName: { type: "string", required: false },
30
+ },
31
+ async execute(input, ctx) {
32
+ const p = input;
33
+ const body = { firstname: p.firstname, lastname: p.lastname, email: p.email };
34
+ if (p.companyName)
35
+ body.company = { name: p.companyName };
36
+ return apiRequest(key(ctx), "POST", "/affiliates/", body);
37
+ },
38
+ });
39
+ rl.registerAction("affiliate.get", {
40
+ description: "Get an affiliate by ID",
41
+ inputSchema: { affiliateId: { type: "string", required: true } },
42
+ async execute(input, ctx) { return apiRequest(key(ctx), "GET", `/affiliates/${input.affiliateId}/`); },
43
+ });
44
+ rl.registerAction("affiliate.list", {
45
+ description: "List affiliates",
46
+ inputSchema: { limit: { type: "number", required: false }, email: { type: "string", required: false } },
47
+ async execute(input, ctx) {
48
+ const p = (input ?? {});
49
+ const qs = {};
50
+ if (p.email)
51
+ qs.email = p.email;
52
+ const data = (await apiRequest(key(ctx), "GET", "/affiliates/", undefined, qs));
53
+ return p.limit ? data.slice(0, p.limit) : data;
54
+ },
55
+ });
56
+ rl.registerAction("affiliate.delete", {
57
+ description: "Delete an affiliate",
58
+ inputSchema: { affiliateId: { type: "string", required: true } },
59
+ async execute(input, ctx) {
60
+ await apiRequest(key(ctx), "DELETE", `/affiliates/${input.affiliateId}/`);
61
+ return { success: true };
62
+ },
63
+ });
64
+ // ── Affiliate Metadata ──────────────────────────────
65
+ rl.registerAction("affiliateMetadata.set", {
66
+ description: "Set metadata key-value on an affiliate",
67
+ inputSchema: { affiliateId: { type: "string", required: true }, key: { type: "string", required: true }, value: { type: "string", required: true } },
68
+ async execute(input, ctx) {
69
+ const p = input;
70
+ return apiRequest(key(ctx), "PUT", `/affiliates/${p.affiliateId}/meta-data/${p.key}/`, { value: p.value });
71
+ },
72
+ });
73
+ rl.registerAction("affiliateMetadata.delete", {
74
+ description: "Delete a metadata key from an affiliate",
75
+ inputSchema: { affiliateId: { type: "string", required: true }, key: { type: "string", required: true } },
76
+ async execute(input, ctx) {
77
+ const p = input;
78
+ await apiRequest(key(ctx), "DELETE", `/affiliates/${p.affiliateId}/meta-data/${p.key}/`);
79
+ return { success: true };
80
+ },
81
+ });
82
+ // ── Program Affiliate ───────────────────────────────
83
+ rl.registerAction("programAffiliate.add", {
84
+ description: "Add an affiliate to a program",
85
+ inputSchema: { programId: { type: "string", required: true }, affiliateId: { type: "string", required: true } },
86
+ async execute(input, ctx) {
87
+ const p = input;
88
+ return apiRequest(key(ctx), "POST", `/programs/${p.programId}/affiliates/`, { affiliate: { id: p.affiliateId } });
89
+ },
90
+ });
91
+ rl.registerAction("programAffiliate.approve", {
92
+ description: "Approve an affiliate for a program",
93
+ inputSchema: { programId: { type: "string", required: true }, affiliateId: { type: "string", required: true } },
94
+ async execute(input, ctx) {
95
+ const p = input;
96
+ return apiRequest(key(ctx), "PUT", `/programs/${p.programId}/affiliates/${p.affiliateId}/approved/`);
97
+ },
98
+ });
99
+ rl.registerAction("programAffiliate.disapprove", {
100
+ description: "Disapprove an affiliate for a program",
101
+ inputSchema: { programId: { type: "string", required: true }, affiliateId: { type: "string", required: true } },
102
+ async execute(input, ctx) {
103
+ const p = input;
104
+ await apiRequest(key(ctx), "DELETE", `/programs/${p.programId}/affiliates/${p.affiliateId}/approved/`);
105
+ return { success: true };
106
+ },
107
+ });
108
+ rl.registerAction("programAffiliate.get", {
109
+ description: "Get an affiliate in a program",
110
+ inputSchema: { programId: { type: "string", required: true }, affiliateId: { type: "string", required: true } },
111
+ async execute(input, ctx) {
112
+ const p = input;
113
+ return apiRequest(key(ctx), "GET", `/programs/${p.programId}/affiliates/${p.affiliateId}/`);
114
+ },
115
+ });
116
+ rl.registerAction("programAffiliate.list", {
117
+ description: "List affiliates in a program",
118
+ inputSchema: { programId: { type: "string", required: true }, limit: { type: "number", required: false } },
119
+ async execute(input, ctx) {
120
+ const p = input;
121
+ const data = (await apiRequest(key(ctx), "GET", `/programs/${p.programId}/affiliates/`));
122
+ return p.limit ? data.slice(0, p.limit) : data;
123
+ },
124
+ });
125
+ }
@@ -0,0 +1,233 @@
1
+ function getConn(ctx) {
2
+ const c = ctx.connection.config;
3
+ const baseUrl = (c.baseUrl || "https://api.telegram.org").replace(/\/$/, "");
4
+ return { baseUrl, token: c.accessToken };
5
+ }
6
+ async function apiRequest(conn, method, endpoint, body) {
7
+ const url = `${conn.baseUrl}/bot${conn.token}/${endpoint}`;
8
+ const init = { method, headers: { "Content-Type": "application/json" } };
9
+ if (body && Object.keys(body).length > 0)
10
+ init.body = JSON.stringify(body);
11
+ const res = await fetch(url, init);
12
+ if (!res.ok)
13
+ throw new Error(`Telegram error ${res.status}: ${await res.text()}`);
14
+ const data = (await res.json());
15
+ if (!data.ok)
16
+ throw new Error(`Telegram API error: ${JSON.stringify(data)}`);
17
+ return data.result;
18
+ }
19
+ export default function telegram(rl) {
20
+ rl.setName("telegram");
21
+ rl.setVersion("0.1.0");
22
+ rl.setConnectionSchema({
23
+ accessToken: { type: "string", required: true, description: "Telegram Bot token", env: "TELEGRAM_BOT_TOKEN" },
24
+ baseUrl: { type: "string", required: false, description: "API base URL (default: https://api.telegram.org)", env: "TELEGRAM_BASE_URL" },
25
+ });
26
+ // ── Message ─────────────────────────────────────────
27
+ rl.registerAction("message.send", {
28
+ description: "Send a text message",
29
+ inputSchema: {
30
+ chatId: { type: "string", required: true },
31
+ text: { type: "string", required: true },
32
+ parseMode: { type: "string", required: false, description: "Markdown, MarkdownV2, or HTML" },
33
+ disableWebPagePreview: { type: "boolean", required: false },
34
+ disableNotification: { type: "boolean", required: false },
35
+ replyToMessageId: { type: "number", required: false },
36
+ },
37
+ async execute(input, ctx) {
38
+ const p = input;
39
+ const body = { chat_id: p.chatId, text: p.text };
40
+ if (p.parseMode)
41
+ body.parse_mode = p.parseMode;
42
+ if (p.disableWebPagePreview)
43
+ body.disable_web_page_preview = true;
44
+ if (p.disableNotification)
45
+ body.disable_notification = true;
46
+ if (p.replyToMessageId)
47
+ body.reply_to_message_id = p.replyToMessageId;
48
+ return apiRequest(getConn(ctx), "POST", "sendMessage", body);
49
+ },
50
+ });
51
+ rl.registerAction("message.edit", {
52
+ description: "Edit a text message",
53
+ inputSchema: {
54
+ chatId: { type: "string", required: true },
55
+ messageId: { type: "number", required: true },
56
+ text: { type: "string", required: true },
57
+ parseMode: { type: "string", required: false },
58
+ },
59
+ async execute(input, ctx) {
60
+ const p = input;
61
+ const body = { chat_id: p.chatId, message_id: p.messageId, text: p.text };
62
+ if (p.parseMode)
63
+ body.parse_mode = p.parseMode;
64
+ return apiRequest(getConn(ctx), "POST", "editMessageText", body);
65
+ },
66
+ });
67
+ rl.registerAction("message.delete", {
68
+ description: "Delete a message",
69
+ inputSchema: { chatId: { type: "string", required: true }, messageId: { type: "number", required: true } },
70
+ async execute(input, ctx) {
71
+ const p = input;
72
+ return apiRequest(getConn(ctx), "POST", "deleteMessage", { chat_id: p.chatId, message_id: p.messageId });
73
+ },
74
+ });
75
+ rl.registerAction("message.pin", {
76
+ description: "Pin a message in a chat",
77
+ inputSchema: { chatId: { type: "string", required: true }, messageId: { type: "number", required: true }, disableNotification: { type: "boolean", required: false } },
78
+ async execute(input, ctx) {
79
+ const p = input;
80
+ const body = { chat_id: p.chatId, message_id: p.messageId };
81
+ if (p.disableNotification)
82
+ body.disable_notification = true;
83
+ return apiRequest(getConn(ctx), "POST", "pinChatMessage", body);
84
+ },
85
+ });
86
+ rl.registerAction("message.unpin", {
87
+ description: "Unpin a message in a chat",
88
+ inputSchema: { chatId: { type: "string", required: true }, messageId: { type: "number", required: true } },
89
+ async execute(input, ctx) {
90
+ const p = input;
91
+ return apiRequest(getConn(ctx), "POST", "unpinChatMessage", { chat_id: p.chatId, message_id: p.messageId });
92
+ },
93
+ });
94
+ rl.registerAction("message.sendLocation", {
95
+ description: "Send a location",
96
+ inputSchema: { chatId: { type: "string", required: true }, latitude: { type: "number", required: true }, longitude: { type: "number", required: true } },
97
+ async execute(input, ctx) {
98
+ const p = input;
99
+ return apiRequest(getConn(ctx), "POST", "sendLocation", { chat_id: p.chatId, latitude: p.latitude, longitude: p.longitude });
100
+ },
101
+ });
102
+ rl.registerAction("message.sendChatAction", {
103
+ description: "Send a chat action (typing, upload_photo, etc.)",
104
+ inputSchema: { chatId: { type: "string", required: true }, action: { type: "string", required: true, description: "typing, upload_photo, record_video, etc." } },
105
+ async execute(input, ctx) {
106
+ const p = input;
107
+ return apiRequest(getConn(ctx), "POST", "sendChatAction", { chat_id: p.chatId, action: p.action });
108
+ },
109
+ });
110
+ rl.registerAction("message.sendPhoto", {
111
+ description: "Send a photo by URL",
112
+ inputSchema: { chatId: { type: "string", required: true }, photo: { type: "string", required: true, description: "Photo URL or file_id" }, caption: { type: "string", required: false } },
113
+ async execute(input, ctx) {
114
+ const p = input;
115
+ const body = { chat_id: p.chatId, photo: p.photo };
116
+ if (p.caption)
117
+ body.caption = p.caption;
118
+ return apiRequest(getConn(ctx), "POST", "sendPhoto", body);
119
+ },
120
+ });
121
+ rl.registerAction("message.sendDocument", {
122
+ description: "Send a document by URL",
123
+ inputSchema: { chatId: { type: "string", required: true }, document: { type: "string", required: true, description: "Document URL or file_id" }, caption: { type: "string", required: false } },
124
+ async execute(input, ctx) {
125
+ const p = input;
126
+ const body = { chat_id: p.chatId, document: p.document };
127
+ if (p.caption)
128
+ body.caption = p.caption;
129
+ return apiRequest(getConn(ctx), "POST", "sendDocument", body);
130
+ },
131
+ });
132
+ rl.registerAction("message.sendVideo", {
133
+ description: "Send a video by URL",
134
+ inputSchema: { chatId: { type: "string", required: true }, video: { type: "string", required: true, description: "Video URL or file_id" }, caption: { type: "string", required: false } },
135
+ async execute(input, ctx) {
136
+ const p = input;
137
+ const body = { chat_id: p.chatId, video: p.video };
138
+ if (p.caption)
139
+ body.caption = p.caption;
140
+ return apiRequest(getConn(ctx), "POST", "sendVideo", body);
141
+ },
142
+ });
143
+ rl.registerAction("message.sendSticker", {
144
+ description: "Send a sticker",
145
+ inputSchema: { chatId: { type: "string", required: true }, sticker: { type: "string", required: true, description: "Sticker URL or file_id" } },
146
+ async execute(input, ctx) {
147
+ const p = input;
148
+ return apiRequest(getConn(ctx), "POST", "sendSticker", { chat_id: p.chatId, sticker: p.sticker });
149
+ },
150
+ });
151
+ rl.registerAction("message.sendAnimation", {
152
+ description: "Send a GIF/animation",
153
+ inputSchema: { chatId: { type: "string", required: true }, animation: { type: "string", required: true, description: "Animation URL or file_id" }, caption: { type: "string", required: false } },
154
+ async execute(input, ctx) {
155
+ const p = input;
156
+ const body = { chat_id: p.chatId, animation: p.animation };
157
+ if (p.caption)
158
+ body.caption = p.caption;
159
+ return apiRequest(getConn(ctx), "POST", "sendAnimation", body);
160
+ },
161
+ });
162
+ rl.registerAction("message.sendAudio", {
163
+ description: "Send audio by URL",
164
+ inputSchema: { chatId: { type: "string", required: true }, audio: { type: "string", required: true, description: "Audio URL or file_id" }, caption: { type: "string", required: false } },
165
+ async execute(input, ctx) {
166
+ const p = input;
167
+ const body = { chat_id: p.chatId, audio: p.audio };
168
+ if (p.caption)
169
+ body.caption = p.caption;
170
+ return apiRequest(getConn(ctx), "POST", "sendAudio", body);
171
+ },
172
+ });
173
+ // ── Chat ────────────────────────────────────────────
174
+ rl.registerAction("chat.get", {
175
+ description: "Get chat info",
176
+ inputSchema: { chatId: { type: "string", required: true } },
177
+ async execute(input, ctx) { return apiRequest(getConn(ctx), "POST", "getChat", { chat_id: input.chatId }); },
178
+ });
179
+ rl.registerAction("chat.getAdministrators", {
180
+ description: "Get chat administrators",
181
+ inputSchema: { chatId: { type: "string", required: true } },
182
+ async execute(input, ctx) { return apiRequest(getConn(ctx), "POST", "getChatAdministrators", { chat_id: input.chatId }); },
183
+ });
184
+ rl.registerAction("chat.getMember", {
185
+ description: "Get a chat member",
186
+ inputSchema: { chatId: { type: "string", required: true }, userId: { type: "number", required: true } },
187
+ async execute(input, ctx) {
188
+ const p = input;
189
+ return apiRequest(getConn(ctx), "POST", "getChatMember", { chat_id: p.chatId, user_id: p.userId });
190
+ },
191
+ });
192
+ rl.registerAction("chat.leave", {
193
+ description: "Leave a chat",
194
+ inputSchema: { chatId: { type: "string", required: true } },
195
+ async execute(input, ctx) { return apiRequest(getConn(ctx), "POST", "leaveChat", { chat_id: input.chatId }); },
196
+ });
197
+ rl.registerAction("chat.setDescription", {
198
+ description: "Set chat description",
199
+ inputSchema: { chatId: { type: "string", required: true }, description: { type: "string", required: true } },
200
+ async execute(input, ctx) {
201
+ const p = input;
202
+ return apiRequest(getConn(ctx), "POST", "setChatDescription", { chat_id: p.chatId, description: p.description });
203
+ },
204
+ });
205
+ rl.registerAction("chat.setTitle", {
206
+ description: "Set chat title",
207
+ inputSchema: { chatId: { type: "string", required: true }, title: { type: "string", required: true } },
208
+ async execute(input, ctx) {
209
+ const p = input;
210
+ return apiRequest(getConn(ctx), "POST", "setChatTitle", { chat_id: p.chatId, title: p.title });
211
+ },
212
+ });
213
+ // ── Callback ────────────────────────────────────────
214
+ rl.registerAction("callback.answer", {
215
+ description: "Answer a callback query",
216
+ inputSchema: { callbackQueryId: { type: "string", required: true }, text: { type: "string", required: false }, showAlert: { type: "boolean", required: false } },
217
+ async execute(input, ctx) {
218
+ const p = input;
219
+ const body = { callback_query_id: p.callbackQueryId };
220
+ if (p.text)
221
+ body.text = p.text;
222
+ if (p.showAlert)
223
+ body.show_alert = true;
224
+ return apiRequest(getConn(ctx), "POST", "answerCallbackQuery", body);
225
+ },
226
+ });
227
+ // ── File ────────────────────────────────────────────
228
+ rl.registerAction("file.get", {
229
+ description: "Get file metadata (use result.file_path to download)",
230
+ inputSchema: { fileId: { type: "string", required: true } },
231
+ async execute(input, ctx) { return apiRequest(getConn(ctx), "POST", "getFile", { file_id: input.fileId }); },
232
+ });
233
+ }