@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/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,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",
|
|
@@ -371,6 +476,7 @@ var tiktokAdsOnboarding = new ConnectorOnboarding({
|
|
|
371
476
|
});
|
|
372
477
|
|
|
373
478
|
// ../connectors/src/connectors/tiktok-ads/parameters.ts
|
|
479
|
+
init_parameter_definition();
|
|
374
480
|
var parameters = {
|
|
375
481
|
advertiserId: new ParameterDefinition({
|
|
376
482
|
slug: "advertiser-id",
|
|
@@ -383,11 +489,114 @@ var parameters = {
|
|
|
383
489
|
})
|
|
384
490
|
};
|
|
385
491
|
|
|
492
|
+
// ../connectors/src/connectors/tiktok-ads/setup-flow.ts
|
|
493
|
+
var BASE_URL3 = "https://business-api.tiktok.com/open_api/v1.3";
|
|
494
|
+
var ALL_ADVERTISERS = "__ALL_ADVERTISERS__";
|
|
495
|
+
var TIKTOK_ADS_SETUP_MAX_ADVERTISERS = 10;
|
|
496
|
+
async function listAdvertisers(proxyFetch) {
|
|
497
|
+
const res = await proxyFetch(`${BASE_URL3}/oauth2/advertiser/get/`, {
|
|
498
|
+
method: "GET"
|
|
499
|
+
});
|
|
500
|
+
if (!res.ok) {
|
|
501
|
+
const body = await res.text().catch(() => res.statusText);
|
|
502
|
+
throw new Error(
|
|
503
|
+
`tiktok-ads: oauth2/advertiser/get failed (${res.status}): ${body}`
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
const data = await res.json();
|
|
507
|
+
if (data.code !== void 0 && data.code !== 0) {
|
|
508
|
+
throw new Error(
|
|
509
|
+
`tiktok-ads: oauth2/advertiser/get error code ${data.code}: ${data.message ?? ""}`
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
return data.data?.list ?? [];
|
|
513
|
+
}
|
|
514
|
+
async function fetchAdvertiserInfo(proxyFetch, advertiserId) {
|
|
515
|
+
const advertiserIdsParam = encodeURIComponent(
|
|
516
|
+
JSON.stringify([advertiserId])
|
|
517
|
+
);
|
|
518
|
+
const url = `${BASE_URL3}/advertiser/info/?advertiser_ids=${advertiserIdsParam}`;
|
|
519
|
+
try {
|
|
520
|
+
const res = await proxyFetch(url, { method: "GET" });
|
|
521
|
+
if (!res.ok) {
|
|
522
|
+
return { advertiser_id: advertiserId };
|
|
523
|
+
}
|
|
524
|
+
const data = await res.json();
|
|
525
|
+
if (Array.isArray(data.data)) {
|
|
526
|
+
return data.data[0] ?? { advertiser_id: advertiserId };
|
|
527
|
+
}
|
|
528
|
+
return data.data?.list?.[0] ?? { advertiser_id: advertiserId };
|
|
529
|
+
} catch {
|
|
530
|
+
return { advertiser_id: advertiserId };
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
var tiktokAdsSetupFlow = {
|
|
534
|
+
initialState: () => ({}),
|
|
535
|
+
steps: [
|
|
536
|
+
{
|
|
537
|
+
slug: "advertisers",
|
|
538
|
+
type: "multiSelect",
|
|
539
|
+
question: {
|
|
540
|
+
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",
|
|
541
|
+
en: "Select target TikTok advertisers (multi-select allowed)"
|
|
542
|
+
},
|
|
543
|
+
async fetchOptions(_state, rt) {
|
|
544
|
+
const advertisers = await listAdvertisers(rt.config.proxyFetch);
|
|
545
|
+
const options = advertisers.map((a) => {
|
|
546
|
+
const id = String(a.advertiser_id ?? "");
|
|
547
|
+
if (!id) return null;
|
|
548
|
+
const label = a.advertiser_name ? `${a.advertiser_name} (${id})` : id;
|
|
549
|
+
return { value: id, label };
|
|
550
|
+
}).filter((v) => v != null);
|
|
551
|
+
if (options.length === 0) return [];
|
|
552
|
+
return [
|
|
553
|
+
{
|
|
554
|
+
value: ALL_ADVERTISERS,
|
|
555
|
+
label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u5E83\u544A\u4E3B" : "All advertisers"
|
|
556
|
+
},
|
|
557
|
+
...options
|
|
558
|
+
];
|
|
559
|
+
},
|
|
560
|
+
applyAnswer: (state, answer) => ({ ...state, advertisers: answer })
|
|
561
|
+
}
|
|
562
|
+
],
|
|
563
|
+
async finalize(state, rt) {
|
|
564
|
+
if (!state.advertisers) {
|
|
565
|
+
throw new Error("TikTok Ads setup: incomplete state on finalize");
|
|
566
|
+
}
|
|
567
|
+
const targetIds = await resolveSetupSelection({
|
|
568
|
+
selected: state.advertisers,
|
|
569
|
+
allSentinel: ALL_ADVERTISERS,
|
|
570
|
+
fetchAll: async () => (await listAdvertisers(rt.config.proxyFetch)).map((a) => String(a.advertiser_id ?? "")).filter((id) => id),
|
|
571
|
+
limit: TIKTOK_ADS_SETUP_MAX_ADVERTISERS
|
|
572
|
+
});
|
|
573
|
+
const sections = ["## TikTok Ads", ""];
|
|
574
|
+
if (targetIds.length === 0) {
|
|
575
|
+
sections.push("_No advertisers selected._", "");
|
|
576
|
+
return sections.join("\n");
|
|
577
|
+
}
|
|
578
|
+
sections.push("| Advertiser ID | Name | Currency | Status | Time Zone |");
|
|
579
|
+
sections.push("|---------------|------|----------|--------|-----------|");
|
|
580
|
+
for (const id of targetIds) {
|
|
581
|
+
const info = await fetchAdvertiserInfo(rt.config.proxyFetch, id);
|
|
582
|
+
const name = (info.name ?? "-").replace(/\|/g, "\\|");
|
|
583
|
+
const currency = info.currency ?? "-";
|
|
584
|
+
const status = info.status ?? "-";
|
|
585
|
+
const timeZone = info.display_timezone ?? "-";
|
|
586
|
+
sections.push(
|
|
587
|
+
`| ${id} | ${name} | ${currency} | ${status} | ${timeZone} |`
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
sections.push("");
|
|
591
|
+
return sections.join("\n");
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
|
|
386
595
|
// ../connectors/src/connectors/tiktok-ads/tools/request.ts
|
|
387
596
|
import { z as z2 } from "zod";
|
|
388
597
|
var BASE_HOST = "https://business-api.tiktok.com";
|
|
389
598
|
var BASE_PATH_SEGMENT = "/open_api/v1.3";
|
|
390
|
-
var
|
|
599
|
+
var BASE_URL4 = `${BASE_HOST}${BASE_PATH_SEGMENT}`;
|
|
391
600
|
var REQUEST_TIMEOUT_MS2 = 6e4;
|
|
392
601
|
var cachedToken2 = null;
|
|
393
602
|
async function getProxyToken2(config) {
|
|
@@ -464,7 +673,7 @@ The advertiser_id is automatically injected if configured.`,
|
|
|
464
673
|
try {
|
|
465
674
|
const advertiserId = parameters.advertiserId.tryGetValue(connection2) ?? "";
|
|
466
675
|
const normalizedPath = normalizeRequestPath(path2, BASE_PATH_SEGMENT);
|
|
467
|
-
let url = `${
|
|
676
|
+
let url = `${BASE_URL4}${normalizedPath}`;
|
|
468
677
|
if (method === "GET") {
|
|
469
678
|
const params = new URLSearchParams(queryParams ?? {});
|
|
470
679
|
if (advertiserId && !params.has("advertiser_id")) {
|
|
@@ -529,6 +738,7 @@ var tools = {
|
|
|
529
738
|
var tiktokAdsConnector = new ConnectorPlugin({
|
|
530
739
|
slug: "tiktok-ads",
|
|
531
740
|
authType: AUTH_TYPES.OAUTH,
|
|
741
|
+
skipConnectionCheckOnCreate: true,
|
|
532
742
|
name: "TikTok Ads",
|
|
533
743
|
description: "Connect to TikTok Ads for advertising campaign data and reporting using OAuth.",
|
|
534
744
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/01jHuwvmhe4ts0wj23Hxpm/afac9fa50ac5b353927900a122e898ab/tiktok.webp",
|
|
@@ -679,6 +889,7 @@ const data = await res.json();
|
|
|
679
889
|
\`\`\``
|
|
680
890
|
},
|
|
681
891
|
tools,
|
|
892
|
+
setup: (params, ctx, config) => runSetupFlow(tiktokAdsSetupFlow, params, ctx, config),
|
|
682
893
|
async checkConnection(_params, config) {
|
|
683
894
|
const { proxyFetch } = config;
|
|
684
895
|
try {
|
|
@@ -733,6 +944,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
733
944
|
import { getContext } from "hono/context-storage";
|
|
734
945
|
import { getCookie } from "hono/cookie";
|
|
735
946
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
947
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
736
948
|
function normalizeHeaders(input) {
|
|
737
949
|
const out = {};
|
|
738
950
|
if (!input) return out;
|
|
@@ -741,6 +953,11 @@ function normalizeHeaders(input) {
|
|
|
741
953
|
});
|
|
742
954
|
return out;
|
|
743
955
|
}
|
|
956
|
+
function extractInputUrl(input) {
|
|
957
|
+
if (typeof input === "string") return input;
|
|
958
|
+
if (input instanceof URL) return input.href;
|
|
959
|
+
return input.url;
|
|
960
|
+
}
|
|
744
961
|
function createSandboxProxyFetch(connectionId) {
|
|
745
962
|
return async (input, init) => {
|
|
746
963
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -750,10 +967,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
750
967
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
751
968
|
);
|
|
752
969
|
}
|
|
753
|
-
const originalUrl =
|
|
970
|
+
const originalUrl = extractInputUrl(input);
|
|
971
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
972
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
973
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
974
|
+
return fetch(sessionUrl, {
|
|
975
|
+
method: "POST",
|
|
976
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
977
|
+
});
|
|
978
|
+
}
|
|
754
979
|
const originalMethod = init?.method ?? "GET";
|
|
755
980
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
756
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
757
981
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
758
982
|
return fetch(proxyUrl, {
|
|
759
983
|
method: "POST",
|
|
@@ -779,10 +1003,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
779
1003
|
}
|
|
780
1004
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
781
1005
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1006
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
782
1007
|
return async (input, init) => {
|
|
783
|
-
const originalUrl =
|
|
784
|
-
const originalMethod = init?.method ?? "GET";
|
|
785
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1008
|
+
const originalUrl = extractInputUrl(input);
|
|
786
1009
|
const c = getContext();
|
|
787
1010
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
788
1011
|
if (!appSession) {
|
|
@@ -790,6 +1013,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
790
1013
|
"No authentication method available for connection proxy."
|
|
791
1014
|
);
|
|
792
1015
|
}
|
|
1016
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
1017
|
+
return fetch(sessionUrl, {
|
|
1018
|
+
method: "POST",
|
|
1019
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
const originalMethod = init?.method ?? "GET";
|
|
1023
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
793
1024
|
return fetch(proxyUrl, {
|
|
794
1025
|
method: "POST",
|
|
795
1026
|
headers: {
|