@squadbase/vite-server 0.1.12-dev.93b8799 → 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 +12128 -934
- package/dist/connectors/airtable-oauth.js +248 -46
- package/dist/connectors/airtable.js +285 -51
- package/dist/connectors/amplitude.js +288 -47
- package/dist/connectors/anthropic.js +126 -47
- package/dist/connectors/asana.js +293 -49
- package/dist/connectors/attio.js +268 -49
- package/dist/connectors/aws-billing.js +253 -46
- package/dist/connectors/azure-sql.js +387 -102
- package/dist/connectors/backlog-api-key.js +283 -47
- package/dist/connectors/clickup.js +304 -49
- package/dist/connectors/cosmosdb.js +271 -50
- package/dist/connectors/customerio.js +285 -47
- package/dist/connectors/dbt.js +306 -47
- package/dist/connectors/freshdesk.js +308 -53
- package/dist/connectors/freshsales.js +299 -52
- package/dist/connectors/freshservice.js +327 -53
- package/dist/connectors/gamma.js +293 -52
- package/dist/connectors/gemini.js +125 -47
- package/dist/connectors/github.js +352 -49
- package/dist/connectors/gmail-oauth.js +170 -7
- package/dist/connectors/gmail.js +316 -47
- package/dist/connectors/google-ads.js +254 -46
- package/dist/connectors/google-analytics-oauth.js +276 -46
- package/dist/connectors/google-analytics.js +378 -49
- package/dist/connectors/google-audit-log.js +404 -47
- package/dist/connectors/google-calendar-oauth.js +225 -46
- package/dist/connectors/google-calendar.js +325 -47
- package/dist/connectors/google-docs.js +186 -6
- package/dist/connectors/google-drive.js +228 -5
- package/dist/connectors/google-search-console-oauth.js +222 -46
- package/dist/connectors/google-sheets.js +238 -47
- package/dist/connectors/google-slides.js +171 -6
- package/dist/connectors/grafana.js +298 -49
- package/dist/connectors/hubspot-oauth.js +174 -5
- package/dist/connectors/hubspot.js +272 -49
- package/dist/connectors/influxdb.js +382 -51
- package/dist/connectors/intercom-oauth.js +176 -5
- package/dist/connectors/intercom.js +268 -49
- package/dist/connectors/jdbc.js +728 -110
- package/dist/connectors/jira-api-key.js +292 -47
- package/dist/connectors/kintone-api-token.js +247 -47
- package/dist/connectors/kintone.js +294 -47
- package/dist/connectors/linear.js +296 -49
- package/dist/connectors/linkedin-ads.js +234 -50
- package/dist/connectors/mailchimp-oauth.js +234 -46
- package/dist/connectors/mailchimp.js +286 -49
- package/dist/connectors/meta-ads-oauth.js +239 -48
- package/dist/connectors/meta-ads.js +251 -50
- package/dist/connectors/mixpanel.js +304 -47
- package/dist/connectors/monday.js +326 -49
- package/dist/connectors/mongodb.js +285 -57
- package/dist/connectors/notion-oauth.js +197 -5
- package/dist/connectors/notion.js +289 -51
- package/dist/connectors/openai.js +125 -47
- package/dist/connectors/oracle.js +405 -103
- package/dist/connectors/outlook-oauth.js +170 -5
- package/dist/connectors/powerbi-oauth.js +217 -5
- package/dist/connectors/salesforce.js +350 -49
- package/dist/connectors/semrush.js +280 -49
- package/dist/connectors/sentry.js +255 -50
- package/dist/connectors/shopify-oauth.js +153 -5
- package/dist/connectors/shopify.js +323 -47
- package/dist/connectors/sqlserver.js +381 -102
- package/dist/connectors/stripe-api-key.js +235 -46
- package/dist/connectors/stripe-oauth.js +168 -5
- package/dist/connectors/supabase.js +269 -48
- package/dist/connectors/tableau.js +337 -206
- package/dist/connectors/tiktok-ads.js +245 -48
- package/dist/connectors/wix-store.js +286 -49
- package/dist/connectors/zendesk-oauth.js +205 -5
- package/dist/connectors/zendesk.js +324 -47
- package/dist/index.d.ts +149 -1
- package/dist/index.js +18297 -6886
- package/dist/main.js +12785 -1382
- package/dist/vite-plugin.js +12140 -936
- 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",
|
|
@@ -194,6 +206,20 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
194
206
|
* `runSetupFlow` from `setup-flow.ts`.
|
|
195
207
|
*/
|
|
196
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;
|
|
197
223
|
constructor(config) {
|
|
198
224
|
this.slug = config.slug;
|
|
199
225
|
this.authType = config.authType;
|
|
@@ -211,6 +237,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
211
237
|
this.query = config.query;
|
|
212
238
|
this.checkConnection = config.checkConnection;
|
|
213
239
|
this.setup = config.setup;
|
|
240
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
214
241
|
}
|
|
215
242
|
get connectorKey() {
|
|
216
243
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -275,6 +302,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
275
302
|
}
|
|
276
303
|
};
|
|
277
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
|
+
|
|
278
350
|
// ../connectors/src/auth-types.ts
|
|
279
351
|
var AUTH_TYPES = {
|
|
280
352
|
OAUTH: "oauth",
|
|
@@ -781,6 +853,144 @@ For each calendar:
|
|
|
781
853
|
}
|
|
782
854
|
});
|
|
783
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
|
+
|
|
784
994
|
// ../connectors/src/connectors/google-calendar/index.ts
|
|
785
995
|
var tools = {
|
|
786
996
|
request: requestTool,
|
|
@@ -994,7 +1204,55 @@ export default async function handler(c: Context) {
|
|
|
994
1204
|
}
|
|
995
1205
|
\`\`\``
|
|
996
1206
|
},
|
|
997
|
-
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
|
+
}
|
|
998
1256
|
});
|
|
999
1257
|
|
|
1000
1258
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -1023,6 +1281,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
1023
1281
|
import { getContext } from "hono/context-storage";
|
|
1024
1282
|
import { getCookie } from "hono/cookie";
|
|
1025
1283
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
1284
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
1026
1285
|
function normalizeHeaders(input) {
|
|
1027
1286
|
const out = {};
|
|
1028
1287
|
if (!input) return out;
|
|
@@ -1031,6 +1290,11 @@ function normalizeHeaders(input) {
|
|
|
1031
1290
|
});
|
|
1032
1291
|
return out;
|
|
1033
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
|
+
}
|
|
1034
1298
|
function createSandboxProxyFetch(connectionId) {
|
|
1035
1299
|
return async (input, init) => {
|
|
1036
1300
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -1040,10 +1304,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
1040
1304
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
1041
1305
|
);
|
|
1042
1306
|
}
|
|
1043
|
-
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
|
+
}
|
|
1044
1316
|
const originalMethod = init?.method ?? "GET";
|
|
1045
1317
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1046
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
1047
1318
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1048
1319
|
return fetch(proxyUrl, {
|
|
1049
1320
|
method: "POST",
|
|
@@ -1069,10 +1340,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
1069
1340
|
}
|
|
1070
1341
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
1071
1342
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1343
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
1072
1344
|
return async (input, init) => {
|
|
1073
|
-
const originalUrl =
|
|
1074
|
-
const originalMethod = init?.method ?? "GET";
|
|
1075
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1345
|
+
const originalUrl = extractInputUrl(input);
|
|
1076
1346
|
const c = getContext();
|
|
1077
1347
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
1078
1348
|
if (!appSession) {
|
|
@@ -1080,6 +1350,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
1080
1350
|
"No authentication method available for connection proxy."
|
|
1081
1351
|
);
|
|
1082
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;
|
|
1083
1361
|
return fetch(proxyUrl, {
|
|
1084
1362
|
method: "POST",
|
|
1085
1363
|
headers: {
|