patchwork-os 0.2.0-alpha.35 → 0.2.0-alpha.36
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 +70 -15
- package/dist/activityLog.d.ts +49 -0
- package/dist/activityLog.js +78 -0
- package/dist/activityLog.js.map +1 -1
- package/dist/approvalHttp.d.ts +25 -0
- package/dist/approvalHttp.js +74 -18
- package/dist/approvalHttp.js.map +1 -1
- package/dist/approvalInsights.d.ts +49 -0
- package/dist/approvalInsights.js +97 -0
- package/dist/approvalInsights.js.map +1 -0
- package/dist/approvalQueue.d.ts +11 -0
- package/dist/approvalQueue.js +80 -1
- package/dist/approvalQueue.js.map +1 -1
- package/dist/approvalSignals.d.ts +124 -0
- package/dist/approvalSignals.js +512 -0
- package/dist/approvalSignals.js.map +1 -0
- package/dist/automation.d.ts +37 -0
- package/dist/automation.js +105 -61
- package/dist/automation.js.map +1 -1
- package/dist/automationSuggestions.d.ts +79 -0
- package/dist/automationSuggestions.js +150 -0
- package/dist/automationSuggestions.js.map +1 -0
- package/dist/bridge.js +46 -0
- package/dist/bridge.js.map +1 -1
- package/dist/ccPermissions.d.ts +15 -0
- package/dist/ccPermissions.js +15 -0
- package/dist/ccPermissions.js.map +1 -1
- package/dist/claudeDriver.js +74 -16
- package/dist/claudeDriver.js.map +1 -1
- package/dist/commands/patchworkInit.d.ts +8 -0
- package/dist/commands/patchworkInit.js +41 -5
- package/dist/commands/patchworkInit.js.map +1 -1
- package/dist/commands/recipe.d.ts +20 -0
- package/dist/commands/recipe.js +194 -5
- package/dist/commands/recipe.js.map +1 -1
- package/dist/commands/recipeInstall.js +93 -4
- package/dist/commands/recipeInstall.js.map +1 -1
- package/dist/commands/tracesExport.d.ts +83 -0
- package/dist/commands/tracesExport.js +269 -0
- package/dist/commands/tracesExport.js.map +1 -0
- package/dist/commands/tracesImport.d.ts +56 -0
- package/dist/commands/tracesImport.js +161 -0
- package/dist/commands/tracesImport.js.map +1 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.js +9 -1
- package/dist/config.js.map +1 -1
- package/dist/connectorRoutes.d.ts +43 -0
- package/dist/connectorRoutes.js +1023 -0
- package/dist/connectorRoutes.js.map +1 -0
- package/dist/connectors/asana.js +6 -7
- package/dist/connectors/asana.js.map +1 -1
- package/dist/connectors/baseConnector.d.ts +20 -0
- package/dist/connectors/baseConnector.js +45 -4
- package/dist/connectors/baseConnector.js.map +1 -1
- package/dist/connectors/discord.js +6 -7
- package/dist/connectors/discord.js.map +1 -1
- package/dist/connectors/gmail.js +39 -10
- package/dist/connectors/gmail.js.map +1 -1
- package/dist/connectors/googleCalendar.js +36 -10
- package/dist/connectors/googleCalendar.js.map +1 -1
- package/dist/connectors/googleDrive.js +22 -6
- package/dist/connectors/googleDrive.js.map +1 -1
- package/dist/connectors/linear.js +2 -2
- package/dist/connectors/linear.js.map +1 -1
- package/dist/connectors/mcpOAuth.js +26 -2
- package/dist/connectors/mcpOAuth.js.map +1 -1
- package/dist/connectors/oauthStateStore.d.ts +31 -0
- package/dist/connectors/oauthStateStore.js +52 -0
- package/dist/connectors/oauthStateStore.js.map +1 -0
- package/dist/connectors/slack.d.ts +15 -0
- package/dist/connectors/slack.js +54 -4
- package/dist/connectors/slack.js.map +1 -1
- package/dist/connectors/tokenStorage.js +27 -2
- package/dist/connectors/tokenStorage.js.map +1 -1
- package/dist/connectors/zendesk.js +19 -1
- package/dist/connectors/zendesk.js.map +1 -1
- package/dist/cors.d.ts +10 -0
- package/dist/cors.js +29 -0
- package/dist/cors.js.map +1 -0
- package/dist/decisionReplay.d.ts +72 -0
- package/dist/decisionReplay.js +92 -0
- package/dist/decisionReplay.js.map +1 -0
- package/dist/decisionTraceLog.d.ts +6 -0
- package/dist/decisionTraceLog.js +54 -2
- package/dist/decisionTraceLog.js.map +1 -1
- package/dist/fp/automationInterpreter.js +25 -21
- package/dist/fp/automationInterpreter.js.map +1 -1
- package/dist/fp/automationState.js +4 -1
- package/dist/fp/automationState.js.map +1 -1
- package/dist/fp/policyParser.js +4 -1
- package/dist/fp/policyParser.js.map +1 -1
- package/dist/inboxRoutes.d.ts +22 -0
- package/dist/inboxRoutes.js +114 -0
- package/dist/inboxRoutes.js.map +1 -0
- package/dist/index.js +479 -17
- package/dist/index.js.map +1 -1
- package/dist/mcpRoutes.d.ts +37 -0
- package/dist/mcpRoutes.js +76 -0
- package/dist/mcpRoutes.js.map +1 -0
- package/dist/oauth.d.ts +3 -0
- package/dist/oauth.js +151 -26
- package/dist/oauth.js.map +1 -1
- package/dist/oauthRoutes.d.ts +32 -0
- package/dist/oauthRoutes.js +124 -0
- package/dist/oauthRoutes.js.map +1 -0
- package/dist/orchestrator/orchestratorBridge.js +2 -2
- package/dist/orchestrator/orchestratorBridge.js.map +1 -1
- package/dist/patchworkConfig.d.ts +7 -0
- package/dist/patchworkConfig.js.map +1 -1
- package/dist/pluginLoader.d.ts +12 -0
- package/dist/pluginLoader.js +43 -4
- package/dist/pluginLoader.js.map +1 -1
- package/dist/pluginWatcher.js +8 -3
- package/dist/pluginWatcher.js.map +1 -1
- package/dist/preToolUseHook.d.ts +12 -0
- package/dist/preToolUseHook.js +23 -0
- package/dist/preToolUseHook.js.map +1 -1
- package/dist/recipeOrchestration.d.ts +1 -0
- package/dist/recipeOrchestration.js +173 -13
- package/dist/recipeOrchestration.js.map +1 -1
- package/dist/recipeRoutes.d.ts +154 -0
- package/dist/recipeRoutes.js +1098 -0
- package/dist/recipeRoutes.js.map +1 -0
- package/dist/recipes/chainedRunner.d.ts +15 -0
- package/dist/recipes/chainedRunner.js +73 -8
- package/dist/recipes/chainedRunner.js.map +1 -1
- package/dist/recipes/compiler.js +3 -3
- package/dist/recipes/compiler.js.map +1 -1
- package/dist/recipes/installer.js +3 -3
- package/dist/recipes/installer.js.map +1 -1
- package/dist/recipes/migrationWarnings.d.ts +12 -0
- package/dist/recipes/migrationWarnings.js +44 -0
- package/dist/recipes/migrationWarnings.js.map +1 -0
- package/dist/recipes/resolveRecipePath.d.ts +69 -0
- package/dist/recipes/resolveRecipePath.js +202 -0
- package/dist/recipes/resolveRecipePath.js.map +1 -0
- package/dist/recipes/tools/file.d.ts +6 -0
- package/dist/recipes/tools/file.js +12 -8
- package/dist/recipes/tools/file.js.map +1 -1
- package/dist/recipes/tools/index.d.ts +2 -0
- package/dist/recipes/tools/index.js +2 -0
- package/dist/recipes/tools/index.js.map +1 -1
- package/dist/recipes/tools/jira.d.ts +14 -0
- package/dist/recipes/tools/jira.js +369 -0
- package/dist/recipes/tools/jira.js.map +1 -0
- package/dist/recipes/tools/linear.js +6 -3
- package/dist/recipes/tools/linear.js.map +1 -1
- package/dist/recipes/tools/sentry.d.ts +12 -0
- package/dist/recipes/tools/sentry.js +73 -0
- package/dist/recipes/tools/sentry.js.map +1 -0
- package/dist/recipes/tools/slack.js +7 -3
- package/dist/recipes/tools/slack.js.map +1 -1
- package/dist/recipes/validation.js +83 -14
- package/dist/recipes/validation.js.map +1 -1
- package/dist/recipes/yamlRunner.d.ts +7 -0
- package/dist/recipes/yamlRunner.js +107 -13
- package/dist/recipes/yamlRunner.js.map +1 -1
- package/dist/recipesHttp.d.ts +44 -1
- package/dist/recipesHttp.js +168 -15
- package/dist/recipesHttp.js.map +1 -1
- package/dist/runLog.d.ts +14 -0
- package/dist/runLog.js +88 -4
- package/dist/runLog.js.map +1 -1
- package/dist/schemas/dry-run-plan.v1.json +139 -0
- package/dist/schemas/recipe.v1.json +684 -0
- package/dist/server.d.ts +71 -10
- package/dist/server.js +363 -1703
- package/dist/server.js.map +1 -1
- package/dist/ssrfGuard.d.ts +54 -0
- package/dist/ssrfGuard.js +122 -0
- package/dist/ssrfGuard.js.map +1 -0
- package/dist/streamableHttp.d.ts +8 -0
- package/dist/streamableHttp.js +112 -21
- package/dist/streamableHttp.js.map +1 -1
- package/dist/tools/getDocumentSymbols.d.ts +24 -0
- package/dist/tools/getDocumentSymbols.js +74 -8
- package/dist/tools/getDocumentSymbols.js.map +1 -1
- package/dist/tools/getSecurityAdvisories.js +10 -1
- package/dist/tools/getSecurityAdvisories.js.map +1 -1
- package/dist/tools/getSessionUsage.d.ts +3 -0
- package/dist/tools/getSessionUsage.js +3 -0
- package/dist/tools/getSessionUsage.js.map +1 -1
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.js +32 -2
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/transaction.d.ts +19 -0
- package/dist/tools/transaction.js +29 -0
- package/dist/tools/transaction.js.map +1 -1
- package/dist/traceEncryption.d.ts +46 -0
- package/dist/traceEncryption.js +124 -0
- package/dist/traceEncryption.js.map +1 -0
- package/dist/transport.d.ts +39 -0
- package/dist/transport.js +88 -8
- package/dist/transport.js.map +1 -1
- package/package.json +4 -2
- package/templates/policies/README.md +72 -0
- package/templates/policies/conservative.json +14 -0
- package/templates/policies/developer.json +14 -0
- package/templates/policies/headless-ci.json +24 -0
- package/templates/policies/personal-assistant.json +15 -0
- package/templates/policies/regulated-industry.json +18 -0
- package/templates/recipes/webhook/README.md +70 -0
- package/templates/recipes/webhook/capture-thought.yaml +26 -0
- package/templates/recipes/webhook/customer-escalation.yaml +49 -0
- package/templates/recipes/webhook/incident-intake.yaml +46 -0
- package/templates/recipes/webhook/meeting-prep.yaml +48 -0
- package/templates/recipes/webhook/morning-brief.yaml +57 -0
|
@@ -0,0 +1,1023 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connector route dispatcher — extracted from src/server.ts.
|
|
3
|
+
*
|
|
4
|
+
* Owns every `/connections/*` HTTP endpoint (auth start / OAuth callback /
|
|
5
|
+
* test ping / disconnect / connect-with-body) for the 18 supported
|
|
6
|
+
* connectors.
|
|
7
|
+
*
|
|
8
|
+
* Two entrypoints — the split exists because OAuth callbacks must run
|
|
9
|
+
* BEFORE the bearer-auth gate (they're browser redirects from the vendor
|
|
10
|
+
* with no Patchwork token), while CRUD routes must run AFTER it:
|
|
11
|
+
*
|
|
12
|
+
* - `tryHandlePublicConnectorRoute` — `/connections/<vendor>/callback`
|
|
13
|
+
* routes. Server.ts calls this BEFORE bearer-auth.
|
|
14
|
+
* - `tryHandleConnectorRoute` — auth/test/disconnect/connect routes.
|
|
15
|
+
* Server.ts calls this AFTER bearer-auth.
|
|
16
|
+
*
|
|
17
|
+
* Mechanical lift — no behavior change:
|
|
18
|
+
* - Handler bodies are byte-identical to the original blocks save for
|
|
19
|
+
* wrapping a few non-IIFE call sites in `void (async()=>{...})()` so
|
|
20
|
+
* both functions can return boolean synchronously rather than
|
|
21
|
+
* Promise<boolean>. The microtask delay this introduces is invisible
|
|
22
|
+
* to clients — the parent request handler `return`s on a true result
|
|
23
|
+
* either way, and `res.end()` has always been async.
|
|
24
|
+
* - Pre-extraction grep confirmed zero `this.` references in either
|
|
25
|
+
* block, so no dependency injection was needed.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Try to handle a `/connections/<vendor>/callback` route. These are
|
|
29
|
+
* unauthenticated browser redirects from the OAuth vendor and MUST run
|
|
30
|
+
* before the bearer-auth gate. Returns true if the route was dispatched.
|
|
31
|
+
*/
|
|
32
|
+
export function tryHandlePublicConnectorRoute(req, res, parsedUrl) {
|
|
33
|
+
if (parsedUrl.pathname === "/connections/github/callback" &&
|
|
34
|
+
req.method === "GET") {
|
|
35
|
+
void (async () => {
|
|
36
|
+
const { handleGithubCallback } = await import("./connectors/github.js");
|
|
37
|
+
const code = parsedUrl.searchParams.get("code");
|
|
38
|
+
const state = parsedUrl.searchParams.get("state");
|
|
39
|
+
const error = parsedUrl.searchParams.get("error");
|
|
40
|
+
const result = await handleGithubCallback(code, state, error);
|
|
41
|
+
res.writeHead(result.status, {
|
|
42
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
43
|
+
});
|
|
44
|
+
res.end(result.body);
|
|
45
|
+
})();
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
if (parsedUrl.pathname === "/connections/linear/callback" &&
|
|
49
|
+
req.method === "GET") {
|
|
50
|
+
void (async () => {
|
|
51
|
+
const { handleLinearCallback } = await import("./connectors/linear.js");
|
|
52
|
+
const code = parsedUrl.searchParams.get("code");
|
|
53
|
+
const state = parsedUrl.searchParams.get("state");
|
|
54
|
+
const error = parsedUrl.searchParams.get("error");
|
|
55
|
+
const result = await handleLinearCallback(code, state, error);
|
|
56
|
+
res.writeHead(result.status, {
|
|
57
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
58
|
+
});
|
|
59
|
+
res.end(result.body);
|
|
60
|
+
})();
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
if (parsedUrl.pathname === "/connections/sentry/callback" &&
|
|
64
|
+
req.method === "GET") {
|
|
65
|
+
void (async () => {
|
|
66
|
+
const { handleSentryCallback } = await import("./connectors/sentry.js");
|
|
67
|
+
const code = parsedUrl.searchParams.get("code");
|
|
68
|
+
const state = parsedUrl.searchParams.get("state");
|
|
69
|
+
const error = parsedUrl.searchParams.get("error");
|
|
70
|
+
const result = await handleSentryCallback(code, state, error);
|
|
71
|
+
res.writeHead(result.status, {
|
|
72
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
73
|
+
});
|
|
74
|
+
res.end(result.body);
|
|
75
|
+
})();
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
if (parsedUrl.pathname === "/connections/google-calendar/callback" &&
|
|
79
|
+
req.method === "GET") {
|
|
80
|
+
void (async () => {
|
|
81
|
+
const { handleCalendarCallback } = await import("./connectors/googleCalendar.js");
|
|
82
|
+
const code = parsedUrl.searchParams.get("code");
|
|
83
|
+
const state = parsedUrl.searchParams.get("state");
|
|
84
|
+
const error = parsedUrl.searchParams.get("error");
|
|
85
|
+
const result = await handleCalendarCallback(code, state, error);
|
|
86
|
+
res.writeHead(result.status, {
|
|
87
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
88
|
+
});
|
|
89
|
+
res.end(result.body);
|
|
90
|
+
})();
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
if (parsedUrl.pathname === "/connections/google-drive/callback" &&
|
|
94
|
+
req.method === "GET") {
|
|
95
|
+
void (async () => {
|
|
96
|
+
const { handleDriveCallback } = await import("./connectors/googleDrive.js");
|
|
97
|
+
const code = parsedUrl.searchParams.get("code");
|
|
98
|
+
const state = parsedUrl.searchParams.get("state");
|
|
99
|
+
const error = parsedUrl.searchParams.get("error");
|
|
100
|
+
const result = await handleDriveCallback(code, state, error);
|
|
101
|
+
res.writeHead(result.status, {
|
|
102
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
103
|
+
});
|
|
104
|
+
res.end(result.body);
|
|
105
|
+
})();
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
if (parsedUrl.pathname === "/connections/slack/callback" &&
|
|
109
|
+
req.method === "GET") {
|
|
110
|
+
void (async () => {
|
|
111
|
+
const { handleSlackCallback } = await import("./connectors/slack.js");
|
|
112
|
+
const code = parsedUrl.searchParams.get("code");
|
|
113
|
+
const state = parsedUrl.searchParams.get("state");
|
|
114
|
+
const error = parsedUrl.searchParams.get("error");
|
|
115
|
+
const result = await handleSlackCallback(code, state, error);
|
|
116
|
+
res.writeHead(result.status, {
|
|
117
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
118
|
+
});
|
|
119
|
+
res.end(result.body);
|
|
120
|
+
})();
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
if (parsedUrl.pathname === "/connections/gmail/callback" &&
|
|
124
|
+
req.method === "GET") {
|
|
125
|
+
void (async () => {
|
|
126
|
+
const { handleGmailCallback } = await import("./connectors/gmail.js");
|
|
127
|
+
const code = parsedUrl.searchParams.get("code");
|
|
128
|
+
const state = parsedUrl.searchParams.get("state");
|
|
129
|
+
const error = parsedUrl.searchParams.get("error");
|
|
130
|
+
const result = await handleGmailCallback(code, state, error);
|
|
131
|
+
res.writeHead(result.status, {
|
|
132
|
+
"Content-Type": result.contentType ?? "text/html",
|
|
133
|
+
});
|
|
134
|
+
res.end(result.body);
|
|
135
|
+
})();
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Try to handle a `/connections/*` route (auth start / test / disconnect /
|
|
142
|
+
* connect-with-body). Returns true if the route was dispatched (caller
|
|
143
|
+
* should `return` from the request handler), false if no route matched
|
|
144
|
+
* (caller should fall through to other route checks).
|
|
145
|
+
*
|
|
146
|
+
* The actual response is written asynchronously inside an IIFE; this
|
|
147
|
+
* function returns synchronously as soon as the route is recognized.
|
|
148
|
+
*/
|
|
149
|
+
export function tryHandleConnectorRoute(req, res, parsedUrl) {
|
|
150
|
+
// ── Gmail / Connections endpoints ───────────────────────────────────────
|
|
151
|
+
if (parsedUrl.pathname === "/connections" && req.method === "GET") {
|
|
152
|
+
void (async () => {
|
|
153
|
+
const { handleConnectionsList } = await import("./connectors/gmail.js");
|
|
154
|
+
const result = await handleConnectionsList();
|
|
155
|
+
res.writeHead(result.status, {
|
|
156
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
157
|
+
});
|
|
158
|
+
res.end(result.body);
|
|
159
|
+
})();
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
if (parsedUrl.pathname === "/connections/gmail/auth" &&
|
|
163
|
+
req.method === "GET") {
|
|
164
|
+
void (async () => {
|
|
165
|
+
const { handleGmailAuthRedirect } = await import("./connectors/gmail.js");
|
|
166
|
+
const result = handleGmailAuthRedirect();
|
|
167
|
+
if (result.redirect) {
|
|
168
|
+
res.writeHead(302, { Location: result.redirect });
|
|
169
|
+
res.end();
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
res.writeHead(result.status, {
|
|
173
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
174
|
+
});
|
|
175
|
+
res.end(result.body);
|
|
176
|
+
}
|
|
177
|
+
})();
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
if (parsedUrl.pathname === "/connections/gmail" && req.method === "DELETE") {
|
|
181
|
+
void (async () => {
|
|
182
|
+
const { handleGmailDisconnect } = await import("./connectors/gmail.js");
|
|
183
|
+
const result = await handleGmailDisconnect();
|
|
184
|
+
res.writeHead(result.status, {
|
|
185
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
186
|
+
});
|
|
187
|
+
res.end(result.body);
|
|
188
|
+
})();
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
if (parsedUrl.pathname === "/connections/gmail/test" &&
|
|
192
|
+
req.method === "POST") {
|
|
193
|
+
void (async () => {
|
|
194
|
+
const { handleGmailTest } = await import("./connectors/gmail.js");
|
|
195
|
+
const result = await handleGmailTest();
|
|
196
|
+
res.writeHead(result.status, {
|
|
197
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
198
|
+
});
|
|
199
|
+
res.end(result.body);
|
|
200
|
+
})();
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
// ── GitHub MCP connector routes ─────────────────────────────────────
|
|
204
|
+
if (parsedUrl.pathname === "/connections/github/auth" &&
|
|
205
|
+
req.method === "GET") {
|
|
206
|
+
void (async () => {
|
|
207
|
+
const { handleGithubAuthorize } = await import("./connectors/github.js");
|
|
208
|
+
const result = await handleGithubAuthorize();
|
|
209
|
+
if (result.redirect) {
|
|
210
|
+
res.writeHead(302, { Location: result.redirect });
|
|
211
|
+
res.end();
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
res.writeHead(result.status, {
|
|
215
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
216
|
+
});
|
|
217
|
+
res.end(result.body);
|
|
218
|
+
}
|
|
219
|
+
})();
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
if (parsedUrl.pathname === "/connections/github/test" &&
|
|
223
|
+
req.method === "POST") {
|
|
224
|
+
void (async () => {
|
|
225
|
+
const { handleGithubTest } = await import("./connectors/github.js");
|
|
226
|
+
const result = await handleGithubTest();
|
|
227
|
+
res.writeHead(result.status, {
|
|
228
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
229
|
+
});
|
|
230
|
+
res.end(result.body);
|
|
231
|
+
})();
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
if (parsedUrl.pathname === "/connections/github" && req.method === "DELETE") {
|
|
235
|
+
void (async () => {
|
|
236
|
+
const { handleGithubDisconnect } = await import("./connectors/github.js");
|
|
237
|
+
const result = await handleGithubDisconnect();
|
|
238
|
+
res.writeHead(result.status, {
|
|
239
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
240
|
+
});
|
|
241
|
+
res.end(result.body);
|
|
242
|
+
})();
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
// ── Sentry MCP connector routes ─────────────────────────────────────
|
|
246
|
+
if (parsedUrl.pathname === "/connections/sentry/auth" &&
|
|
247
|
+
req.method === "GET") {
|
|
248
|
+
void (async () => {
|
|
249
|
+
const { handleSentryAuthorize } = await import("./connectors/sentry.js");
|
|
250
|
+
const result = await handleSentryAuthorize();
|
|
251
|
+
if (result.redirect) {
|
|
252
|
+
res.writeHead(302, { Location: result.redirect });
|
|
253
|
+
res.end();
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
res.writeHead(result.status, {
|
|
257
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
258
|
+
});
|
|
259
|
+
res.end(result.body);
|
|
260
|
+
}
|
|
261
|
+
})();
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
if (parsedUrl.pathname === "/connections/sentry/callback" &&
|
|
265
|
+
req.method === "GET") {
|
|
266
|
+
void (async () => {
|
|
267
|
+
const { handleSentryCallback } = await import("./connectors/sentry.js");
|
|
268
|
+
const code = parsedUrl.searchParams.get("code");
|
|
269
|
+
const state = parsedUrl.searchParams.get("state");
|
|
270
|
+
const error = parsedUrl.searchParams.get("error");
|
|
271
|
+
const result = await handleSentryCallback(code, state, error);
|
|
272
|
+
res.writeHead(result.status, {
|
|
273
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
274
|
+
});
|
|
275
|
+
res.end(result.body);
|
|
276
|
+
})();
|
|
277
|
+
return true;
|
|
278
|
+
}
|
|
279
|
+
if (parsedUrl.pathname === "/connections/sentry/test" &&
|
|
280
|
+
req.method === "POST") {
|
|
281
|
+
void (async () => {
|
|
282
|
+
const { handleSentryTest } = await import("./connectors/sentry.js");
|
|
283
|
+
const result = await handleSentryTest();
|
|
284
|
+
res.writeHead(result.status, {
|
|
285
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
286
|
+
});
|
|
287
|
+
res.end(result.body);
|
|
288
|
+
})();
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
if (parsedUrl.pathname === "/connections/sentry" && req.method === "DELETE") {
|
|
292
|
+
void (async () => {
|
|
293
|
+
const { handleSentryDisconnect } = await import("./connectors/sentry.js");
|
|
294
|
+
const result = await handleSentryDisconnect();
|
|
295
|
+
res.writeHead(result.status, {
|
|
296
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
297
|
+
});
|
|
298
|
+
res.end(result.body);
|
|
299
|
+
})();
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
// ── Linear MCP connector routes ─────────────────────────────────────
|
|
303
|
+
if (parsedUrl.pathname === "/connections/linear/auth" &&
|
|
304
|
+
req.method === "GET") {
|
|
305
|
+
void (async () => {
|
|
306
|
+
const { handleLinearAuthorize } = await import("./connectors/linear.js");
|
|
307
|
+
const result = await handleLinearAuthorize();
|
|
308
|
+
if (result.redirect) {
|
|
309
|
+
res.writeHead(302, { Location: result.redirect });
|
|
310
|
+
res.end();
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
res.writeHead(result.status, {
|
|
314
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
315
|
+
});
|
|
316
|
+
res.end(result.body);
|
|
317
|
+
}
|
|
318
|
+
})();
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
if (parsedUrl.pathname === "/connections/linear/callback" &&
|
|
322
|
+
req.method === "GET") {
|
|
323
|
+
void (async () => {
|
|
324
|
+
const { handleLinearCallback } = await import("./connectors/linear.js");
|
|
325
|
+
const code = parsedUrl.searchParams.get("code");
|
|
326
|
+
const state = parsedUrl.searchParams.get("state");
|
|
327
|
+
const error = parsedUrl.searchParams.get("error");
|
|
328
|
+
const result = await handleLinearCallback(code, state, error);
|
|
329
|
+
res.writeHead(result.status, {
|
|
330
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
331
|
+
});
|
|
332
|
+
res.end(result.body);
|
|
333
|
+
})();
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
if (parsedUrl.pathname === "/connections/linear/test" &&
|
|
337
|
+
req.method === "POST") {
|
|
338
|
+
void (async () => {
|
|
339
|
+
const { handleLinearTest } = await import("./connectors/linear.js");
|
|
340
|
+
const result = await handleLinearTest();
|
|
341
|
+
res.writeHead(result.status, {
|
|
342
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
343
|
+
});
|
|
344
|
+
res.end(result.body);
|
|
345
|
+
})();
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
if (parsedUrl.pathname === "/connections/linear" && req.method === "DELETE") {
|
|
349
|
+
void (async () => {
|
|
350
|
+
const { handleLinearDisconnect } = await import("./connectors/linear.js");
|
|
351
|
+
const result = await handleLinearDisconnect();
|
|
352
|
+
res.writeHead(result.status, {
|
|
353
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
354
|
+
});
|
|
355
|
+
res.end(result.body);
|
|
356
|
+
})();
|
|
357
|
+
return true;
|
|
358
|
+
}
|
|
359
|
+
// ── Slack connector routes ──────────────────────────────────────
|
|
360
|
+
if ((parsedUrl.pathname === "/connections/slack/auth" ||
|
|
361
|
+
parsedUrl.pathname === "/connections/slack/authorize") &&
|
|
362
|
+
req.method === "GET") {
|
|
363
|
+
void (async () => {
|
|
364
|
+
const { handleSlackAuthorize } = await import("./connectors/slack.js");
|
|
365
|
+
const result = handleSlackAuthorize();
|
|
366
|
+
if (result.redirect) {
|
|
367
|
+
res.writeHead(302, { Location: result.redirect });
|
|
368
|
+
res.end();
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
res.writeHead(result.status, {
|
|
372
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
373
|
+
});
|
|
374
|
+
res.end(result.body);
|
|
375
|
+
}
|
|
376
|
+
})();
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
if (parsedUrl.pathname === "/connections/slack/test" &&
|
|
380
|
+
req.method === "POST") {
|
|
381
|
+
void (async () => {
|
|
382
|
+
const { handleSlackTest } = await import("./connectors/slack.js");
|
|
383
|
+
const result = await handleSlackTest();
|
|
384
|
+
res.writeHead(result.status, {
|
|
385
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
386
|
+
});
|
|
387
|
+
res.end(result.body);
|
|
388
|
+
})();
|
|
389
|
+
return true;
|
|
390
|
+
}
|
|
391
|
+
if (parsedUrl.pathname === "/connections/slack" && req.method === "DELETE") {
|
|
392
|
+
void (async () => {
|
|
393
|
+
const { handleSlackDisconnect } = await import("./connectors/slack.js");
|
|
394
|
+
const result = handleSlackDisconnect();
|
|
395
|
+
res.writeHead(result.status, {
|
|
396
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
397
|
+
});
|
|
398
|
+
res.end(result.body);
|
|
399
|
+
})();
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
// ── Discord connector routes ───────────────────────────────────
|
|
403
|
+
if ((parsedUrl.pathname === "/connections/discord/auth" ||
|
|
404
|
+
parsedUrl.pathname === "/connections/discord/authorize") &&
|
|
405
|
+
req.method === "GET") {
|
|
406
|
+
void (async () => {
|
|
407
|
+
const { handleDiscordAuthorize } = await import("./connectors/discord.js");
|
|
408
|
+
const result = handleDiscordAuthorize();
|
|
409
|
+
if (result.redirect) {
|
|
410
|
+
res.writeHead(302, { Location: result.redirect });
|
|
411
|
+
res.end();
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
res.writeHead(result.status, {
|
|
415
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
416
|
+
});
|
|
417
|
+
res.end(result.body);
|
|
418
|
+
}
|
|
419
|
+
})();
|
|
420
|
+
return true;
|
|
421
|
+
}
|
|
422
|
+
if (parsedUrl.pathname === "/connections/discord/callback" &&
|
|
423
|
+
req.method === "GET") {
|
|
424
|
+
void (async () => {
|
|
425
|
+
const { handleDiscordCallback } = await import("./connectors/discord.js");
|
|
426
|
+
const code = parsedUrl.searchParams.get("code");
|
|
427
|
+
const state = parsedUrl.searchParams.get("state");
|
|
428
|
+
const error = parsedUrl.searchParams.get("error");
|
|
429
|
+
const result = await handleDiscordCallback(code, state, error);
|
|
430
|
+
res.writeHead(result.status, {
|
|
431
|
+
"Content-Type": result.contentType ?? "text/html",
|
|
432
|
+
});
|
|
433
|
+
res.end(result.body);
|
|
434
|
+
})();
|
|
435
|
+
return true;
|
|
436
|
+
}
|
|
437
|
+
if (parsedUrl.pathname === "/connections/discord/test" &&
|
|
438
|
+
req.method === "POST") {
|
|
439
|
+
void (async () => {
|
|
440
|
+
const { handleDiscordTest } = await import("./connectors/discord.js");
|
|
441
|
+
const result = await handleDiscordTest();
|
|
442
|
+
res.writeHead(result.status, {
|
|
443
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
444
|
+
});
|
|
445
|
+
res.end(result.body);
|
|
446
|
+
})();
|
|
447
|
+
return true;
|
|
448
|
+
}
|
|
449
|
+
if (parsedUrl.pathname === "/connections/discord" &&
|
|
450
|
+
req.method === "DELETE") {
|
|
451
|
+
void (async () => {
|
|
452
|
+
const { handleDiscordDisconnect } = await import("./connectors/discord.js");
|
|
453
|
+
const result = await handleDiscordDisconnect();
|
|
454
|
+
res.writeHead(result.status, {
|
|
455
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
456
|
+
});
|
|
457
|
+
res.end(result.body);
|
|
458
|
+
})();
|
|
459
|
+
return true;
|
|
460
|
+
}
|
|
461
|
+
// ── Asana connector routes ─────────────────────────────────────
|
|
462
|
+
if ((parsedUrl.pathname === "/connections/asana/auth" ||
|
|
463
|
+
parsedUrl.pathname === "/connections/asana/authorize") &&
|
|
464
|
+
req.method === "GET") {
|
|
465
|
+
void (async () => {
|
|
466
|
+
const { handleAsanaAuthorize } = await import("./connectors/asana.js");
|
|
467
|
+
const result = handleAsanaAuthorize();
|
|
468
|
+
if (result.redirect) {
|
|
469
|
+
res.writeHead(302, { Location: result.redirect });
|
|
470
|
+
res.end();
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
res.writeHead(result.status, {
|
|
474
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
475
|
+
});
|
|
476
|
+
res.end(result.body);
|
|
477
|
+
}
|
|
478
|
+
})();
|
|
479
|
+
return true;
|
|
480
|
+
}
|
|
481
|
+
if (parsedUrl.pathname === "/connections/asana/callback" &&
|
|
482
|
+
req.method === "GET") {
|
|
483
|
+
void (async () => {
|
|
484
|
+
const { handleAsanaCallback } = await import("./connectors/asana.js");
|
|
485
|
+
const code = parsedUrl.searchParams.get("code");
|
|
486
|
+
const state = parsedUrl.searchParams.get("state");
|
|
487
|
+
const error = parsedUrl.searchParams.get("error");
|
|
488
|
+
const result = await handleAsanaCallback(code, state, error);
|
|
489
|
+
res.writeHead(result.status, {
|
|
490
|
+
"Content-Type": result.contentType ?? "text/html",
|
|
491
|
+
});
|
|
492
|
+
res.end(result.body);
|
|
493
|
+
})();
|
|
494
|
+
return true;
|
|
495
|
+
}
|
|
496
|
+
if (parsedUrl.pathname === "/connections/asana/test" &&
|
|
497
|
+
req.method === "POST") {
|
|
498
|
+
void (async () => {
|
|
499
|
+
const { handleAsanaTest } = await import("./connectors/asana.js");
|
|
500
|
+
const result = await handleAsanaTest();
|
|
501
|
+
res.writeHead(result.status, {
|
|
502
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
503
|
+
});
|
|
504
|
+
res.end(result.body);
|
|
505
|
+
})();
|
|
506
|
+
return true;
|
|
507
|
+
}
|
|
508
|
+
if (parsedUrl.pathname === "/connections/asana" && req.method === "DELETE") {
|
|
509
|
+
void (async () => {
|
|
510
|
+
const { handleAsanaDisconnect } = await import("./connectors/asana.js");
|
|
511
|
+
const result = await handleAsanaDisconnect();
|
|
512
|
+
res.writeHead(result.status, {
|
|
513
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
514
|
+
});
|
|
515
|
+
res.end(result.body);
|
|
516
|
+
})();
|
|
517
|
+
return true;
|
|
518
|
+
}
|
|
519
|
+
// ── GitLab connector routes ────────────────────────────────────
|
|
520
|
+
if ((parsedUrl.pathname === "/connections/gitlab/auth" ||
|
|
521
|
+
parsedUrl.pathname === "/connections/gitlab/authorize") &&
|
|
522
|
+
req.method === "GET") {
|
|
523
|
+
void (async () => {
|
|
524
|
+
const { handleGitLabAuthorize } = await import("./connectors/gitlab.js");
|
|
525
|
+
const result = handleGitLabAuthorize();
|
|
526
|
+
if (result.redirect) {
|
|
527
|
+
res.writeHead(302, { Location: result.redirect });
|
|
528
|
+
res.end();
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
res.writeHead(result.status, {
|
|
532
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
533
|
+
});
|
|
534
|
+
res.end(result.body);
|
|
535
|
+
}
|
|
536
|
+
})();
|
|
537
|
+
return true;
|
|
538
|
+
}
|
|
539
|
+
if (parsedUrl.pathname === "/connections/gitlab/callback" &&
|
|
540
|
+
req.method === "GET") {
|
|
541
|
+
void (async () => {
|
|
542
|
+
const { handleGitLabCallback } = await import("./connectors/gitlab.js");
|
|
543
|
+
const code = parsedUrl.searchParams.get("code");
|
|
544
|
+
const state = parsedUrl.searchParams.get("state");
|
|
545
|
+
const error = parsedUrl.searchParams.get("error");
|
|
546
|
+
const result = await handleGitLabCallback(code, state, error);
|
|
547
|
+
res.writeHead(result.status, {
|
|
548
|
+
"Content-Type": result.contentType ?? "text/html",
|
|
549
|
+
});
|
|
550
|
+
res.end(result.body);
|
|
551
|
+
})();
|
|
552
|
+
return true;
|
|
553
|
+
}
|
|
554
|
+
if (parsedUrl.pathname === "/connections/gitlab/test" &&
|
|
555
|
+
req.method === "POST") {
|
|
556
|
+
void (async () => {
|
|
557
|
+
const { handleGitLabTest } = await import("./connectors/gitlab.js");
|
|
558
|
+
const result = await handleGitLabTest();
|
|
559
|
+
res.writeHead(result.status, {
|
|
560
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
561
|
+
});
|
|
562
|
+
res.end(result.body);
|
|
563
|
+
})();
|
|
564
|
+
return true;
|
|
565
|
+
}
|
|
566
|
+
if (parsedUrl.pathname === "/connections/gitlab" && req.method === "DELETE") {
|
|
567
|
+
void (async () => {
|
|
568
|
+
const { handleGitLabDisconnect } = await import("./connectors/gitlab.js");
|
|
569
|
+
const result = await handleGitLabDisconnect();
|
|
570
|
+
res.writeHead(result.status, {
|
|
571
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
572
|
+
});
|
|
573
|
+
res.end(result.body);
|
|
574
|
+
})();
|
|
575
|
+
return true;
|
|
576
|
+
}
|
|
577
|
+
// ── Notion routes ──────────────────────────────────────────────
|
|
578
|
+
if (parsedUrl.pathname === "/connections/notion/connect" &&
|
|
579
|
+
req.method === "POST") {
|
|
580
|
+
const chunks = [];
|
|
581
|
+
req.on("data", (c) => chunks.push(c));
|
|
582
|
+
req.on("end", () => {
|
|
583
|
+
void (async () => {
|
|
584
|
+
const { handleNotionConnect } = await import("./connectors/notion.js");
|
|
585
|
+
const result = await handleNotionConnect(Buffer.concat(chunks).toString("utf-8"));
|
|
586
|
+
res.writeHead(result.status, {
|
|
587
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
588
|
+
});
|
|
589
|
+
res.end(result.body);
|
|
590
|
+
})();
|
|
591
|
+
});
|
|
592
|
+
return true;
|
|
593
|
+
}
|
|
594
|
+
if (parsedUrl.pathname === "/connections/notion/test" &&
|
|
595
|
+
req.method === "POST") {
|
|
596
|
+
void (async () => {
|
|
597
|
+
const { handleNotionTest } = await import("./connectors/notion.js");
|
|
598
|
+
const result = await handleNotionTest();
|
|
599
|
+
res.writeHead(result.status, {
|
|
600
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
601
|
+
});
|
|
602
|
+
res.end(result.body);
|
|
603
|
+
})();
|
|
604
|
+
return true;
|
|
605
|
+
}
|
|
606
|
+
if (parsedUrl.pathname === "/connections/notion" && req.method === "DELETE") {
|
|
607
|
+
void (async () => {
|
|
608
|
+
const { handleNotionDisconnect } = await import("./connectors/notion.js");
|
|
609
|
+
const result = handleNotionDisconnect();
|
|
610
|
+
res.writeHead(result.status, {
|
|
611
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
612
|
+
});
|
|
613
|
+
res.end(result.body);
|
|
614
|
+
})();
|
|
615
|
+
return true;
|
|
616
|
+
}
|
|
617
|
+
// ── Confluence routes ───────────────────────────────────────────
|
|
618
|
+
if (parsedUrl.pathname === "/connections/confluence/connect" &&
|
|
619
|
+
req.method === "POST") {
|
|
620
|
+
const chunks = [];
|
|
621
|
+
req.on("data", (c) => chunks.push(c));
|
|
622
|
+
req.on("end", () => {
|
|
623
|
+
void (async () => {
|
|
624
|
+
const { handleConfluenceConnect } = await import("./connectors/confluence.js");
|
|
625
|
+
const result = await handleConfluenceConnect(Buffer.concat(chunks).toString("utf-8"));
|
|
626
|
+
res.writeHead(result.status, {
|
|
627
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
628
|
+
});
|
|
629
|
+
res.end(result.body);
|
|
630
|
+
})();
|
|
631
|
+
});
|
|
632
|
+
return true;
|
|
633
|
+
}
|
|
634
|
+
if (parsedUrl.pathname === "/connections/confluence/test" &&
|
|
635
|
+
req.method === "POST") {
|
|
636
|
+
void (async () => {
|
|
637
|
+
const { handleConfluenceTest } = await import("./connectors/confluence.js");
|
|
638
|
+
const result = await handleConfluenceTest();
|
|
639
|
+
res.writeHead(result.status, {
|
|
640
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
641
|
+
});
|
|
642
|
+
res.end(result.body);
|
|
643
|
+
})();
|
|
644
|
+
return true;
|
|
645
|
+
}
|
|
646
|
+
if (parsedUrl.pathname === "/connections/confluence" &&
|
|
647
|
+
req.method === "DELETE") {
|
|
648
|
+
void (async () => {
|
|
649
|
+
const { handleConfluenceDisconnect } = await import("./connectors/confluence.js");
|
|
650
|
+
const result = handleConfluenceDisconnect();
|
|
651
|
+
res.writeHead(result.status, {
|
|
652
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
653
|
+
});
|
|
654
|
+
res.end(result.body);
|
|
655
|
+
})();
|
|
656
|
+
return true;
|
|
657
|
+
}
|
|
658
|
+
// ── Zendesk routes ──────────────────────────────────────────────
|
|
659
|
+
if (parsedUrl.pathname === "/connections/zendesk/connect" &&
|
|
660
|
+
req.method === "POST") {
|
|
661
|
+
const chunks = [];
|
|
662
|
+
req.on("data", (c) => chunks.push(c));
|
|
663
|
+
req.on("end", () => {
|
|
664
|
+
void (async () => {
|
|
665
|
+
const { handleZendeskConnect } = await import("./connectors/zendesk.js");
|
|
666
|
+
const result = await handleZendeskConnect(Buffer.concat(chunks).toString("utf-8"));
|
|
667
|
+
res.writeHead(result.status, {
|
|
668
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
669
|
+
});
|
|
670
|
+
res.end(result.body);
|
|
671
|
+
})();
|
|
672
|
+
});
|
|
673
|
+
return true;
|
|
674
|
+
}
|
|
675
|
+
if (parsedUrl.pathname === "/connections/zendesk/test" &&
|
|
676
|
+
req.method === "POST") {
|
|
677
|
+
void (async () => {
|
|
678
|
+
const { handleZendeskTest } = await import("./connectors/zendesk.js");
|
|
679
|
+
const result = await handleZendeskTest();
|
|
680
|
+
res.writeHead(result.status, {
|
|
681
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
682
|
+
});
|
|
683
|
+
res.end(result.body);
|
|
684
|
+
})();
|
|
685
|
+
return true;
|
|
686
|
+
}
|
|
687
|
+
if (parsedUrl.pathname === "/connections/zendesk" &&
|
|
688
|
+
req.method === "DELETE") {
|
|
689
|
+
void (async () => {
|
|
690
|
+
const { handleZendeskDisconnect } = await import("./connectors/zendesk.js");
|
|
691
|
+
const result = handleZendeskDisconnect();
|
|
692
|
+
res.writeHead(result.status, {
|
|
693
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
694
|
+
});
|
|
695
|
+
res.end(result.body);
|
|
696
|
+
})();
|
|
697
|
+
return true;
|
|
698
|
+
}
|
|
699
|
+
// ── Intercom routes ─────────────────────────────────────────────
|
|
700
|
+
if (parsedUrl.pathname === "/connections/intercom/connect" &&
|
|
701
|
+
req.method === "POST") {
|
|
702
|
+
const chunks = [];
|
|
703
|
+
req.on("data", (c) => chunks.push(c));
|
|
704
|
+
req.on("end", () => {
|
|
705
|
+
void (async () => {
|
|
706
|
+
const { handleIntercomConnect } = await import("./connectors/intercom.js");
|
|
707
|
+
const result = await handleIntercomConnect(Buffer.concat(chunks).toString("utf-8"));
|
|
708
|
+
res.writeHead(result.status, {
|
|
709
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
710
|
+
});
|
|
711
|
+
res.end(result.body);
|
|
712
|
+
})();
|
|
713
|
+
});
|
|
714
|
+
return true;
|
|
715
|
+
}
|
|
716
|
+
if (parsedUrl.pathname === "/connections/intercom/test" &&
|
|
717
|
+
req.method === "POST") {
|
|
718
|
+
void (async () => {
|
|
719
|
+
const { handleIntercomTest } = await import("./connectors/intercom.js");
|
|
720
|
+
const result = await handleIntercomTest();
|
|
721
|
+
res.writeHead(result.status, {
|
|
722
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
723
|
+
});
|
|
724
|
+
res.end(result.body);
|
|
725
|
+
})();
|
|
726
|
+
return true;
|
|
727
|
+
}
|
|
728
|
+
if (parsedUrl.pathname === "/connections/intercom" &&
|
|
729
|
+
req.method === "DELETE") {
|
|
730
|
+
void (async () => {
|
|
731
|
+
const { handleIntercomDisconnect } = await import("./connectors/intercom.js");
|
|
732
|
+
const result = handleIntercomDisconnect();
|
|
733
|
+
res.writeHead(result.status, {
|
|
734
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
735
|
+
});
|
|
736
|
+
res.end(result.body);
|
|
737
|
+
})();
|
|
738
|
+
return true;
|
|
739
|
+
}
|
|
740
|
+
// ── HubSpot routes ─────────────────────────────────────────────
|
|
741
|
+
if (parsedUrl.pathname === "/connections/hubspot/connect" &&
|
|
742
|
+
req.method === "POST") {
|
|
743
|
+
const chunks = [];
|
|
744
|
+
req.on("data", (c) => chunks.push(c));
|
|
745
|
+
req.on("end", () => {
|
|
746
|
+
void (async () => {
|
|
747
|
+
const { handleHubSpotConnect } = await import("./connectors/hubspot.js");
|
|
748
|
+
const result = await handleHubSpotConnect(Buffer.concat(chunks).toString("utf-8"));
|
|
749
|
+
res.writeHead(result.status, {
|
|
750
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
751
|
+
});
|
|
752
|
+
res.end(result.body);
|
|
753
|
+
})();
|
|
754
|
+
});
|
|
755
|
+
return true;
|
|
756
|
+
}
|
|
757
|
+
if (parsedUrl.pathname === "/connections/hubspot/test" &&
|
|
758
|
+
req.method === "POST") {
|
|
759
|
+
void (async () => {
|
|
760
|
+
const { handleHubSpotTest } = await import("./connectors/hubspot.js");
|
|
761
|
+
const result = await handleHubSpotTest();
|
|
762
|
+
res.writeHead(result.status, {
|
|
763
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
764
|
+
});
|
|
765
|
+
res.end(result.body);
|
|
766
|
+
})();
|
|
767
|
+
return true;
|
|
768
|
+
}
|
|
769
|
+
if (parsedUrl.pathname === "/connections/hubspot" &&
|
|
770
|
+
req.method === "DELETE") {
|
|
771
|
+
void (async () => {
|
|
772
|
+
const { handleHubSpotDisconnect } = await import("./connectors/hubspot.js");
|
|
773
|
+
const result = handleHubSpotDisconnect();
|
|
774
|
+
res.writeHead(result.status, {
|
|
775
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
776
|
+
});
|
|
777
|
+
res.end(result.body);
|
|
778
|
+
})();
|
|
779
|
+
return true;
|
|
780
|
+
}
|
|
781
|
+
// ── Datadog routes ─────────────────────────────────────────────
|
|
782
|
+
if (parsedUrl.pathname === "/connections/datadog/connect" &&
|
|
783
|
+
req.method === "POST") {
|
|
784
|
+
const chunks = [];
|
|
785
|
+
req.on("data", (c) => chunks.push(c));
|
|
786
|
+
req.on("end", () => {
|
|
787
|
+
void (async () => {
|
|
788
|
+
const { handleDatadogConnect } = await import("./connectors/datadog.js");
|
|
789
|
+
const result = await handleDatadogConnect(Buffer.concat(chunks).toString("utf-8"));
|
|
790
|
+
res.writeHead(result.status, {
|
|
791
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
792
|
+
});
|
|
793
|
+
res.end(result.body);
|
|
794
|
+
})();
|
|
795
|
+
});
|
|
796
|
+
return true;
|
|
797
|
+
}
|
|
798
|
+
if (parsedUrl.pathname === "/connections/datadog/test" &&
|
|
799
|
+
req.method === "POST") {
|
|
800
|
+
void (async () => {
|
|
801
|
+
const { handleDatadogTest } = await import("./connectors/datadog.js");
|
|
802
|
+
const result = await handleDatadogTest();
|
|
803
|
+
res.writeHead(result.status, {
|
|
804
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
805
|
+
});
|
|
806
|
+
res.end(result.body);
|
|
807
|
+
})();
|
|
808
|
+
return true;
|
|
809
|
+
}
|
|
810
|
+
if (parsedUrl.pathname === "/connections/datadog" &&
|
|
811
|
+
req.method === "DELETE") {
|
|
812
|
+
void (async () => {
|
|
813
|
+
const { handleDatadogDisconnect } = await import("./connectors/datadog.js");
|
|
814
|
+
const result = handleDatadogDisconnect();
|
|
815
|
+
res.writeHead(result.status, {
|
|
816
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
817
|
+
});
|
|
818
|
+
res.end(result.body);
|
|
819
|
+
})();
|
|
820
|
+
return true;
|
|
821
|
+
}
|
|
822
|
+
// ── PagerDuty routes ───────────────────────────────────────────
|
|
823
|
+
if (parsedUrl.pathname === "/connections/pagerduty/connect" &&
|
|
824
|
+
req.method === "POST") {
|
|
825
|
+
const chunks = [];
|
|
826
|
+
req.on("data", (c) => chunks.push(c));
|
|
827
|
+
req.on("end", () => {
|
|
828
|
+
void (async () => {
|
|
829
|
+
const { handlePagerDutyConnect } = await import("./connectors/pagerduty.js");
|
|
830
|
+
const result = await handlePagerDutyConnect(Buffer.concat(chunks).toString("utf-8"));
|
|
831
|
+
res.writeHead(result.status, {
|
|
832
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
833
|
+
});
|
|
834
|
+
res.end(result.body);
|
|
835
|
+
})();
|
|
836
|
+
});
|
|
837
|
+
return true;
|
|
838
|
+
}
|
|
839
|
+
if (parsedUrl.pathname === "/connections/pagerduty/test" &&
|
|
840
|
+
req.method === "POST") {
|
|
841
|
+
void (async () => {
|
|
842
|
+
const { handlePagerDutyTest } = await import("./connectors/pagerduty.js");
|
|
843
|
+
const result = await handlePagerDutyTest();
|
|
844
|
+
res.writeHead(result.status, {
|
|
845
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
846
|
+
});
|
|
847
|
+
res.end(result.body);
|
|
848
|
+
})();
|
|
849
|
+
return true;
|
|
850
|
+
}
|
|
851
|
+
if (parsedUrl.pathname === "/connections/pagerduty" &&
|
|
852
|
+
req.method === "DELETE") {
|
|
853
|
+
void (async () => {
|
|
854
|
+
const { handlePagerDutyDisconnect } = await import("./connectors/pagerduty.js");
|
|
855
|
+
const result = handlePagerDutyDisconnect();
|
|
856
|
+
res.writeHead(result.status, {
|
|
857
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
858
|
+
});
|
|
859
|
+
res.end(result.body);
|
|
860
|
+
})();
|
|
861
|
+
return true;
|
|
862
|
+
}
|
|
863
|
+
// ── Stripe routes ───────────────────────────────────────────────
|
|
864
|
+
if (parsedUrl.pathname === "/connections/stripe/connect" &&
|
|
865
|
+
req.method === "POST") {
|
|
866
|
+
let body = "";
|
|
867
|
+
req.on("data", (chunk) => {
|
|
868
|
+
body += chunk.toString();
|
|
869
|
+
});
|
|
870
|
+
req.on("end", () => {
|
|
871
|
+
void (async () => {
|
|
872
|
+
const { handleStripeConnect } = await import("./connectors/stripe.js");
|
|
873
|
+
const result = await handleStripeConnect(body);
|
|
874
|
+
res.writeHead(result.status, {
|
|
875
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
876
|
+
});
|
|
877
|
+
res.end(result.body);
|
|
878
|
+
})();
|
|
879
|
+
});
|
|
880
|
+
return true;
|
|
881
|
+
}
|
|
882
|
+
if (parsedUrl.pathname === "/connections/stripe/test" &&
|
|
883
|
+
req.method === "POST") {
|
|
884
|
+
void (async () => {
|
|
885
|
+
const { handleStripeTest } = await import("./connectors/stripe.js");
|
|
886
|
+
const result = await handleStripeTest();
|
|
887
|
+
res.writeHead(result.status, {
|
|
888
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
889
|
+
});
|
|
890
|
+
res.end(result.body);
|
|
891
|
+
})();
|
|
892
|
+
return true;
|
|
893
|
+
}
|
|
894
|
+
if (parsedUrl.pathname === "/connections/stripe" && req.method === "DELETE") {
|
|
895
|
+
void (async () => {
|
|
896
|
+
const { handleStripeDisconnect } = await import("./connectors/stripe.js");
|
|
897
|
+
const result = handleStripeDisconnect();
|
|
898
|
+
res.writeHead(result.status, {
|
|
899
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
900
|
+
});
|
|
901
|
+
res.end(result.body);
|
|
902
|
+
})();
|
|
903
|
+
return true;
|
|
904
|
+
}
|
|
905
|
+
// ── Google Calendar routes ──────────────────────────────────────
|
|
906
|
+
if (parsedUrl.pathname === "/connections/google-calendar/auth" &&
|
|
907
|
+
req.method === "GET") {
|
|
908
|
+
void (async () => {
|
|
909
|
+
const { handleCalendarAuthRedirect } = await import("./connectors/googleCalendar.js");
|
|
910
|
+
const result = handleCalendarAuthRedirect();
|
|
911
|
+
if (result.redirect) {
|
|
912
|
+
res.writeHead(302, { Location: result.redirect });
|
|
913
|
+
res.end();
|
|
914
|
+
}
|
|
915
|
+
else {
|
|
916
|
+
res.writeHead(result.status, {
|
|
917
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
918
|
+
});
|
|
919
|
+
res.end(result.body);
|
|
920
|
+
}
|
|
921
|
+
})();
|
|
922
|
+
return true;
|
|
923
|
+
}
|
|
924
|
+
if (parsedUrl.pathname === "/connections/google-calendar/callback" &&
|
|
925
|
+
req.method === "GET") {
|
|
926
|
+
void (async () => {
|
|
927
|
+
const { handleCalendarCallback } = await import("./connectors/googleCalendar.js");
|
|
928
|
+
const code = parsedUrl.searchParams.get("code");
|
|
929
|
+
const state = parsedUrl.searchParams.get("state");
|
|
930
|
+
const error = parsedUrl.searchParams.get("error");
|
|
931
|
+
const result = await handleCalendarCallback(code, state, error);
|
|
932
|
+
res.writeHead(result.status, {
|
|
933
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
934
|
+
});
|
|
935
|
+
res.end(result.body);
|
|
936
|
+
})();
|
|
937
|
+
return true;
|
|
938
|
+
}
|
|
939
|
+
if (parsedUrl.pathname === "/connections/google-calendar/test" &&
|
|
940
|
+
req.method === "POST") {
|
|
941
|
+
void (async () => {
|
|
942
|
+
const { handleCalendarTest } = await import("./connectors/googleCalendar.js");
|
|
943
|
+
const result = await handleCalendarTest();
|
|
944
|
+
res.writeHead(result.status, {
|
|
945
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
946
|
+
});
|
|
947
|
+
res.end(result.body);
|
|
948
|
+
})();
|
|
949
|
+
return true;
|
|
950
|
+
}
|
|
951
|
+
if (parsedUrl.pathname === "/connections/google-calendar" &&
|
|
952
|
+
req.method === "DELETE") {
|
|
953
|
+
void (async () => {
|
|
954
|
+
const { handleCalendarDisconnect } = await import("./connectors/googleCalendar.js");
|
|
955
|
+
const result = await handleCalendarDisconnect();
|
|
956
|
+
res.writeHead(result.status, {
|
|
957
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
958
|
+
});
|
|
959
|
+
res.end(result.body);
|
|
960
|
+
})();
|
|
961
|
+
return true;
|
|
962
|
+
}
|
|
963
|
+
// ── Google Drive routes ─────────────────────────────────────────
|
|
964
|
+
if (parsedUrl.pathname === "/connections/google-drive/auth" &&
|
|
965
|
+
req.method === "GET") {
|
|
966
|
+
void (async () => {
|
|
967
|
+
const { handleDriveAuthRedirect } = await import("./connectors/googleDrive.js");
|
|
968
|
+
const result = handleDriveAuthRedirect();
|
|
969
|
+
if (result.redirect) {
|
|
970
|
+
res.writeHead(302, { Location: result.redirect });
|
|
971
|
+
res.end();
|
|
972
|
+
}
|
|
973
|
+
else {
|
|
974
|
+
res.writeHead(result.status, {
|
|
975
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
976
|
+
});
|
|
977
|
+
res.end(result.body);
|
|
978
|
+
}
|
|
979
|
+
})();
|
|
980
|
+
return true;
|
|
981
|
+
}
|
|
982
|
+
if (parsedUrl.pathname === "/connections/google-drive/callback" &&
|
|
983
|
+
req.method === "GET") {
|
|
984
|
+
void (async () => {
|
|
985
|
+
const { handleDriveCallback } = await import("./connectors/googleDrive.js");
|
|
986
|
+
const code = parsedUrl.searchParams.get("code");
|
|
987
|
+
const state = parsedUrl.searchParams.get("state");
|
|
988
|
+
const error = parsedUrl.searchParams.get("error");
|
|
989
|
+
const result = await handleDriveCallback(code, state, error);
|
|
990
|
+
res.writeHead(result.status, {
|
|
991
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
992
|
+
});
|
|
993
|
+
res.end(result.body);
|
|
994
|
+
})();
|
|
995
|
+
return true;
|
|
996
|
+
}
|
|
997
|
+
if (parsedUrl.pathname === "/connections/google-drive/test" &&
|
|
998
|
+
req.method === "POST") {
|
|
999
|
+
void (async () => {
|
|
1000
|
+
const { handleDriveTest } = await import("./connectors/googleDrive.js");
|
|
1001
|
+
const result = await handleDriveTest();
|
|
1002
|
+
res.writeHead(result.status, {
|
|
1003
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1004
|
+
});
|
|
1005
|
+
res.end(result.body);
|
|
1006
|
+
})();
|
|
1007
|
+
return true;
|
|
1008
|
+
}
|
|
1009
|
+
if (parsedUrl.pathname === "/connections/google-drive" &&
|
|
1010
|
+
req.method === "DELETE") {
|
|
1011
|
+
void (async () => {
|
|
1012
|
+
const { handleDriveDisconnect } = await import("./connectors/googleDrive.js");
|
|
1013
|
+
const result = await handleDriveDisconnect();
|
|
1014
|
+
res.writeHead(result.status, {
|
|
1015
|
+
"Content-Type": result.contentType ?? "application/json",
|
|
1016
|
+
});
|
|
1017
|
+
res.end(result.body);
|
|
1018
|
+
})();
|
|
1019
|
+
return true;
|
|
1020
|
+
}
|
|
1021
|
+
return false;
|
|
1022
|
+
}
|
|
1023
|
+
//# sourceMappingURL=connectorRoutes.js.map
|