@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,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/";
|
|
@@ -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,51 @@ 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
|
+
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
|
+
|
|
194
274
|
// ../connectors/src/auth-types.ts
|
|
195
275
|
var AUTH_TYPES = {
|
|
196
276
|
OAUTH: "oauth",
|
|
@@ -371,6 +451,7 @@ var tiktokAdsOnboarding = new ConnectorOnboarding({
|
|
|
371
451
|
});
|
|
372
452
|
|
|
373
453
|
// ../connectors/src/connectors/tiktok-ads/parameters.ts
|
|
454
|
+
init_parameter_definition();
|
|
374
455
|
var parameters = {
|
|
375
456
|
advertiserId: new ParameterDefinition({
|
|
376
457
|
slug: "advertiser-id",
|
|
@@ -383,11 +464,114 @@ var parameters = {
|
|
|
383
464
|
})
|
|
384
465
|
};
|
|
385
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
|
+
|
|
386
570
|
// ../connectors/src/connectors/tiktok-ads/tools/request.ts
|
|
387
571
|
import { z as z2 } from "zod";
|
|
388
572
|
var BASE_HOST = "https://business-api.tiktok.com";
|
|
389
573
|
var BASE_PATH_SEGMENT = "/open_api/v1.3";
|
|
390
|
-
var
|
|
574
|
+
var BASE_URL4 = `${BASE_HOST}${BASE_PATH_SEGMENT}`;
|
|
391
575
|
var REQUEST_TIMEOUT_MS2 = 6e4;
|
|
392
576
|
var cachedToken2 = null;
|
|
393
577
|
async function getProxyToken2(config) {
|
|
@@ -464,7 +648,7 @@ The advertiser_id is automatically injected if configured.`,
|
|
|
464
648
|
try {
|
|
465
649
|
const advertiserId = parameters.advertiserId.tryGetValue(connection2) ?? "";
|
|
466
650
|
const normalizedPath = normalizeRequestPath(path2, BASE_PATH_SEGMENT);
|
|
467
|
-
let url = `${
|
|
651
|
+
let url = `${BASE_URL4}${normalizedPath}`;
|
|
468
652
|
if (method === "GET") {
|
|
469
653
|
const params = new URLSearchParams(queryParams ?? {});
|
|
470
654
|
if (advertiserId && !params.has("advertiser_id")) {
|
|
@@ -529,6 +713,7 @@ var tools = {
|
|
|
529
713
|
var tiktokAdsConnector = new ConnectorPlugin({
|
|
530
714
|
slug: "tiktok-ads",
|
|
531
715
|
authType: AUTH_TYPES.OAUTH,
|
|
716
|
+
skipConnectionCheckOnCreate: true,
|
|
532
717
|
name: "TikTok Ads",
|
|
533
718
|
description: "Connect to TikTok Ads for advertising campaign data and reporting using OAuth.",
|
|
534
719
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/01jHuwvmhe4ts0wj23Hxpm/afac9fa50ac5b353927900a122e898ab/tiktok.webp",
|
|
@@ -679,6 +864,7 @@ const data = await res.json();
|
|
|
679
864
|
\`\`\``
|
|
680
865
|
},
|
|
681
866
|
tools,
|
|
867
|
+
setup: (params, ctx, config) => runSetupFlow(tiktokAdsSetupFlow, params, ctx, config),
|
|
682
868
|
async checkConnection(_params, config) {
|
|
683
869
|
const { proxyFetch } = config;
|
|
684
870
|
try {
|
|
@@ -733,6 +919,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
733
919
|
import { getContext } from "hono/context-storage";
|
|
734
920
|
import { getCookie } from "hono/cookie";
|
|
735
921
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
922
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
736
923
|
function normalizeHeaders(input) {
|
|
737
924
|
const out = {};
|
|
738
925
|
if (!input) return out;
|
|
@@ -741,6 +928,11 @@ function normalizeHeaders(input) {
|
|
|
741
928
|
});
|
|
742
929
|
return out;
|
|
743
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
|
+
}
|
|
744
936
|
function createSandboxProxyFetch(connectionId) {
|
|
745
937
|
return async (input, init) => {
|
|
746
938
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -750,10 +942,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
750
942
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
751
943
|
);
|
|
752
944
|
}
|
|
753
|
-
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
|
+
}
|
|
754
954
|
const originalMethod = init?.method ?? "GET";
|
|
755
955
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
756
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
757
956
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
758
957
|
return fetch(proxyUrl, {
|
|
759
958
|
method: "POST",
|
|
@@ -779,10 +978,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
779
978
|
}
|
|
780
979
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
781
980
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
981
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
782
982
|
return async (input, init) => {
|
|
783
|
-
const originalUrl =
|
|
784
|
-
const originalMethod = init?.method ?? "GET";
|
|
785
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
983
|
+
const originalUrl = extractInputUrl(input);
|
|
786
984
|
const c = getContext();
|
|
787
985
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
788
986
|
if (!appSession) {
|
|
@@ -790,6 +988,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
790
988
|
"No authentication method available for connection proxy."
|
|
791
989
|
);
|
|
792
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;
|
|
793
999
|
return fetch(proxyUrl, {
|
|
794
1000
|
method: "POST",
|
|
795
1001
|
headers: {
|