@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/semrush/parameters.ts
|
|
57
|
+
init_parameter_definition();
|
|
46
58
|
var parameters = {
|
|
47
59
|
apiKey: new ParameterDefinition({
|
|
48
60
|
slug: "api-key",
|
|
@@ -236,6 +248,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
236
248
|
tools;
|
|
237
249
|
query;
|
|
238
250
|
checkConnection;
|
|
251
|
+
/**
|
|
252
|
+
* SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
|
|
253
|
+
* implement this expose a step-by-step exploration flow (database/schema/
|
|
254
|
+
* table/etc. discovery) that the dashboard backend drives via the
|
|
255
|
+
* `/connections/:connectionId/setup` endpoint. Implement by delegating to
|
|
256
|
+
* `runSetupFlow` from `setup-flow.ts`.
|
|
257
|
+
*/
|
|
258
|
+
setup;
|
|
259
|
+
/**
|
|
260
|
+
* Opt-out of the default "verify before save" behavior on connection
|
|
261
|
+
* creation. The backend invokes `checkConnection` synchronously while
|
|
262
|
+
* creating the connection and aborts (no row inserted) if it fails — this
|
|
263
|
+
* flag disables that for connectors where the check cannot succeed pre-save:
|
|
264
|
+
*
|
|
265
|
+
* - `squadbase-db` populates `connection-url` only after Neon provisioning
|
|
266
|
+
* - OAuth connectors require an OAuth-aware proxyFetch keyed by the
|
|
267
|
+
* connectionId, which doesn't exist until the row is saved
|
|
268
|
+
*
|
|
269
|
+
* Exceptions are the explicit position; new credential-input connectors get
|
|
270
|
+
* the default verify-on-create behavior without opt-in.
|
|
271
|
+
*/
|
|
272
|
+
skipConnectionCheckOnCreate;
|
|
239
273
|
constructor(config) {
|
|
240
274
|
this.slug = config.slug;
|
|
241
275
|
this.authType = config.authType;
|
|
@@ -252,6 +286,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
252
286
|
this.tools = config.tools;
|
|
253
287
|
this.query = config.query;
|
|
254
288
|
this.checkConnection = config.checkConnection;
|
|
289
|
+
this.setup = config.setup;
|
|
290
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
255
291
|
}
|
|
256
292
|
get connectorKey() {
|
|
257
293
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -316,6 +352,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
316
352
|
}
|
|
317
353
|
};
|
|
318
354
|
|
|
355
|
+
// ../connectors/src/setup-flow.ts
|
|
356
|
+
async function runSetupFlow(flow, params, ctx, config) {
|
|
357
|
+
const runtime = {
|
|
358
|
+
params,
|
|
359
|
+
language: ctx.language,
|
|
360
|
+
config
|
|
361
|
+
};
|
|
362
|
+
let state = flow.initialState();
|
|
363
|
+
let answerIdx = 0;
|
|
364
|
+
for (const step of flow.steps) {
|
|
365
|
+
const ans = ctx.answers[answerIdx];
|
|
366
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
367
|
+
state = step.applyAnswer(state, ans.answer);
|
|
368
|
+
answerIdx += 1;
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
if (step.type === "text") {
|
|
372
|
+
return {
|
|
373
|
+
type: "nextQuestion",
|
|
374
|
+
questionSlug: step.slug,
|
|
375
|
+
question: step.question[ctx.language],
|
|
376
|
+
questionType: "text"
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
|
|
380
|
+
if (options.length === 0) {
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
return {
|
|
384
|
+
type: "nextQuestion",
|
|
385
|
+
questionSlug: step.slug,
|
|
386
|
+
question: step.question[ctx.language],
|
|
387
|
+
questionType: step.type,
|
|
388
|
+
options
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
392
|
+
return { type: "fulfilled", dataInvestigationResult };
|
|
393
|
+
}
|
|
394
|
+
async function resolveSetupSelection(params) {
|
|
395
|
+
const { selected, allSentinel, fetchAll, limit } = params;
|
|
396
|
+
const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
|
|
397
|
+
return resolved.slice(0, limit);
|
|
398
|
+
}
|
|
399
|
+
|
|
319
400
|
// ../connectors/src/auth-types.ts
|
|
320
401
|
var AUTH_TYPES = {
|
|
321
402
|
OAUTH: "oauth",
|
|
@@ -511,6 +592,144 @@ var semrushOnboarding = new ConnectorOnboarding({
|
|
|
511
592
|
}
|
|
512
593
|
});
|
|
513
594
|
|
|
595
|
+
// ../connectors/src/connectors/semrush/utils.ts
|
|
596
|
+
var PROJECTS_BASE_URL = "https://api.semrush.com/management/v1";
|
|
597
|
+
function projectsApiFetch(params, path2, init) {
|
|
598
|
+
const apiKey = params[parameters.apiKey.slug];
|
|
599
|
+
if (!apiKey) {
|
|
600
|
+
throw new Error(
|
|
601
|
+
`semrush: missing required parameter: ${parameters.apiKey.slug}`
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
const trimmedPath = path2.startsWith("/") ? path2 : `/${path2}`;
|
|
605
|
+
const url = new URL(`${PROJECTS_BASE_URL}${trimmedPath}`);
|
|
606
|
+
if (!url.searchParams.has("key")) {
|
|
607
|
+
url.searchParams.set("key", apiKey);
|
|
608
|
+
}
|
|
609
|
+
const headers = new Headers(init?.headers);
|
|
610
|
+
if (!headers.has("Accept")) headers.set("Accept", "application/json");
|
|
611
|
+
return fetch(url.toString(), { ...init, headers });
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// ../connectors/src/connectors/semrush/setup-flow.ts
|
|
615
|
+
var ALL_PROJECTS = "__ALL_PROJECTS__";
|
|
616
|
+
var SEMRUSH_SETUP_MAX_PROJECTS = 10;
|
|
617
|
+
function projectId(p) {
|
|
618
|
+
const raw = p.project_id ?? p.id;
|
|
619
|
+
return raw == null ? "" : String(raw);
|
|
620
|
+
}
|
|
621
|
+
function projectName(p) {
|
|
622
|
+
return p.project_name ?? p.name ?? p.domain ?? p.url ?? projectId(p);
|
|
623
|
+
}
|
|
624
|
+
function projectDomain(p) {
|
|
625
|
+
return p.domain ?? p.url ?? "";
|
|
626
|
+
}
|
|
627
|
+
function projectCreatedAt(p) {
|
|
628
|
+
return p.created_at ?? p.date_created ?? "";
|
|
629
|
+
}
|
|
630
|
+
async function fetchProjects(params) {
|
|
631
|
+
let res;
|
|
632
|
+
try {
|
|
633
|
+
res = await projectsApiFetch(params, "/projects/");
|
|
634
|
+
} catch (err) {
|
|
635
|
+
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
636
|
+
}
|
|
637
|
+
if (!res.ok) {
|
|
638
|
+
const body2 = await res.text().catch(() => res.statusText);
|
|
639
|
+
return { ok: false, error: `HTTP ${res.status} ${body2 || res.statusText}` };
|
|
640
|
+
}
|
|
641
|
+
let body;
|
|
642
|
+
try {
|
|
643
|
+
body = await res.json();
|
|
644
|
+
} catch (err) {
|
|
645
|
+
return {
|
|
646
|
+
ok: false,
|
|
647
|
+
error: err instanceof Error ? err.message : String(err)
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
const projects = Array.isArray(body) ? body : Array.isArray(body?.projects) ? body.projects : Array.isArray(body?.data) ? body.data : [];
|
|
651
|
+
return { ok: true, projects };
|
|
652
|
+
}
|
|
653
|
+
var semrushSetupFlow = {
|
|
654
|
+
initialState: () => ({}),
|
|
655
|
+
steps: [
|
|
656
|
+
{
|
|
657
|
+
slug: "projects",
|
|
658
|
+
type: "multiSelect",
|
|
659
|
+
question: {
|
|
660
|
+
ja: "\u5BFE\u8C61\u306E Semrush \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
|
|
661
|
+
en: "Select target Semrush projects (multi-select allowed)"
|
|
662
|
+
},
|
|
663
|
+
async fetchOptions(_state, rt) {
|
|
664
|
+
const result = await fetchProjects(rt.params);
|
|
665
|
+
if (!result.ok || result.projects.length === 0) {
|
|
666
|
+
return [];
|
|
667
|
+
}
|
|
668
|
+
const options = result.projects.map((p) => {
|
|
669
|
+
const id = projectId(p);
|
|
670
|
+
if (!id) return null;
|
|
671
|
+
return { value: id, label: projectName(p) };
|
|
672
|
+
}).filter((opt) => opt !== null);
|
|
673
|
+
if (options.length === 0) return [];
|
|
674
|
+
return [
|
|
675
|
+
{
|
|
676
|
+
value: ALL_PROJECTS,
|
|
677
|
+
label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8" : "All projects"
|
|
678
|
+
},
|
|
679
|
+
...options
|
|
680
|
+
];
|
|
681
|
+
},
|
|
682
|
+
applyAnswer: (state, answer) => ({ ...state, projects: answer })
|
|
683
|
+
}
|
|
684
|
+
],
|
|
685
|
+
async finalize(state, rt) {
|
|
686
|
+
const sections = ["## Semrush", ""];
|
|
687
|
+
if (!state.projects?.length) {
|
|
688
|
+
sections.push(
|
|
689
|
+
"_No Semrush Projects API access detected; Standard Analytics reports run by domain/keyword and don't require pre-selection._",
|
|
690
|
+
""
|
|
691
|
+
);
|
|
692
|
+
return sections.join("\n");
|
|
693
|
+
}
|
|
694
|
+
const result = await fetchProjects(rt.params);
|
|
695
|
+
if (!result.ok) {
|
|
696
|
+
throw new Error(
|
|
697
|
+
`semrush: listProjects failed on finalize: ${result.error}`
|
|
698
|
+
);
|
|
699
|
+
}
|
|
700
|
+
const projectByIdMap = /* @__PURE__ */ new Map();
|
|
701
|
+
for (const p of result.projects) {
|
|
702
|
+
const id = projectId(p);
|
|
703
|
+
if (id) projectByIdMap.set(id, p);
|
|
704
|
+
}
|
|
705
|
+
const targetIds = await resolveSetupSelection({
|
|
706
|
+
selected: state.projects,
|
|
707
|
+
allSentinel: ALL_PROJECTS,
|
|
708
|
+
fetchAll: async () => result.projects.map((p) => projectId(p)).filter((id) => id),
|
|
709
|
+
limit: SEMRUSH_SETUP_MAX_PROJECTS
|
|
710
|
+
});
|
|
711
|
+
if (!targetIds.length) {
|
|
712
|
+
sections.push("_No projects selected._", "");
|
|
713
|
+
return sections.join("\n");
|
|
714
|
+
}
|
|
715
|
+
sections.push("| Project | Domain | Created |");
|
|
716
|
+
sections.push("|---------|--------|---------|");
|
|
717
|
+
for (const id of targetIds) {
|
|
718
|
+
const p = projectByIdMap.get(id);
|
|
719
|
+
if (!p) {
|
|
720
|
+
sections.push(`| ${id} | - | - |`);
|
|
721
|
+
continue;
|
|
722
|
+
}
|
|
723
|
+
const name = projectName(p).replace(/\|/g, "\\|");
|
|
724
|
+
const domain = projectDomain(p).replace(/\|/g, "\\|") || "-";
|
|
725
|
+
const created = projectCreatedAt(p) || "-";
|
|
726
|
+
sections.push(`| ${name} | ${domain} | ${created} |`);
|
|
727
|
+
}
|
|
728
|
+
sections.push("");
|
|
729
|
+
return sections.join("\n");
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
|
|
514
733
|
// ../connectors/src/connectors/semrush/index.ts
|
|
515
734
|
var tools = { request: requestTool };
|
|
516
735
|
var semrushConnector = new ConnectorPlugin({
|
|
@@ -732,6 +951,7 @@ API \u30E6\u30CB\u30C3\u30C8\u6B8B\u91CF\u306E\u78BA\u8A8D\uFF08\u7121\u6599\u30
|
|
|
732
951
|
- \u5C65\u6B74\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u306E\u65E5\u4ED8\u306F\u5FC5\u305A\u6708\u306E15\u65E5\uFF08\`YYYYMM15\`\uFF09`
|
|
733
952
|
},
|
|
734
953
|
tools,
|
|
954
|
+
setup: (params, ctx, config) => runSetupFlow(semrushSetupFlow, params, ctx, config),
|
|
735
955
|
async checkConnection(params) {
|
|
736
956
|
try {
|
|
737
957
|
const apiKey = params["api-key"];
|
|
@@ -790,6 +1010,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
790
1010
|
import { getContext } from "hono/context-storage";
|
|
791
1011
|
import { getCookie } from "hono/cookie";
|
|
792
1012
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
1013
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
793
1014
|
function normalizeHeaders(input) {
|
|
794
1015
|
const out = {};
|
|
795
1016
|
if (!input) return out;
|
|
@@ -798,6 +1019,11 @@ function normalizeHeaders(input) {
|
|
|
798
1019
|
});
|
|
799
1020
|
return out;
|
|
800
1021
|
}
|
|
1022
|
+
function extractInputUrl(input) {
|
|
1023
|
+
if (typeof input === "string") return input;
|
|
1024
|
+
if (input instanceof URL) return input.href;
|
|
1025
|
+
return input.url;
|
|
1026
|
+
}
|
|
801
1027
|
function createSandboxProxyFetch(connectionId) {
|
|
802
1028
|
return async (input, init) => {
|
|
803
1029
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -807,10 +1033,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
807
1033
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
808
1034
|
);
|
|
809
1035
|
}
|
|
810
|
-
const originalUrl =
|
|
1036
|
+
const originalUrl = extractInputUrl(input);
|
|
1037
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
1038
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
1039
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
1040
|
+
return fetch(sessionUrl, {
|
|
1041
|
+
method: "POST",
|
|
1042
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
811
1045
|
const originalMethod = init?.method ?? "GET";
|
|
812
1046
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
813
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
814
1047
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
815
1048
|
return fetch(proxyUrl, {
|
|
816
1049
|
method: "POST",
|
|
@@ -828,18 +1061,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
828
1061
|
};
|
|
829
1062
|
}
|
|
830
1063
|
function createDeployedAppProxyFetch(connectionId) {
|
|
831
|
-
const
|
|
832
|
-
if (!
|
|
1064
|
+
const projectId2 = process.env["SQUADBASE_PROJECT_ID"];
|
|
1065
|
+
if (!projectId2) {
|
|
833
1066
|
throw new Error(
|
|
834
1067
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
835
1068
|
);
|
|
836
1069
|
}
|
|
837
1070
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
838
|
-
const proxyUrl = `https://${
|
|
1071
|
+
const proxyUrl = `https://${projectId2}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1072
|
+
const sessionUrl = `https://${projectId2}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
839
1073
|
return async (input, init) => {
|
|
840
|
-
const originalUrl =
|
|
841
|
-
const originalMethod = init?.method ?? "GET";
|
|
842
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1074
|
+
const originalUrl = extractInputUrl(input);
|
|
843
1075
|
const c = getContext();
|
|
844
1076
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
845
1077
|
if (!appSession) {
|
|
@@ -847,6 +1079,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
847
1079
|
"No authentication method available for connection proxy."
|
|
848
1080
|
);
|
|
849
1081
|
}
|
|
1082
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
1083
|
+
return fetch(sessionUrl, {
|
|
1084
|
+
method: "POST",
|
|
1085
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
const originalMethod = init?.method ?? "GET";
|
|
1089
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
850
1090
|
return fetch(proxyUrl, {
|
|
851
1091
|
method: "POST",
|
|
852
1092
|
headers: {
|