@squadbase/vite-server 0.1.12-dev.a9ac647 → 0.1.17-dev.24af54e
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/dist/cli/index.js +12374 -883
- package/dist/connectors/airtable-oauth.js +257 -46
- package/dist/connectors/airtable.js +294 -51
- package/dist/connectors/amplitude.js +297 -47
- package/dist/connectors/anthropic.js +135 -47
- package/dist/connectors/asana.js +302 -49
- package/dist/connectors/attio.js +277 -49
- package/dist/connectors/aws-billing.js +262 -46
- package/dist/connectors/azure-sql.js +396 -102
- package/dist/connectors/backlog-api-key.js +292 -47
- package/dist/connectors/clickup.js +313 -49
- package/dist/connectors/cosmosdb.js +280 -50
- package/dist/connectors/customerio.js +294 -47
- package/dist/connectors/dbt.js +315 -47
- package/dist/connectors/freshdesk.js +317 -53
- package/dist/connectors/freshsales.js +308 -52
- package/dist/connectors/freshservice.js +336 -53
- package/dist/connectors/gamma.js +302 -52
- package/dist/connectors/gemini.js +134 -47
- package/dist/connectors/github.js +361 -49
- package/dist/connectors/gmail-oauth.js +179 -7
- package/dist/connectors/gmail.js +325 -47
- package/dist/connectors/google-ads.js +263 -46
- package/dist/connectors/google-analytics-oauth.js +285 -46
- package/dist/connectors/google-analytics.js +387 -49
- package/dist/connectors/google-audit-log.js +413 -47
- package/dist/connectors/google-calendar-oauth.js +234 -46
- package/dist/connectors/google-calendar.js +334 -47
- package/dist/connectors/google-docs.js +195 -6
- package/dist/connectors/google-drive.js +237 -5
- package/dist/connectors/google-search-console-oauth.js +231 -46
- package/dist/connectors/google-sheets.js +247 -47
- package/dist/connectors/google-slides.js +180 -6
- package/dist/connectors/grafana.js +307 -49
- package/dist/connectors/hubspot-oauth.js +183 -5
- package/dist/connectors/hubspot.js +281 -49
- package/dist/connectors/influxdb.js +391 -51
- package/dist/connectors/intercom-oauth.js +185 -5
- package/dist/connectors/intercom.js +277 -49
- package/dist/connectors/jdbc.js +737 -110
- package/dist/connectors/jira-api-key.js +301 -47
- package/dist/connectors/kintone-api-token.js +256 -47
- package/dist/connectors/kintone.js +303 -47
- package/dist/connectors/linear.js +305 -49
- package/dist/connectors/linkedin-ads.js +243 -50
- package/dist/connectors/mailchimp-oauth.js +243 -46
- package/dist/connectors/mailchimp.js +295 -49
- package/dist/connectors/meta-ads-oauth.js +248 -48
- package/dist/connectors/meta-ads.js +260 -50
- package/dist/connectors/mixpanel.js +313 -47
- package/dist/connectors/monday.js +335 -49
- package/dist/connectors/mongodb.js +294 -57
- package/dist/connectors/notion-oauth.js +206 -5
- package/dist/connectors/notion.js +298 -51
- package/dist/connectors/openai.js +134 -47
- package/dist/connectors/oracle.js +414 -103
- package/dist/connectors/outlook-oauth.js +179 -5
- package/dist/connectors/powerbi-oauth.js +226 -5
- package/dist/connectors/salesforce.js +359 -49
- package/dist/connectors/semrush.js +289 -49
- package/dist/connectors/sentry.js +264 -50
- package/dist/connectors/shopify-oauth.js +162 -5
- package/dist/connectors/shopify.js +332 -47
- package/dist/connectors/sqlserver.js +390 -102
- package/dist/connectors/stripe-api-key.js +244 -46
- package/dist/connectors/stripe-oauth.js +177 -5
- package/dist/connectors/supabase.js +278 -48
- package/dist/connectors/tableau.js +389 -184
- package/dist/connectors/tiktok-ads.js +254 -48
- package/dist/connectors/wix-store.js +295 -49
- package/dist/connectors/zendesk-oauth.js +214 -5
- package/dist/connectors/zendesk.js +333 -47
- package/dist/index.d.ts +149 -1
- package/dist/index.js +13677 -1969
- package/dist/main.js +13627 -1927
- package/dist/vite-plugin.js +12391 -890
- package/package.json +1 -1
|
@@ -1,48 +1,60 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __esm = (fn, res) => function __init() {
|
|
3
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
4
|
+
};
|
|
5
|
+
|
|
1
6
|
// ../connectors/src/parameter-definition.ts
|
|
2
|
-
var ParameterDefinition
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
7
|
+
var ParameterDefinition;
|
|
8
|
+
var init_parameter_definition = __esm({
|
|
9
|
+
"../connectors/src/parameter-definition.ts"() {
|
|
10
|
+
"use strict";
|
|
11
|
+
ParameterDefinition = class {
|
|
12
|
+
slug;
|
|
13
|
+
name;
|
|
14
|
+
description;
|
|
15
|
+
envVarBaseKey;
|
|
16
|
+
type;
|
|
17
|
+
secret;
|
|
18
|
+
required;
|
|
19
|
+
constructor(config) {
|
|
20
|
+
this.slug = config.slug;
|
|
21
|
+
this.name = config.name;
|
|
22
|
+
this.description = config.description;
|
|
23
|
+
this.envVarBaseKey = config.envVarBaseKey;
|
|
24
|
+
this.type = config.type;
|
|
25
|
+
this.secret = config.secret;
|
|
26
|
+
this.required = config.required;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get the parameter value from a ConnectorConnectionObject.
|
|
30
|
+
*/
|
|
31
|
+
getValue(connection2) {
|
|
32
|
+
const param = connection2.parameters.find(
|
|
33
|
+
(p) => p.parameterSlug === this.slug
|
|
34
|
+
);
|
|
35
|
+
if (!param || param.value == null) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Parameter "${this.slug}" not found or has no value in connection "${connection2.id}"`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return param.value;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Try to get the parameter value. Returns undefined if not found (for optional params).
|
|
44
|
+
*/
|
|
45
|
+
tryGetValue(connection2) {
|
|
46
|
+
const param = connection2.parameters.find(
|
|
47
|
+
(p) => p.parameterSlug === this.slug
|
|
48
|
+
);
|
|
49
|
+
if (!param || param.value == null) return void 0;
|
|
50
|
+
return param.value;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
42
53
|
}
|
|
43
|
-
};
|
|
54
|
+
});
|
|
44
55
|
|
|
45
56
|
// ../connectors/src/connectors/google-calendar/parameters.ts
|
|
57
|
+
init_parameter_definition();
|
|
46
58
|
var parameters = {
|
|
47
59
|
serviceAccountKeyJsonBase64: new ParameterDefinition({
|
|
48
60
|
slug: "service-account-key-json-base64",
|
|
@@ -186,6 +198,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
186
198
|
tools;
|
|
187
199
|
query;
|
|
188
200
|
checkConnection;
|
|
201
|
+
/**
|
|
202
|
+
* SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
|
|
203
|
+
* implement this expose a step-by-step exploration flow (database/schema/
|
|
204
|
+
* table/etc. discovery) that the dashboard backend drives via the
|
|
205
|
+
* `/connections/:connectionId/setup` endpoint. Implement by delegating to
|
|
206
|
+
* `runSetupFlow` from `setup-flow.ts`.
|
|
207
|
+
*/
|
|
208
|
+
setup;
|
|
209
|
+
/**
|
|
210
|
+
* Opt-out of the default "verify before save" behavior on connection
|
|
211
|
+
* creation. The backend invokes `checkConnection` synchronously while
|
|
212
|
+
* creating the connection and aborts (no row inserted) if it fails — this
|
|
213
|
+
* flag disables that for connectors where the check cannot succeed pre-save:
|
|
214
|
+
*
|
|
215
|
+
* - `squadbase-db` populates `connection-url` only after Neon provisioning
|
|
216
|
+
* - OAuth connectors require an OAuth-aware proxyFetch keyed by the
|
|
217
|
+
* connectionId, which doesn't exist until the row is saved
|
|
218
|
+
*
|
|
219
|
+
* Exceptions are the explicit position; new credential-input connectors get
|
|
220
|
+
* the default verify-on-create behavior without opt-in.
|
|
221
|
+
*/
|
|
222
|
+
skipConnectionCheckOnCreate;
|
|
189
223
|
constructor(config) {
|
|
190
224
|
this.slug = config.slug;
|
|
191
225
|
this.authType = config.authType;
|
|
@@ -202,6 +236,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
202
236
|
this.tools = config.tools;
|
|
203
237
|
this.query = config.query;
|
|
204
238
|
this.checkConnection = config.checkConnection;
|
|
239
|
+
this.setup = config.setup;
|
|
240
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
205
241
|
}
|
|
206
242
|
get connectorKey() {
|
|
207
243
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -266,6 +302,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
266
302
|
}
|
|
267
303
|
};
|
|
268
304
|
|
|
305
|
+
// ../connectors/src/setup-flow.ts
|
|
306
|
+
async function runSetupFlow(flow, params, ctx, config) {
|
|
307
|
+
const runtime = {
|
|
308
|
+
params,
|
|
309
|
+
language: ctx.language,
|
|
310
|
+
config
|
|
311
|
+
};
|
|
312
|
+
let state = flow.initialState();
|
|
313
|
+
let answerIdx = 0;
|
|
314
|
+
for (const step of flow.steps) {
|
|
315
|
+
const ans = ctx.answers[answerIdx];
|
|
316
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
317
|
+
state = step.applyAnswer(state, ans.answer);
|
|
318
|
+
answerIdx += 1;
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
if (step.type === "text") {
|
|
322
|
+
return {
|
|
323
|
+
type: "nextQuestion",
|
|
324
|
+
questionSlug: step.slug,
|
|
325
|
+
question: step.question[ctx.language],
|
|
326
|
+
questionType: "text"
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
|
|
330
|
+
if (options.length === 0) {
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
type: "nextQuestion",
|
|
335
|
+
questionSlug: step.slug,
|
|
336
|
+
question: step.question[ctx.language],
|
|
337
|
+
questionType: step.type,
|
|
338
|
+
options
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
342
|
+
return { type: "fulfilled", dataInvestigationResult };
|
|
343
|
+
}
|
|
344
|
+
async function resolveSetupSelection(params) {
|
|
345
|
+
const { selected, allSentinel, fetchAll, limit } = params;
|
|
346
|
+
const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
|
|
347
|
+
return resolved.slice(0, limit);
|
|
348
|
+
}
|
|
349
|
+
|
|
269
350
|
// ../connectors/src/auth-types.ts
|
|
270
351
|
var AUTH_TYPES = {
|
|
271
352
|
OAUTH: "oauth",
|
|
@@ -772,6 +853,144 @@ For each calendar:
|
|
|
772
853
|
}
|
|
773
854
|
});
|
|
774
855
|
|
|
856
|
+
// ../connectors/src/connectors/google-calendar/utils.ts
|
|
857
|
+
function decodeServiceAccount3(keyJsonBase64) {
|
|
858
|
+
const decoded = Buffer.from(keyJsonBase64, "base64").toString("utf-8");
|
|
859
|
+
return JSON.parse(decoded);
|
|
860
|
+
}
|
|
861
|
+
var READONLY_SCOPES2 = ["https://www.googleapis.com/auth/calendar.readonly"];
|
|
862
|
+
async function getAccessToken(params, subject, scopes) {
|
|
863
|
+
const keyJsonBase64 = params[parameters.serviceAccountKeyJsonBase64.slug];
|
|
864
|
+
if (!keyJsonBase64) {
|
|
865
|
+
throw new Error("Google Calendar setup: service account key is missing");
|
|
866
|
+
}
|
|
867
|
+
const sa = decodeServiceAccount3(keyJsonBase64);
|
|
868
|
+
const { GoogleAuth } = await import("google-auth-library");
|
|
869
|
+
const auth = new GoogleAuth({
|
|
870
|
+
credentials: { client_email: sa.client_email, private_key: sa.private_key },
|
|
871
|
+
scopes,
|
|
872
|
+
...subject ? { clientOptions: { subject } } : {}
|
|
873
|
+
});
|
|
874
|
+
const token = await auth.getAccessToken();
|
|
875
|
+
if (!token) {
|
|
876
|
+
throw new Error("Google Calendar setup: failed to obtain access token");
|
|
877
|
+
}
|
|
878
|
+
return token;
|
|
879
|
+
}
|
|
880
|
+
async function calendarApiFetch(params, subject, url) {
|
|
881
|
+
const token = await getAccessToken(params, subject, READONLY_SCOPES2);
|
|
882
|
+
const res = await fetch(url, {
|
|
883
|
+
method: "GET",
|
|
884
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
885
|
+
});
|
|
886
|
+
if (!res.ok) {
|
|
887
|
+
const text = await res.text().catch(() => res.statusText);
|
|
888
|
+
throw new Error(
|
|
889
|
+
`Google Calendar ${url} failed: HTTP ${res.status} ${text}`
|
|
890
|
+
);
|
|
891
|
+
}
|
|
892
|
+
return await res.json();
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
// ../connectors/src/connectors/google-calendar/setup-flow.ts
|
|
896
|
+
var ALL_CALENDARS = "__ALL_CALENDARS__";
|
|
897
|
+
var GOOGLE_CALENDAR_SETUP_MAX_CALENDARS = 20;
|
|
898
|
+
var NO_SUBJECT = "";
|
|
899
|
+
async function listCalendars(params, subject) {
|
|
900
|
+
const url = "https://www.googleapis.com/calendar/v3/users/me/calendarList?maxResults=250";
|
|
901
|
+
const data = await calendarApiFetch(
|
|
902
|
+
params,
|
|
903
|
+
subject,
|
|
904
|
+
url
|
|
905
|
+
);
|
|
906
|
+
return data.items ?? [];
|
|
907
|
+
}
|
|
908
|
+
function displayName(c) {
|
|
909
|
+
return c.summaryOverride ?? c.summary ?? c.id;
|
|
910
|
+
}
|
|
911
|
+
var googleCalendarSetupFlow = {
|
|
912
|
+
initialState: () => ({}),
|
|
913
|
+
steps: [
|
|
914
|
+
{
|
|
915
|
+
slug: "subject",
|
|
916
|
+
type: "text",
|
|
917
|
+
question: {
|
|
918
|
+
ja: "\u5BFE\u8C61\u3068\u3059\u308B Workspace \u30E6\u30FC\u30B6\u30FC\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u7A7A\u6B04\u3067\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u81EA\u8EAB\u3068\u3057\u3066\u30A2\u30AF\u30BB\u30B9\uFF09",
|
|
919
|
+
en: "Enter the Workspace user email to impersonate via Domain-wide Delegation (leave empty to access as the service account itself)"
|
|
920
|
+
},
|
|
921
|
+
applyAnswer: (state, answer) => ({
|
|
922
|
+
...state,
|
|
923
|
+
subject: (answer[0] ?? "").trim()
|
|
924
|
+
})
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
slug: "calendars",
|
|
928
|
+
type: "multiSelect",
|
|
929
|
+
question: {
|
|
930
|
+
ja: "\u5BFE\u8C61\u306E\u30AB\u30EC\u30F3\u30C0\u30FC\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
|
|
931
|
+
en: "Select target calendars (multi-select allowed)"
|
|
932
|
+
},
|
|
933
|
+
async fetchOptions(state, rt) {
|
|
934
|
+
if (state.subject == null) return [];
|
|
935
|
+
const subj = state.subject === NO_SUBJECT ? null : state.subject;
|
|
936
|
+
const cals = await listCalendars(rt.params, subj);
|
|
937
|
+
return [
|
|
938
|
+
{
|
|
939
|
+
value: ALL_CALENDARS,
|
|
940
|
+
label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u30AB\u30EC\u30F3\u30C0\u30FC" : "All calendars"
|
|
941
|
+
},
|
|
942
|
+
...cals.map((c) => ({ value: c.id, label: displayName(c) }))
|
|
943
|
+
];
|
|
944
|
+
},
|
|
945
|
+
applyAnswer: (state, answer) => ({ ...state, calendars: answer })
|
|
946
|
+
}
|
|
947
|
+
],
|
|
948
|
+
async finalize(state, rt) {
|
|
949
|
+
if (state.subject == null || !state.calendars) {
|
|
950
|
+
throw new Error("Google Calendar setup: incomplete state on finalize");
|
|
951
|
+
}
|
|
952
|
+
const subj = state.subject === NO_SUBJECT ? null : state.subject;
|
|
953
|
+
const cals = await listCalendars(rt.params, subj);
|
|
954
|
+
const byId = new Map(cals.map((c) => [c.id, c]));
|
|
955
|
+
const targetIds = await resolveSetupSelection({
|
|
956
|
+
selected: state.calendars,
|
|
957
|
+
allSentinel: ALL_CALENDARS,
|
|
958
|
+
fetchAll: async () => cals.map((c) => c.id),
|
|
959
|
+
limit: GOOGLE_CALENDAR_SETUP_MAX_CALENDARS
|
|
960
|
+
});
|
|
961
|
+
const subjectLabel = subj ?? "(service account)";
|
|
962
|
+
const sections = [
|
|
963
|
+
"## Google Calendar",
|
|
964
|
+
"",
|
|
965
|
+
`### Subject: ${subjectLabel}`,
|
|
966
|
+
""
|
|
967
|
+
];
|
|
968
|
+
if (targetIds.length === 0) {
|
|
969
|
+
sections.push(
|
|
970
|
+
rt.language === "ja" ? "\u5BFE\u8C61\u306E\u30AB\u30EC\u30F3\u30C0\u30FC\u304C\u9078\u629E\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002" : "No calendars selected."
|
|
971
|
+
);
|
|
972
|
+
return sections.join("\n");
|
|
973
|
+
}
|
|
974
|
+
sections.push("| Calendar | Time Zone | Primary | Access |");
|
|
975
|
+
sections.push("|----------|-----------|---------|--------|");
|
|
976
|
+
for (const id of targetIds) {
|
|
977
|
+
const c = byId.get(id);
|
|
978
|
+
if (!c) {
|
|
979
|
+
sections.push(`| ${id} | - | - | - |`);
|
|
980
|
+
continue;
|
|
981
|
+
}
|
|
982
|
+
const tz = c.timeZone ?? "-";
|
|
983
|
+
const primary = c.primary ? "yes" : "no";
|
|
984
|
+
const access = c.accessRole ?? "-";
|
|
985
|
+
sections.push(
|
|
986
|
+
`| ${displayName(c)} | ${tz} | ${primary} | ${access} |`
|
|
987
|
+
);
|
|
988
|
+
}
|
|
989
|
+
sections.push("");
|
|
990
|
+
return sections.join("\n");
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
|
|
775
994
|
// ../connectors/src/connectors/google-calendar/index.ts
|
|
776
995
|
var tools = {
|
|
777
996
|
request: requestTool,
|
|
@@ -985,7 +1204,55 @@ export default async function handler(c: Context) {
|
|
|
985
1204
|
}
|
|
986
1205
|
\`\`\``
|
|
987
1206
|
},
|
|
988
|
-
tools
|
|
1207
|
+
tools,
|
|
1208
|
+
setup: (params, ctx, config) => runSetupFlow(googleCalendarSetupFlow, params, ctx, config),
|
|
1209
|
+
async checkConnection(params, _config) {
|
|
1210
|
+
const keyJsonBase64 = params[parameters.serviceAccountKeyJsonBase64.slug];
|
|
1211
|
+
if (!keyJsonBase64) {
|
|
1212
|
+
return {
|
|
1213
|
+
success: false,
|
|
1214
|
+
error: "google-calendar: missing service account key"
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
let sa;
|
|
1218
|
+
try {
|
|
1219
|
+
const decoded = Buffer.from(keyJsonBase64, "base64").toString("utf-8");
|
|
1220
|
+
sa = JSON.parse(decoded);
|
|
1221
|
+
} catch (err) {
|
|
1222
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1223
|
+
return {
|
|
1224
|
+
success: false,
|
|
1225
|
+
error: `google-calendar: failed to parse service account JSON: ${msg}`
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
if (!sa.client_email || !sa.private_key) {
|
|
1229
|
+
return {
|
|
1230
|
+
success: false,
|
|
1231
|
+
error: "google-calendar: service account JSON must contain client_email and private_key"
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
try {
|
|
1235
|
+
const { GoogleAuth } = await import("google-auth-library");
|
|
1236
|
+
const auth = new GoogleAuth({
|
|
1237
|
+
credentials: {
|
|
1238
|
+
client_email: sa.client_email,
|
|
1239
|
+
private_key: sa.private_key
|
|
1240
|
+
},
|
|
1241
|
+
scopes: ["https://www.googleapis.com/auth/calendar.readonly"]
|
|
1242
|
+
});
|
|
1243
|
+
const token = await auth.getAccessToken();
|
|
1244
|
+
if (!token) {
|
|
1245
|
+
return {
|
|
1246
|
+
success: false,
|
|
1247
|
+
error: "google-calendar: failed to obtain access token"
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1250
|
+
return { success: true };
|
|
1251
|
+
} catch (err) {
|
|
1252
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1253
|
+
return { success: false, error: msg };
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
989
1256
|
});
|
|
990
1257
|
|
|
991
1258
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -1014,6 +1281,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
1014
1281
|
import { getContext } from "hono/context-storage";
|
|
1015
1282
|
import { getCookie } from "hono/cookie";
|
|
1016
1283
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
1284
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
1017
1285
|
function normalizeHeaders(input) {
|
|
1018
1286
|
const out = {};
|
|
1019
1287
|
if (!input) return out;
|
|
@@ -1022,6 +1290,11 @@ function normalizeHeaders(input) {
|
|
|
1022
1290
|
});
|
|
1023
1291
|
return out;
|
|
1024
1292
|
}
|
|
1293
|
+
function extractInputUrl(input) {
|
|
1294
|
+
if (typeof input === "string") return input;
|
|
1295
|
+
if (input instanceof URL) return input.href;
|
|
1296
|
+
return input.url;
|
|
1297
|
+
}
|
|
1025
1298
|
function createSandboxProxyFetch(connectionId) {
|
|
1026
1299
|
return async (input, init) => {
|
|
1027
1300
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -1031,10 +1304,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
1031
1304
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
1032
1305
|
);
|
|
1033
1306
|
}
|
|
1034
|
-
const originalUrl =
|
|
1307
|
+
const originalUrl = extractInputUrl(input);
|
|
1308
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
1309
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
1310
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
1311
|
+
return fetch(sessionUrl, {
|
|
1312
|
+
method: "POST",
|
|
1313
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1035
1316
|
const originalMethod = init?.method ?? "GET";
|
|
1036
1317
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1037
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
1038
1318
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1039
1319
|
return fetch(proxyUrl, {
|
|
1040
1320
|
method: "POST",
|
|
@@ -1060,10 +1340,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
1060
1340
|
}
|
|
1061
1341
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
1062
1342
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1343
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
1063
1344
|
return async (input, init) => {
|
|
1064
|
-
const originalUrl =
|
|
1065
|
-
const originalMethod = init?.method ?? "GET";
|
|
1066
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1345
|
+
const originalUrl = extractInputUrl(input);
|
|
1067
1346
|
const c = getContext();
|
|
1068
1347
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
1069
1348
|
if (!appSession) {
|
|
@@ -1071,6 +1350,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
1071
1350
|
"No authentication method available for connection proxy."
|
|
1072
1351
|
);
|
|
1073
1352
|
}
|
|
1353
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
1354
|
+
return fetch(sessionUrl, {
|
|
1355
|
+
method: "POST",
|
|
1356
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
const originalMethod = init?.method ?? "GET";
|
|
1360
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1074
1361
|
return fetch(proxyUrl, {
|
|
1075
1362
|
method: "POST",
|
|
1076
1363
|
headers: {
|