@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/tiktok-ads/sdk/index.ts
|
|
46
57
|
var BASE_URL = "https://business-api.tiktok.com/open_api/v1.3/";
|
|
@@ -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",
|
|
@@ -380,6 +451,7 @@ var tiktokAdsOnboarding = new ConnectorOnboarding({
|
|
|
380
451
|
});
|
|
381
452
|
|
|
382
453
|
// ../connectors/src/connectors/tiktok-ads/parameters.ts
|
|
454
|
+
init_parameter_definition();
|
|
383
455
|
var parameters = {
|
|
384
456
|
advertiserId: new ParameterDefinition({
|
|
385
457
|
slug: "advertiser-id",
|
|
@@ -392,11 +464,114 @@ var parameters = {
|
|
|
392
464
|
})
|
|
393
465
|
};
|
|
394
466
|
|
|
467
|
+
// ../connectors/src/connectors/tiktok-ads/setup-flow.ts
|
|
468
|
+
var BASE_URL3 = "https://business-api.tiktok.com/open_api/v1.3";
|
|
469
|
+
var ALL_ADVERTISERS = "__ALL_ADVERTISERS__";
|
|
470
|
+
var TIKTOK_ADS_SETUP_MAX_ADVERTISERS = 10;
|
|
471
|
+
async function listAdvertisers(proxyFetch) {
|
|
472
|
+
const res = await proxyFetch(`${BASE_URL3}/oauth2/advertiser/get/`, {
|
|
473
|
+
method: "GET"
|
|
474
|
+
});
|
|
475
|
+
if (!res.ok) {
|
|
476
|
+
const body = await res.text().catch(() => res.statusText);
|
|
477
|
+
throw new Error(
|
|
478
|
+
`tiktok-ads: oauth2/advertiser/get failed (${res.status}): ${body}`
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
const data = await res.json();
|
|
482
|
+
if (data.code !== void 0 && data.code !== 0) {
|
|
483
|
+
throw new Error(
|
|
484
|
+
`tiktok-ads: oauth2/advertiser/get error code ${data.code}: ${data.message ?? ""}`
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
return data.data?.list ?? [];
|
|
488
|
+
}
|
|
489
|
+
async function fetchAdvertiserInfo(proxyFetch, advertiserId) {
|
|
490
|
+
const advertiserIdsParam = encodeURIComponent(
|
|
491
|
+
JSON.stringify([advertiserId])
|
|
492
|
+
);
|
|
493
|
+
const url = `${BASE_URL3}/advertiser/info/?advertiser_ids=${advertiserIdsParam}`;
|
|
494
|
+
try {
|
|
495
|
+
const res = await proxyFetch(url, { method: "GET" });
|
|
496
|
+
if (!res.ok) {
|
|
497
|
+
return { advertiser_id: advertiserId };
|
|
498
|
+
}
|
|
499
|
+
const data = await res.json();
|
|
500
|
+
if (Array.isArray(data.data)) {
|
|
501
|
+
return data.data[0] ?? { advertiser_id: advertiserId };
|
|
502
|
+
}
|
|
503
|
+
return data.data?.list?.[0] ?? { advertiser_id: advertiserId };
|
|
504
|
+
} catch {
|
|
505
|
+
return { advertiser_id: advertiserId };
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
var tiktokAdsSetupFlow = {
|
|
509
|
+
initialState: () => ({}),
|
|
510
|
+
steps: [
|
|
511
|
+
{
|
|
512
|
+
slug: "advertisers",
|
|
513
|
+
type: "multiSelect",
|
|
514
|
+
question: {
|
|
515
|
+
ja: "\u5BFE\u8C61\u306E TikTok \u5E83\u544A\u4E3B\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
|
|
516
|
+
en: "Select target TikTok advertisers (multi-select allowed)"
|
|
517
|
+
},
|
|
518
|
+
async fetchOptions(_state, rt) {
|
|
519
|
+
const advertisers = await listAdvertisers(rt.config.proxyFetch);
|
|
520
|
+
const options = advertisers.map((a) => {
|
|
521
|
+
const id = String(a.advertiser_id ?? "");
|
|
522
|
+
if (!id) return null;
|
|
523
|
+
const label = a.advertiser_name ? `${a.advertiser_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_ADVERTISERS,
|
|
530
|
+
label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u5E83\u544A\u4E3B" : "All advertisers"
|
|
531
|
+
},
|
|
532
|
+
...options
|
|
533
|
+
];
|
|
534
|
+
},
|
|
535
|
+
applyAnswer: (state, answer) => ({ ...state, advertisers: answer })
|
|
536
|
+
}
|
|
537
|
+
],
|
|
538
|
+
async finalize(state, rt) {
|
|
539
|
+
if (!state.advertisers) {
|
|
540
|
+
throw new Error("TikTok Ads setup: incomplete state on finalize");
|
|
541
|
+
}
|
|
542
|
+
const targetIds = await resolveSetupSelection({
|
|
543
|
+
selected: state.advertisers,
|
|
544
|
+
allSentinel: ALL_ADVERTISERS,
|
|
545
|
+
fetchAll: async () => (await listAdvertisers(rt.config.proxyFetch)).map((a) => String(a.advertiser_id ?? "")).filter((id) => id),
|
|
546
|
+
limit: TIKTOK_ADS_SETUP_MAX_ADVERTISERS
|
|
547
|
+
});
|
|
548
|
+
const sections = ["## TikTok Ads", ""];
|
|
549
|
+
if (targetIds.length === 0) {
|
|
550
|
+
sections.push("_No advertisers selected._", "");
|
|
551
|
+
return sections.join("\n");
|
|
552
|
+
}
|
|
553
|
+
sections.push("| Advertiser ID | Name | Currency | Status | Time Zone |");
|
|
554
|
+
sections.push("|---------------|------|----------|--------|-----------|");
|
|
555
|
+
for (const id of targetIds) {
|
|
556
|
+
const info = await fetchAdvertiserInfo(rt.config.proxyFetch, id);
|
|
557
|
+
const name = (info.name ?? "-").replace(/\|/g, "\\|");
|
|
558
|
+
const currency = info.currency ?? "-";
|
|
559
|
+
const status = info.status ?? "-";
|
|
560
|
+
const timeZone = info.display_timezone ?? "-";
|
|
561
|
+
sections.push(
|
|
562
|
+
`| ${id} | ${name} | ${currency} | ${status} | ${timeZone} |`
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
sections.push("");
|
|
566
|
+
return sections.join("\n");
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
|
|
395
570
|
// ../connectors/src/connectors/tiktok-ads/tools/request.ts
|
|
396
571
|
import { z as z2 } from "zod";
|
|
397
572
|
var BASE_HOST = "https://business-api.tiktok.com";
|
|
398
573
|
var BASE_PATH_SEGMENT = "/open_api/v1.3";
|
|
399
|
-
var
|
|
574
|
+
var BASE_URL4 = `${BASE_HOST}${BASE_PATH_SEGMENT}`;
|
|
400
575
|
var REQUEST_TIMEOUT_MS2 = 6e4;
|
|
401
576
|
var cachedToken2 = null;
|
|
402
577
|
async function getProxyToken2(config) {
|
|
@@ -473,7 +648,7 @@ The advertiser_id is automatically injected if configured.`,
|
|
|
473
648
|
try {
|
|
474
649
|
const advertiserId = parameters.advertiserId.tryGetValue(connection2) ?? "";
|
|
475
650
|
const normalizedPath = normalizeRequestPath(path2, BASE_PATH_SEGMENT);
|
|
476
|
-
let url = `${
|
|
651
|
+
let url = `${BASE_URL4}${normalizedPath}`;
|
|
477
652
|
if (method === "GET") {
|
|
478
653
|
const params = new URLSearchParams(queryParams ?? {});
|
|
479
654
|
if (advertiserId && !params.has("advertiser_id")) {
|
|
@@ -538,6 +713,7 @@ var tools = {
|
|
|
538
713
|
var tiktokAdsConnector = new ConnectorPlugin({
|
|
539
714
|
slug: "tiktok-ads",
|
|
540
715
|
authType: AUTH_TYPES.OAUTH,
|
|
716
|
+
skipConnectionCheckOnCreate: true,
|
|
541
717
|
name: "TikTok Ads",
|
|
542
718
|
description: "Connect to TikTok Ads for advertising campaign data and reporting using OAuth.",
|
|
543
719
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/01jHuwvmhe4ts0wj23Hxpm/afac9fa50ac5b353927900a122e898ab/tiktok.webp",
|
|
@@ -688,6 +864,7 @@ const data = await res.json();
|
|
|
688
864
|
\`\`\``
|
|
689
865
|
},
|
|
690
866
|
tools,
|
|
867
|
+
setup: (params, ctx, config) => runSetupFlow(tiktokAdsSetupFlow, params, ctx, config),
|
|
691
868
|
async checkConnection(_params, config) {
|
|
692
869
|
const { proxyFetch } = config;
|
|
693
870
|
try {
|
|
@@ -742,6 +919,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
742
919
|
import { getContext } from "hono/context-storage";
|
|
743
920
|
import { getCookie } from "hono/cookie";
|
|
744
921
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
922
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
745
923
|
function normalizeHeaders(input) {
|
|
746
924
|
const out = {};
|
|
747
925
|
if (!input) return out;
|
|
@@ -750,6 +928,11 @@ function normalizeHeaders(input) {
|
|
|
750
928
|
});
|
|
751
929
|
return out;
|
|
752
930
|
}
|
|
931
|
+
function extractInputUrl(input) {
|
|
932
|
+
if (typeof input === "string") return input;
|
|
933
|
+
if (input instanceof URL) return input.href;
|
|
934
|
+
return input.url;
|
|
935
|
+
}
|
|
753
936
|
function createSandboxProxyFetch(connectionId) {
|
|
754
937
|
return async (input, init) => {
|
|
755
938
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -759,10 +942,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
759
942
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
760
943
|
);
|
|
761
944
|
}
|
|
762
|
-
const originalUrl =
|
|
945
|
+
const originalUrl = extractInputUrl(input);
|
|
946
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
947
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
948
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
949
|
+
return fetch(sessionUrl, {
|
|
950
|
+
method: "POST",
|
|
951
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
952
|
+
});
|
|
953
|
+
}
|
|
763
954
|
const originalMethod = init?.method ?? "GET";
|
|
764
955
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
765
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
766
956
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
767
957
|
return fetch(proxyUrl, {
|
|
768
958
|
method: "POST",
|
|
@@ -788,10 +978,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
788
978
|
}
|
|
789
979
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
790
980
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
981
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
791
982
|
return async (input, init) => {
|
|
792
|
-
const originalUrl =
|
|
793
|
-
const originalMethod = init?.method ?? "GET";
|
|
794
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
983
|
+
const originalUrl = extractInputUrl(input);
|
|
795
984
|
const c = getContext();
|
|
796
985
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
797
986
|
if (!appSession) {
|
|
@@ -799,6 +988,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
799
988
|
"No authentication method available for connection proxy."
|
|
800
989
|
);
|
|
801
990
|
}
|
|
991
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
992
|
+
return fetch(sessionUrl, {
|
|
993
|
+
method: "POST",
|
|
994
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
const originalMethod = init?.method ?? "GET";
|
|
998
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
802
999
|
return fetch(proxyUrl, {
|
|
803
1000
|
method: "POST",
|
|
804
1001
|
headers: {
|