@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,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/";
|
|
@@ -119,6 +130,20 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
119
130
|
* `runSetupFlow` from `setup-flow.ts`.
|
|
120
131
|
*/
|
|
121
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;
|
|
122
147
|
constructor(config) {
|
|
123
148
|
this.slug = config.slug;
|
|
124
149
|
this.authType = config.authType;
|
|
@@ -136,6 +161,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
136
161
|
this.query = config.query;
|
|
137
162
|
this.checkConnection = config.checkConnection;
|
|
138
163
|
this.setup = config.setup;
|
|
164
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
139
165
|
}
|
|
140
166
|
get connectorKey() {
|
|
141
167
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -200,6 +226,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
200
226
|
}
|
|
201
227
|
};
|
|
202
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
|
+
for (const step of flow.steps) {
|
|
239
|
+
const ans = ctx.answers[answerIdx];
|
|
240
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
241
|
+
state = step.applyAnswer(state, ans.answer);
|
|
242
|
+
answerIdx += 1;
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
if (step.type === "text") {
|
|
246
|
+
return {
|
|
247
|
+
type: "nextQuestion",
|
|
248
|
+
questionSlug: step.slug,
|
|
249
|
+
question: step.question[ctx.language],
|
|
250
|
+
questionType: "text"
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
|
|
254
|
+
if (options.length === 0) {
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
type: "nextQuestion",
|
|
259
|
+
questionSlug: step.slug,
|
|
260
|
+
question: step.question[ctx.language],
|
|
261
|
+
questionType: step.type,
|
|
262
|
+
options
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
266
|
+
return { type: "fulfilled", dataInvestigationResult };
|
|
267
|
+
}
|
|
268
|
+
async function resolveSetupSelection(params) {
|
|
269
|
+
const { selected, allSentinel, fetchAll, limit } = params;
|
|
270
|
+
const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
|
|
271
|
+
return resolved.slice(0, limit);
|
|
272
|
+
}
|
|
273
|
+
|
|
203
274
|
// ../connectors/src/auth-types.ts
|
|
204
275
|
var AUTH_TYPES = {
|
|
205
276
|
OAUTH: "oauth",
|
|
@@ -360,6 +431,7 @@ var metaAdsOauthOnboarding = new ConnectorOnboarding({
|
|
|
360
431
|
});
|
|
361
432
|
|
|
362
433
|
// ../connectors/src/connectors/meta-ads-oauth/parameters.ts
|
|
434
|
+
init_parameter_definition();
|
|
363
435
|
var parameters = {
|
|
364
436
|
adAccountId: new ParameterDefinition({
|
|
365
437
|
slug: "ad-account-id",
|
|
@@ -372,9 +444,106 @@ var parameters = {
|
|
|
372
444
|
})
|
|
373
445
|
};
|
|
374
446
|
|
|
447
|
+
// ../connectors/src/connectors/meta-ads-oauth/setup-flow.ts
|
|
448
|
+
var BASE_URL3 = "https://graph.facebook.com/v21.0";
|
|
449
|
+
var ALL_AD_ACCOUNTS = "__ALL_AD_ACCOUNTS__";
|
|
450
|
+
var META_ADS_OAUTH_SETUP_MAX_ACCOUNTS = 10;
|
|
451
|
+
var ACCOUNT_STATUS_LABELS = {
|
|
452
|
+
1: "ACTIVE",
|
|
453
|
+
2: "DISABLED",
|
|
454
|
+
3: "UNSETTLED",
|
|
455
|
+
7: "PENDING_RISK_REVIEW",
|
|
456
|
+
8: "PENDING_SETTLEMENT",
|
|
457
|
+
9: "IN_GRACE_PERIOD",
|
|
458
|
+
100: "PENDING_CLOSURE",
|
|
459
|
+
101: "CLOSED",
|
|
460
|
+
201: "ANY_ACTIVE",
|
|
461
|
+
202: "ANY_CLOSED"
|
|
462
|
+
};
|
|
463
|
+
function statusLabel(status) {
|
|
464
|
+
if (status == null) return "-";
|
|
465
|
+
return ACCOUNT_STATUS_LABELS[status] ?? String(status);
|
|
466
|
+
}
|
|
467
|
+
async function listAdAccounts(proxyFetch) {
|
|
468
|
+
const url = `${BASE_URL3}/me/adaccounts?fields=id,account_id,name,currency,account_status&limit=200`;
|
|
469
|
+
const res = await proxyFetch(url, { method: "GET" });
|
|
470
|
+
if (!res.ok) {
|
|
471
|
+
const body = await res.text().catch(() => res.statusText);
|
|
472
|
+
throw new Error(
|
|
473
|
+
`meta-ads-oauth: listAdAccounts failed (${res.status}): ${body}`
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
const data = await res.json();
|
|
477
|
+
return data.data ?? [];
|
|
478
|
+
}
|
|
479
|
+
function bareAdAccountId(account) {
|
|
480
|
+
if (account.account_id) return account.account_id;
|
|
481
|
+
return (account.id ?? "").replace(/^act_/, "");
|
|
482
|
+
}
|
|
483
|
+
var metaAdsOauthSetupFlow = {
|
|
484
|
+
initialState: () => ({}),
|
|
485
|
+
steps: [
|
|
486
|
+
{
|
|
487
|
+
slug: "adAccounts",
|
|
488
|
+
type: "multiSelect",
|
|
489
|
+
question: {
|
|
490
|
+
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",
|
|
491
|
+
en: "Select target Meta ad accounts (multi-select allowed)"
|
|
492
|
+
},
|
|
493
|
+
async fetchOptions(_state, rt) {
|
|
494
|
+
const accounts = await listAdAccounts(rt.config.proxyFetch);
|
|
495
|
+
const options = accounts.map((a) => {
|
|
496
|
+
const id = bareAdAccountId(a);
|
|
497
|
+
if (!id) return null;
|
|
498
|
+
const label = a.name ? `${a.name} (${id})` : id;
|
|
499
|
+
return { value: id, label };
|
|
500
|
+
}).filter((v) => v != null);
|
|
501
|
+
if (options.length === 0) return [];
|
|
502
|
+
return [
|
|
503
|
+
{
|
|
504
|
+
value: ALL_AD_ACCOUNTS,
|
|
505
|
+
label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u5E83\u544A\u30A2\u30AB\u30A6\u30F3\u30C8" : "All ad accounts"
|
|
506
|
+
},
|
|
507
|
+
...options
|
|
508
|
+
];
|
|
509
|
+
},
|
|
510
|
+
applyAnswer: (state, answer) => ({ ...state, adAccounts: answer })
|
|
511
|
+
}
|
|
512
|
+
],
|
|
513
|
+
async finalize(state, rt) {
|
|
514
|
+
if (!state.adAccounts) {
|
|
515
|
+
throw new Error("Meta Ads OAuth setup: incomplete state on finalize");
|
|
516
|
+
}
|
|
517
|
+
const accounts = await listAdAccounts(rt.config.proxyFetch);
|
|
518
|
+
const byId = new Map(accounts.map((a) => [bareAdAccountId(a), a]));
|
|
519
|
+
const targetIds = await resolveSetupSelection({
|
|
520
|
+
selected: state.adAccounts,
|
|
521
|
+
allSentinel: ALL_AD_ACCOUNTS,
|
|
522
|
+
fetchAll: async () => accounts.map((a) => bareAdAccountId(a)).filter((id) => id),
|
|
523
|
+
limit: META_ADS_OAUTH_SETUP_MAX_ACCOUNTS
|
|
524
|
+
});
|
|
525
|
+
const sections = ["## Meta Ads", ""];
|
|
526
|
+
if (targetIds.length === 0) {
|
|
527
|
+
sections.push("_No ad accounts selected._", "");
|
|
528
|
+
return sections.join("\n");
|
|
529
|
+
}
|
|
530
|
+
sections.push("| Ad Account ID | Name | Currency | Status |");
|
|
531
|
+
sections.push("|---------------|------|----------|--------|");
|
|
532
|
+
for (const id of targetIds) {
|
|
533
|
+
const account = byId.get(id);
|
|
534
|
+
const name = (account?.name ?? "-").replace(/\|/g, "\\|");
|
|
535
|
+
const currency = account?.currency ?? "-";
|
|
536
|
+
const status = statusLabel(account?.account_status);
|
|
537
|
+
sections.push(`| ${id} | ${name} | ${currency} | ${status} |`);
|
|
538
|
+
}
|
|
539
|
+
sections.push("");
|
|
540
|
+
return sections.join("\n");
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
|
|
375
544
|
// ../connectors/src/connectors/meta-ads-oauth/tools/request.ts
|
|
376
545
|
import { z as z2 } from "zod";
|
|
377
|
-
var
|
|
546
|
+
var BASE_URL4 = "https://graph.facebook.com/v21.0/";
|
|
378
547
|
var REQUEST_TIMEOUT_MS2 = 6e4;
|
|
379
548
|
var cachedToken2 = null;
|
|
380
549
|
async function getProxyToken2(config) {
|
|
@@ -451,7 +620,7 @@ Authentication is handled automatically via OAuth proxy.
|
|
|
451
620
|
try {
|
|
452
621
|
const adAccountId = parameters.adAccountId.tryGetValue(connection2) ?? "";
|
|
453
622
|
const resolvedPath = adAccountId ? path2.replace(/\{adAccountId\}/g, adAccountId) : path2;
|
|
454
|
-
let url = `${
|
|
623
|
+
let url = `${BASE_URL4}${resolvedPath}`;
|
|
455
624
|
if (queryParams && Object.keys(queryParams).length > 0) {
|
|
456
625
|
const params = new URLSearchParams(queryParams);
|
|
457
626
|
const separator = url.includes("?") ? "&" : "?";
|
|
@@ -501,6 +670,7 @@ var tools = {
|
|
|
501
670
|
var metaAdsOauthConnector = new ConnectorPlugin({
|
|
502
671
|
slug: "meta-ads",
|
|
503
672
|
authType: AUTH_TYPES.OAUTH,
|
|
673
|
+
skipConnectionCheckOnCreate: true,
|
|
504
674
|
name: "Meta Ads",
|
|
505
675
|
description: "Connect to Meta (Facebook/Instagram) Ads for advertising campaign data and reporting using OAuth.",
|
|
506
676
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/2vyrgcvdf3jETIFXHtbteO/de7f3288e831c9f738e44cf1f961c3bd/meta-icon.webp",
|
|
@@ -633,6 +803,7 @@ const data = await res.json();
|
|
|
633
803
|
\`\`\``
|
|
634
804
|
},
|
|
635
805
|
tools,
|
|
806
|
+
setup: (params, ctx, config) => runSetupFlow(metaAdsOauthSetupFlow, params, ctx, config),
|
|
636
807
|
async checkConnection(_params, config) {
|
|
637
808
|
const { proxyFetch } = config;
|
|
638
809
|
try {
|
|
@@ -681,6 +852,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
681
852
|
import { getContext } from "hono/context-storage";
|
|
682
853
|
import { getCookie } from "hono/cookie";
|
|
683
854
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
855
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
684
856
|
function normalizeHeaders(input) {
|
|
685
857
|
const out = {};
|
|
686
858
|
if (!input) return out;
|
|
@@ -689,6 +861,11 @@ function normalizeHeaders(input) {
|
|
|
689
861
|
});
|
|
690
862
|
return out;
|
|
691
863
|
}
|
|
864
|
+
function extractInputUrl(input) {
|
|
865
|
+
if (typeof input === "string") return input;
|
|
866
|
+
if (input instanceof URL) return input.href;
|
|
867
|
+
return input.url;
|
|
868
|
+
}
|
|
692
869
|
function createSandboxProxyFetch(connectionId) {
|
|
693
870
|
return async (input, init) => {
|
|
694
871
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -698,10 +875,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
698
875
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
699
876
|
);
|
|
700
877
|
}
|
|
701
|
-
const originalUrl =
|
|
878
|
+
const originalUrl = extractInputUrl(input);
|
|
879
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
880
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
881
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
882
|
+
return fetch(sessionUrl, {
|
|
883
|
+
method: "POST",
|
|
884
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
885
|
+
});
|
|
886
|
+
}
|
|
702
887
|
const originalMethod = init?.method ?? "GET";
|
|
703
888
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
704
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
705
889
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
706
890
|
return fetch(proxyUrl, {
|
|
707
891
|
method: "POST",
|
|
@@ -727,10 +911,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
727
911
|
}
|
|
728
912
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
729
913
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
914
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
730
915
|
return async (input, init) => {
|
|
731
|
-
const originalUrl =
|
|
732
|
-
const originalMethod = init?.method ?? "GET";
|
|
733
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
916
|
+
const originalUrl = extractInputUrl(input);
|
|
734
917
|
const c = getContext();
|
|
735
918
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
736
919
|
if (!appSession) {
|
|
@@ -738,6 +921,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
738
921
|
"No authentication method available for connection proxy."
|
|
739
922
|
);
|
|
740
923
|
}
|
|
924
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
925
|
+
return fetch(sessionUrl, {
|
|
926
|
+
method: "POST",
|
|
927
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
const originalMethod = init?.method ?? "GET";
|
|
931
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
741
932
|
return fetch(proxyUrl, {
|
|
742
933
|
method: "POST",
|
|
743
934
|
headers: {
|