@squadbase/vite-server 0.1.12-dev.a9ac647 → 0.1.17-dev.3b633bb
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 +14375 -1652
- package/dist/connectors/airtable-oauth.js +282 -46
- package/dist/connectors/airtable.js +319 -51
- package/dist/connectors/amplitude.js +322 -47
- package/dist/connectors/anthropic.js +135 -47
- package/dist/connectors/asana.js +327 -49
- package/dist/connectors/attio.js +302 -49
- package/dist/connectors/aws-billing.js +287 -46
- package/dist/connectors/azure-sql.js +421 -102
- package/dist/connectors/backlog-api-key.js +317 -47
- package/dist/connectors/clickup.js +338 -49
- package/dist/connectors/cosmosdb.js +305 -50
- package/dist/connectors/customerio.js +319 -47
- package/dist/connectors/dbt.js +340 -47
- package/dist/connectors/freshdesk.js +342 -53
- package/dist/connectors/freshsales.js +333 -52
- package/dist/connectors/freshservice.js +361 -53
- package/dist/connectors/gamma.js +327 -52
- package/dist/connectors/gemini.js +134 -47
- package/dist/connectors/github.js +386 -49
- package/dist/connectors/gmail-oauth.js +204 -7
- package/dist/connectors/gmail.js +350 -47
- package/dist/connectors/google-ads.js +288 -46
- package/dist/connectors/google-analytics-oauth.js +310 -46
- package/dist/connectors/google-analytics.js +547 -87
- package/dist/connectors/google-audit-log.js +438 -47
- package/dist/connectors/google-calendar-oauth.js +259 -46
- package/dist/connectors/google-calendar.js +359 -47
- package/dist/connectors/google-docs.js +220 -6
- package/dist/connectors/google-drive.js +262 -5
- package/dist/connectors/google-search-console-oauth.js +256 -46
- package/dist/connectors/google-sheets.js +272 -47
- package/dist/connectors/google-slides.js +205 -6
- package/dist/connectors/grafana.js +332 -49
- package/dist/connectors/hubspot-oauth.js +208 -5
- package/dist/connectors/hubspot.js +306 -49
- package/dist/connectors/influxdb.js +416 -51
- package/dist/connectors/intercom-oauth.js +210 -5
- package/dist/connectors/intercom.js +302 -49
- package/dist/connectors/jdbc.js +762 -110
- package/dist/connectors/jira-api-key.js +326 -47
- package/dist/connectors/kintone-api-token.js +281 -47
- package/dist/connectors/kintone.js +328 -47
- package/dist/connectors/linear.js +330 -49
- package/dist/connectors/linkedin-ads.js +268 -50
- package/dist/connectors/mailchimp-oauth.js +268 -46
- package/dist/connectors/mailchimp.js +320 -49
- package/dist/connectors/meta-ads-oauth.js +273 -48
- package/dist/connectors/meta-ads.js +285 -50
- package/dist/connectors/mixpanel.js +338 -47
- package/dist/connectors/monday.js +360 -49
- package/dist/connectors/mongodb.js +319 -57
- package/dist/connectors/notion-oauth.js +231 -5
- package/dist/connectors/notion.js +323 -51
- package/dist/connectors/openai.js +134 -47
- package/dist/connectors/oracle.js +454 -103
- package/dist/connectors/outlook-oauth.js +204 -5
- package/dist/connectors/powerbi-oauth.js +498 -5
- package/dist/connectors/salesforce.js +384 -49
- package/dist/connectors/semrush.js +609 -49
- package/dist/connectors/sentry.js +289 -50
- package/dist/connectors/shopify-oauth.js +187 -5
- package/dist/connectors/shopify.js +357 -47
- package/dist/connectors/sqlserver.js +415 -102
- package/dist/connectors/stripe-api-key.js +269 -46
- package/dist/connectors/stripe-oauth.js +202 -5
- package/dist/connectors/supabase.js +303 -48
- package/dist/connectors/tableau.js +536 -163
- package/dist/connectors/tiktok-ads.js +279 -48
- package/dist/connectors/wix-store.js +320 -49
- package/dist/connectors/zendesk-oauth.js +239 -5
- package/dist/connectors/zendesk.js +358 -47
- package/dist/index.d.ts +149 -1
- package/dist/index.js +15057 -2117
- package/dist/main.js +15005 -2073
- package/dist/vite-plugin.js +14752 -2019
- package/package.json +1 -1
|
@@ -1,46 +1,57 @@
|
|
|
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/meta-ads-oauth/sdk/index.ts
|
|
46
57
|
var BASE_URL = "https://graph.facebook.com/v21.0/";
|
|
@@ -111,6 +122,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
111
122
|
tools;
|
|
112
123
|
query;
|
|
113
124
|
checkConnection;
|
|
125
|
+
/**
|
|
126
|
+
* SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
|
|
127
|
+
* implement this expose a step-by-step exploration flow (database/schema/
|
|
128
|
+
* table/etc. discovery) that the dashboard backend drives via the
|
|
129
|
+
* `/connections/:connectionId/setup` endpoint. Implement by delegating to
|
|
130
|
+
* `runSetupFlow` from `setup-flow.ts`.
|
|
131
|
+
*/
|
|
132
|
+
setup;
|
|
133
|
+
/**
|
|
134
|
+
* Opt-out of the default "verify before save" behavior on connection
|
|
135
|
+
* creation. The backend invokes `checkConnection` synchronously while
|
|
136
|
+
* creating the connection and aborts (no row inserted) if it fails — this
|
|
137
|
+
* flag disables that for connectors where the check cannot succeed pre-save:
|
|
138
|
+
*
|
|
139
|
+
* - `squadbase-db` populates `connection-url` only after Neon provisioning
|
|
140
|
+
* - OAuth connectors require an OAuth-aware proxyFetch keyed by the
|
|
141
|
+
* connectionId, which doesn't exist until the row is saved
|
|
142
|
+
*
|
|
143
|
+
* Exceptions are the explicit position; new credential-input connectors get
|
|
144
|
+
* the default verify-on-create behavior without opt-in.
|
|
145
|
+
*/
|
|
146
|
+
skipConnectionCheckOnCreate;
|
|
114
147
|
constructor(config) {
|
|
115
148
|
this.slug = config.slug;
|
|
116
149
|
this.authType = config.authType;
|
|
@@ -127,6 +160,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
127
160
|
this.tools = config.tools;
|
|
128
161
|
this.query = config.query;
|
|
129
162
|
this.checkConnection = config.checkConnection;
|
|
163
|
+
this.setup = config.setup;
|
|
164
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
130
165
|
}
|
|
131
166
|
get connectorKey() {
|
|
132
167
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -191,6 +226,76 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
191
226
|
}
|
|
192
227
|
};
|
|
193
228
|
|
|
229
|
+
// ../connectors/src/setup-flow.ts
|
|
230
|
+
async function runSetupFlow(flow, params, ctx, config) {
|
|
231
|
+
const runtime = {
|
|
232
|
+
params,
|
|
233
|
+
language: ctx.language,
|
|
234
|
+
config
|
|
235
|
+
};
|
|
236
|
+
let state = flow.initialState();
|
|
237
|
+
let answerIdx = 0;
|
|
238
|
+
const pendingParameterUpdates = [];
|
|
239
|
+
for (const step of flow.steps) {
|
|
240
|
+
const ans = ctx.answers[answerIdx];
|
|
241
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
242
|
+
state = step.applyAnswer(state, ans.answer);
|
|
243
|
+
if (step.toParameterUpdates) {
|
|
244
|
+
pendingParameterUpdates.push(...step.toParameterUpdates(state));
|
|
245
|
+
}
|
|
246
|
+
answerIdx += 1;
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
250
|
+
if (step.type === "text") {
|
|
251
|
+
if (step.fetchOptions) {
|
|
252
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
253
|
+
if (options2.length === 0) {
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
type: "nextQuestion",
|
|
259
|
+
questionSlug: step.slug,
|
|
260
|
+
question: step.question[ctx.language],
|
|
261
|
+
questionType: "text",
|
|
262
|
+
allowFreeText: resolvedAllowFreeText,
|
|
263
|
+
...pendingParameterUpdates.length > 0 && {
|
|
264
|
+
parameterUpdates: pendingParameterUpdates
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
|
|
269
|
+
if (options.length === 0) {
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
type: "nextQuestion",
|
|
274
|
+
questionSlug: step.slug,
|
|
275
|
+
question: step.question[ctx.language],
|
|
276
|
+
questionType: step.type,
|
|
277
|
+
options,
|
|
278
|
+
allowFreeText: resolvedAllowFreeText,
|
|
279
|
+
...pendingParameterUpdates.length > 0 && {
|
|
280
|
+
parameterUpdates: pendingParameterUpdates
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
285
|
+
return {
|
|
286
|
+
type: "fulfilled",
|
|
287
|
+
dataInvestigationResult,
|
|
288
|
+
...pendingParameterUpdates.length > 0 && {
|
|
289
|
+
parameterUpdates: pendingParameterUpdates
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
async function resolveSetupSelection(params) {
|
|
294
|
+
const { selected, allSentinel, fetchAll, limit } = params;
|
|
295
|
+
const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
|
|
296
|
+
return resolved.slice(0, limit);
|
|
297
|
+
}
|
|
298
|
+
|
|
194
299
|
// ../connectors/src/auth-types.ts
|
|
195
300
|
var AUTH_TYPES = {
|
|
196
301
|
OAUTH: "oauth",
|
|
@@ -351,6 +456,7 @@ var metaAdsOauthOnboarding = new ConnectorOnboarding({
|
|
|
351
456
|
});
|
|
352
457
|
|
|
353
458
|
// ../connectors/src/connectors/meta-ads-oauth/parameters.ts
|
|
459
|
+
init_parameter_definition();
|
|
354
460
|
var parameters = {
|
|
355
461
|
adAccountId: new ParameterDefinition({
|
|
356
462
|
slug: "ad-account-id",
|
|
@@ -363,9 +469,106 @@ var parameters = {
|
|
|
363
469
|
})
|
|
364
470
|
};
|
|
365
471
|
|
|
472
|
+
// ../connectors/src/connectors/meta-ads-oauth/setup-flow.ts
|
|
473
|
+
var BASE_URL3 = "https://graph.facebook.com/v21.0";
|
|
474
|
+
var ALL_AD_ACCOUNTS = "__ALL_AD_ACCOUNTS__";
|
|
475
|
+
var META_ADS_OAUTH_SETUP_MAX_ACCOUNTS = 10;
|
|
476
|
+
var ACCOUNT_STATUS_LABELS = {
|
|
477
|
+
1: "ACTIVE",
|
|
478
|
+
2: "DISABLED",
|
|
479
|
+
3: "UNSETTLED",
|
|
480
|
+
7: "PENDING_RISK_REVIEW",
|
|
481
|
+
8: "PENDING_SETTLEMENT",
|
|
482
|
+
9: "IN_GRACE_PERIOD",
|
|
483
|
+
100: "PENDING_CLOSURE",
|
|
484
|
+
101: "CLOSED",
|
|
485
|
+
201: "ANY_ACTIVE",
|
|
486
|
+
202: "ANY_CLOSED"
|
|
487
|
+
};
|
|
488
|
+
function statusLabel(status) {
|
|
489
|
+
if (status == null) return "-";
|
|
490
|
+
return ACCOUNT_STATUS_LABELS[status] ?? String(status);
|
|
491
|
+
}
|
|
492
|
+
async function listAdAccounts(proxyFetch) {
|
|
493
|
+
const url = `${BASE_URL3}/me/adaccounts?fields=id,account_id,name,currency,account_status&limit=200`;
|
|
494
|
+
const res = await proxyFetch(url, { method: "GET" });
|
|
495
|
+
if (!res.ok) {
|
|
496
|
+
const body = await res.text().catch(() => res.statusText);
|
|
497
|
+
throw new Error(
|
|
498
|
+
`meta-ads-oauth: listAdAccounts failed (${res.status}): ${body}`
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
const data = await res.json();
|
|
502
|
+
return data.data ?? [];
|
|
503
|
+
}
|
|
504
|
+
function bareAdAccountId(account) {
|
|
505
|
+
if (account.account_id) return account.account_id;
|
|
506
|
+
return (account.id ?? "").replace(/^act_/, "");
|
|
507
|
+
}
|
|
508
|
+
var metaAdsOauthSetupFlow = {
|
|
509
|
+
initialState: () => ({}),
|
|
510
|
+
steps: [
|
|
511
|
+
{
|
|
512
|
+
slug: "adAccounts",
|
|
513
|
+
type: "multiSelect",
|
|
514
|
+
question: {
|
|
515
|
+
ja: "\u5BFE\u8C61\u306E Meta \u5E83\u544A\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
|
|
516
|
+
en: "Select target Meta ad accounts (multi-select allowed)"
|
|
517
|
+
},
|
|
518
|
+
async fetchOptions(_state, rt) {
|
|
519
|
+
const accounts = await listAdAccounts(rt.config.proxyFetch);
|
|
520
|
+
const options = accounts.map((a) => {
|
|
521
|
+
const id = bareAdAccountId(a);
|
|
522
|
+
if (!id) return null;
|
|
523
|
+
const label = a.name ? `${a.name} (${id})` : id;
|
|
524
|
+
return { value: id, label };
|
|
525
|
+
}).filter((v) => v != null);
|
|
526
|
+
if (options.length === 0) return [];
|
|
527
|
+
return [
|
|
528
|
+
{
|
|
529
|
+
value: ALL_AD_ACCOUNTS,
|
|
530
|
+
label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u5E83\u544A\u30A2\u30AB\u30A6\u30F3\u30C8" : "All ad accounts"
|
|
531
|
+
},
|
|
532
|
+
...options
|
|
533
|
+
];
|
|
534
|
+
},
|
|
535
|
+
applyAnswer: (state, answer) => ({ ...state, adAccounts: answer })
|
|
536
|
+
}
|
|
537
|
+
],
|
|
538
|
+
async finalize(state, rt) {
|
|
539
|
+
if (!state.adAccounts) {
|
|
540
|
+
throw new Error("Meta Ads OAuth setup: incomplete state on finalize");
|
|
541
|
+
}
|
|
542
|
+
const accounts = await listAdAccounts(rt.config.proxyFetch);
|
|
543
|
+
const byId = new Map(accounts.map((a) => [bareAdAccountId(a), a]));
|
|
544
|
+
const targetIds = await resolveSetupSelection({
|
|
545
|
+
selected: state.adAccounts,
|
|
546
|
+
allSentinel: ALL_AD_ACCOUNTS,
|
|
547
|
+
fetchAll: async () => accounts.map((a) => bareAdAccountId(a)).filter((id) => id),
|
|
548
|
+
limit: META_ADS_OAUTH_SETUP_MAX_ACCOUNTS
|
|
549
|
+
});
|
|
550
|
+
const sections = ["## Meta Ads", ""];
|
|
551
|
+
if (targetIds.length === 0) {
|
|
552
|
+
sections.push("_No ad accounts selected._", "");
|
|
553
|
+
return sections.join("\n");
|
|
554
|
+
}
|
|
555
|
+
sections.push("| Ad Account ID | Name | Currency | Status |");
|
|
556
|
+
sections.push("|---------------|------|----------|--------|");
|
|
557
|
+
for (const id of targetIds) {
|
|
558
|
+
const account = byId.get(id);
|
|
559
|
+
const name = (account?.name ?? "-").replace(/\|/g, "\\|");
|
|
560
|
+
const currency = account?.currency ?? "-";
|
|
561
|
+
const status = statusLabel(account?.account_status);
|
|
562
|
+
sections.push(`| ${id} | ${name} | ${currency} | ${status} |`);
|
|
563
|
+
}
|
|
564
|
+
sections.push("");
|
|
565
|
+
return sections.join("\n");
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
|
|
366
569
|
// ../connectors/src/connectors/meta-ads-oauth/tools/request.ts
|
|
367
570
|
import { z as z2 } from "zod";
|
|
368
|
-
var
|
|
571
|
+
var BASE_URL4 = "https://graph.facebook.com/v21.0/";
|
|
369
572
|
var REQUEST_TIMEOUT_MS2 = 6e4;
|
|
370
573
|
var cachedToken2 = null;
|
|
371
574
|
async function getProxyToken2(config) {
|
|
@@ -442,7 +645,7 @@ Authentication is handled automatically via OAuth proxy.
|
|
|
442
645
|
try {
|
|
443
646
|
const adAccountId = parameters.adAccountId.tryGetValue(connection2) ?? "";
|
|
444
647
|
const resolvedPath = adAccountId ? path2.replace(/\{adAccountId\}/g, adAccountId) : path2;
|
|
445
|
-
let url = `${
|
|
648
|
+
let url = `${BASE_URL4}${resolvedPath}`;
|
|
446
649
|
if (queryParams && Object.keys(queryParams).length > 0) {
|
|
447
650
|
const params = new URLSearchParams(queryParams);
|
|
448
651
|
const separator = url.includes("?") ? "&" : "?";
|
|
@@ -492,6 +695,7 @@ var tools = {
|
|
|
492
695
|
var metaAdsOauthConnector = new ConnectorPlugin({
|
|
493
696
|
slug: "meta-ads",
|
|
494
697
|
authType: AUTH_TYPES.OAUTH,
|
|
698
|
+
skipConnectionCheckOnCreate: true,
|
|
495
699
|
name: "Meta Ads",
|
|
496
700
|
description: "Connect to Meta (Facebook/Instagram) Ads for advertising campaign data and reporting using OAuth.",
|
|
497
701
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/2vyrgcvdf3jETIFXHtbteO/de7f3288e831c9f738e44cf1f961c3bd/meta-icon.webp",
|
|
@@ -624,6 +828,7 @@ const data = await res.json();
|
|
|
624
828
|
\`\`\``
|
|
625
829
|
},
|
|
626
830
|
tools,
|
|
831
|
+
setup: (params, ctx, config) => runSetupFlow(metaAdsOauthSetupFlow, params, ctx, config),
|
|
627
832
|
async checkConnection(_params, config) {
|
|
628
833
|
const { proxyFetch } = config;
|
|
629
834
|
try {
|
|
@@ -672,6 +877,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
672
877
|
import { getContext } from "hono/context-storage";
|
|
673
878
|
import { getCookie } from "hono/cookie";
|
|
674
879
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
880
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
675
881
|
function normalizeHeaders(input) {
|
|
676
882
|
const out = {};
|
|
677
883
|
if (!input) return out;
|
|
@@ -680,6 +886,11 @@ function normalizeHeaders(input) {
|
|
|
680
886
|
});
|
|
681
887
|
return out;
|
|
682
888
|
}
|
|
889
|
+
function extractInputUrl(input) {
|
|
890
|
+
if (typeof input === "string") return input;
|
|
891
|
+
if (input instanceof URL) return input.href;
|
|
892
|
+
return input.url;
|
|
893
|
+
}
|
|
683
894
|
function createSandboxProxyFetch(connectionId) {
|
|
684
895
|
return async (input, init) => {
|
|
685
896
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -689,10 +900,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
689
900
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
690
901
|
);
|
|
691
902
|
}
|
|
692
|
-
const originalUrl =
|
|
903
|
+
const originalUrl = extractInputUrl(input);
|
|
904
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
905
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
906
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
907
|
+
return fetch(sessionUrl, {
|
|
908
|
+
method: "POST",
|
|
909
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
910
|
+
});
|
|
911
|
+
}
|
|
693
912
|
const originalMethod = init?.method ?? "GET";
|
|
694
913
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
695
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
696
914
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
697
915
|
return fetch(proxyUrl, {
|
|
698
916
|
method: "POST",
|
|
@@ -718,10 +936,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
718
936
|
}
|
|
719
937
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
720
938
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
939
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
721
940
|
return async (input, init) => {
|
|
722
|
-
const originalUrl =
|
|
723
|
-
const originalMethod = init?.method ?? "GET";
|
|
724
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
941
|
+
const originalUrl = extractInputUrl(input);
|
|
725
942
|
const c = getContext();
|
|
726
943
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
727
944
|
if (!appSession) {
|
|
@@ -729,6 +946,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
729
946
|
"No authentication method available for connection proxy."
|
|
730
947
|
);
|
|
731
948
|
}
|
|
949
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
950
|
+
return fetch(sessionUrl, {
|
|
951
|
+
method: "POST",
|
|
952
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
const originalMethod = init?.method ?? "GET";
|
|
956
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
732
957
|
return fetch(proxyUrl, {
|
|
733
958
|
method: "POST",
|
|
734
959
|
headers: {
|