@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,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/intercom/parameters.ts
|
|
57
|
+
init_parameter_definition();
|
|
46
58
|
var parameters = {
|
|
47
59
|
accessToken: new ParameterDefinition({
|
|
48
60
|
slug: "access-token",
|
|
@@ -214,6 +226,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
214
226
|
tools;
|
|
215
227
|
query;
|
|
216
228
|
checkConnection;
|
|
229
|
+
/**
|
|
230
|
+
* SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
|
|
231
|
+
* implement this expose a step-by-step exploration flow (database/schema/
|
|
232
|
+
* table/etc. discovery) that the dashboard backend drives via the
|
|
233
|
+
* `/connections/:connectionId/setup` endpoint. Implement by delegating to
|
|
234
|
+
* `runSetupFlow` from `setup-flow.ts`.
|
|
235
|
+
*/
|
|
236
|
+
setup;
|
|
237
|
+
/**
|
|
238
|
+
* Opt-out of the default "verify before save" behavior on connection
|
|
239
|
+
* creation. The backend invokes `checkConnection` synchronously while
|
|
240
|
+
* creating the connection and aborts (no row inserted) if it fails — this
|
|
241
|
+
* flag disables that for connectors where the check cannot succeed pre-save:
|
|
242
|
+
*
|
|
243
|
+
* - `squadbase-db` populates `connection-url` only after Neon provisioning
|
|
244
|
+
* - OAuth connectors require an OAuth-aware proxyFetch keyed by the
|
|
245
|
+
* connectionId, which doesn't exist until the row is saved
|
|
246
|
+
*
|
|
247
|
+
* Exceptions are the explicit position; new credential-input connectors get
|
|
248
|
+
* the default verify-on-create behavior without opt-in.
|
|
249
|
+
*/
|
|
250
|
+
skipConnectionCheckOnCreate;
|
|
217
251
|
constructor(config) {
|
|
218
252
|
this.slug = config.slug;
|
|
219
253
|
this.authType = config.authType;
|
|
@@ -230,6 +264,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
230
264
|
this.tools = config.tools;
|
|
231
265
|
this.query = config.query;
|
|
232
266
|
this.checkConnection = config.checkConnection;
|
|
267
|
+
this.setup = config.setup;
|
|
268
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
233
269
|
}
|
|
234
270
|
get connectorKey() {
|
|
235
271
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -294,6 +330,76 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
294
330
|
}
|
|
295
331
|
};
|
|
296
332
|
|
|
333
|
+
// ../connectors/src/setup-flow.ts
|
|
334
|
+
async function runSetupFlow(flow, params, ctx, config) {
|
|
335
|
+
const runtime = {
|
|
336
|
+
params,
|
|
337
|
+
language: ctx.language,
|
|
338
|
+
config
|
|
339
|
+
};
|
|
340
|
+
let state = flow.initialState();
|
|
341
|
+
let answerIdx = 0;
|
|
342
|
+
const pendingParameterUpdates = [];
|
|
343
|
+
for (const step of flow.steps) {
|
|
344
|
+
const ans = ctx.answers[answerIdx];
|
|
345
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
346
|
+
state = step.applyAnswer(state, ans.answer);
|
|
347
|
+
if (step.toParameterUpdates) {
|
|
348
|
+
pendingParameterUpdates.push(...step.toParameterUpdates(state));
|
|
349
|
+
}
|
|
350
|
+
answerIdx += 1;
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
354
|
+
if (step.type === "text") {
|
|
355
|
+
if (step.fetchOptions) {
|
|
356
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
357
|
+
if (options2.length === 0) {
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return {
|
|
362
|
+
type: "nextQuestion",
|
|
363
|
+
questionSlug: step.slug,
|
|
364
|
+
question: step.question[ctx.language],
|
|
365
|
+
questionType: "text",
|
|
366
|
+
allowFreeText: resolvedAllowFreeText,
|
|
367
|
+
...pendingParameterUpdates.length > 0 && {
|
|
368
|
+
parameterUpdates: pendingParameterUpdates
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
|
|
373
|
+
if (options.length === 0) {
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
return {
|
|
377
|
+
type: "nextQuestion",
|
|
378
|
+
questionSlug: step.slug,
|
|
379
|
+
question: step.question[ctx.language],
|
|
380
|
+
questionType: step.type,
|
|
381
|
+
options,
|
|
382
|
+
allowFreeText: resolvedAllowFreeText,
|
|
383
|
+
...pendingParameterUpdates.length > 0 && {
|
|
384
|
+
parameterUpdates: pendingParameterUpdates
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
389
|
+
return {
|
|
390
|
+
type: "fulfilled",
|
|
391
|
+
dataInvestigationResult,
|
|
392
|
+
...pendingParameterUpdates.length > 0 && {
|
|
393
|
+
parameterUpdates: pendingParameterUpdates
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
async function resolveSetupSelection(params) {
|
|
398
|
+
const { selected, allSentinel, fetchAll, limit } = params;
|
|
399
|
+
const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
|
|
400
|
+
return resolved.slice(0, limit);
|
|
401
|
+
}
|
|
402
|
+
|
|
297
403
|
// ../connectors/src/auth-types.ts
|
|
298
404
|
var AUTH_TYPES = {
|
|
299
405
|
OAUTH: "oauth",
|
|
@@ -318,9 +424,103 @@ var intercomOnboarding = new ConnectorOnboarding({
|
|
|
318
424
|
}
|
|
319
425
|
});
|
|
320
426
|
|
|
427
|
+
// ../connectors/src/connectors/intercom/utils.ts
|
|
428
|
+
var BASE_URL2 = "https://api.intercom.io";
|
|
429
|
+
var INTERCOM_VERSION = "2.11";
|
|
430
|
+
async function apiFetch(params, path2, init) {
|
|
431
|
+
const accessToken = params[parameters.accessToken.slug];
|
|
432
|
+
if (!accessToken) {
|
|
433
|
+
throw new Error("intercom: missing required parameter: access-token");
|
|
434
|
+
}
|
|
435
|
+
const url = `${BASE_URL2}${path2.startsWith("/") ? "" : "/"}${path2}`;
|
|
436
|
+
const headers = new Headers(init?.headers);
|
|
437
|
+
headers.set("Authorization", `Bearer ${accessToken}`);
|
|
438
|
+
headers.set("Accept", "application/json");
|
|
439
|
+
headers.set("Intercom-Version", INTERCOM_VERSION);
|
|
440
|
+
return fetch(url, { ...init, headers });
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// ../connectors/src/connectors/intercom/setup-flow.ts
|
|
444
|
+
var INTERCOM_SETUP_MAX_SCOPES = 10;
|
|
445
|
+
var INTERCOM_SCOPES = [
|
|
446
|
+
{ value: "contacts", label: "Contacts", countPath: "/contacts?per_page=1" },
|
|
447
|
+
{ value: "companies", label: "Companies", countPath: "/companies?per_page=1" },
|
|
448
|
+
{
|
|
449
|
+
value: "conversations",
|
|
450
|
+
label: "Conversations",
|
|
451
|
+
countPath: "/conversations?per_page=1"
|
|
452
|
+
},
|
|
453
|
+
{ value: "articles", label: "Articles", countPath: "/articles?per_page=1" },
|
|
454
|
+
{ value: "teams", label: "Teams", countPath: "/teams" }
|
|
455
|
+
];
|
|
456
|
+
async function fetchCount(params, path2) {
|
|
457
|
+
const res = await apiFetch(params, path2);
|
|
458
|
+
if (!res.ok) {
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
461
|
+
const data = await res.json();
|
|
462
|
+
if (typeof data.total_count === "number") return data.total_count;
|
|
463
|
+
if (Array.isArray(data.teams)) return data.teams.length;
|
|
464
|
+
if (Array.isArray(data.data)) return data.data.length;
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
var intercomSetupFlow = {
|
|
468
|
+
initialState: () => ({}),
|
|
469
|
+
steps: [
|
|
470
|
+
{
|
|
471
|
+
slug: "scopes",
|
|
472
|
+
type: "multiSelect",
|
|
473
|
+
question: {
|
|
474
|
+
ja: "\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3067\u6982\u89B3\u3057\u305F\u3044Intercom\u30C7\u30FC\u30BF\u30B9\u30B3\u30FC\u30D7\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
|
|
475
|
+
en: "Select the Intercom data scopes to include in setup (multi-select allowed)"
|
|
476
|
+
},
|
|
477
|
+
async fetchOptions(_state, _rt) {
|
|
478
|
+
return INTERCOM_SCOPES.map((s) => ({
|
|
479
|
+
value: s.value,
|
|
480
|
+
label: s.label
|
|
481
|
+
}));
|
|
482
|
+
},
|
|
483
|
+
applyAnswer: (state, answer) => ({ ...state, scopes: answer })
|
|
484
|
+
}
|
|
485
|
+
],
|
|
486
|
+
async finalize(state, rt) {
|
|
487
|
+
if (!state.scopes) {
|
|
488
|
+
throw new Error("Intercom setup: incomplete state on finalize");
|
|
489
|
+
}
|
|
490
|
+
const targetScopes = await resolveSetupSelection({
|
|
491
|
+
selected: state.scopes,
|
|
492
|
+
allSentinel: "__ALL__",
|
|
493
|
+
fetchAll: async () => INTERCOM_SCOPES.map((s) => s.value),
|
|
494
|
+
limit: INTERCOM_SETUP_MAX_SCOPES
|
|
495
|
+
});
|
|
496
|
+
const scopeByValue = new Map(INTERCOM_SCOPES.map((s) => [s.value, s]));
|
|
497
|
+
const sections = [
|
|
498
|
+
"## Intercom",
|
|
499
|
+
"",
|
|
500
|
+
"### Selected scopes",
|
|
501
|
+
"",
|
|
502
|
+
"| Scope | Count |",
|
|
503
|
+
"|-------|-------|"
|
|
504
|
+
];
|
|
505
|
+
for (const value of targetScopes) {
|
|
506
|
+
const scope = scopeByValue.get(value);
|
|
507
|
+
if (!scope) {
|
|
508
|
+
sections.push(`| ${value} | _unknown_ |`);
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
const count = await fetchCount(rt.params, scope.countPath);
|
|
512
|
+
sections.push(
|
|
513
|
+
`| ${scope.label} (${scope.value}) | ${count == null ? "-" : count} |`
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
sections.push("");
|
|
517
|
+
return sections.join("\n");
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
|
|
321
521
|
// ../connectors/src/connectors/intercom/tools/request.ts
|
|
322
522
|
import { z } from "zod";
|
|
323
|
-
var
|
|
523
|
+
var BASE_URL3 = "https://api.intercom.io";
|
|
324
524
|
var API_VERSION2 = "2.11";
|
|
325
525
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
326
526
|
var inputSchema = z.object({
|
|
@@ -370,7 +570,7 @@ The Intercom-Version header is set to 2.11 automatically.`,
|
|
|
370
570
|
);
|
|
371
571
|
try {
|
|
372
572
|
const accessToken = parameters.accessToken.getValue(connection2);
|
|
373
|
-
const url = `${
|
|
573
|
+
const url = `${BASE_URL3}${path2.startsWith("/") ? "" : "/"}${path2}`;
|
|
374
574
|
const controller = new AbortController();
|
|
375
575
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
376
576
|
try {
|
|
@@ -608,7 +808,40 @@ export default async function handler(c: Context) {
|
|
|
608
808
|
- \u8AD6\u7406\u6F14\u7B97\u5B50: \`AND\`, \`OR\`\uFF08\u8907\u6570\u30D5\u30A3\u30EB\u30BF\u306E\u7D50\u5408\uFF09
|
|
609
809
|
- \u65E5\u4ED8\u30D5\u30A3\u30FC\u30EB\u30C9\u306FUnix\u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\u3092\u4F7F\u7528`
|
|
610
810
|
},
|
|
611
|
-
tools
|
|
811
|
+
tools,
|
|
812
|
+
setup: (params, ctx, config) => runSetupFlow(intercomSetupFlow, params, ctx, config),
|
|
813
|
+
async checkConnection(params, _config) {
|
|
814
|
+
const accessToken = params[parameters.accessToken.slug];
|
|
815
|
+
if (!accessToken) {
|
|
816
|
+
return {
|
|
817
|
+
success: false,
|
|
818
|
+
error: `Missing required parameter: ${parameters.accessToken.slug}`
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
try {
|
|
822
|
+
const res = await fetch("https://api.intercom.io/me", {
|
|
823
|
+
method: "GET",
|
|
824
|
+
headers: {
|
|
825
|
+
Authorization: `Bearer ${accessToken}`,
|
|
826
|
+
"Intercom-Version": "2.11",
|
|
827
|
+
Accept: "application/json"
|
|
828
|
+
}
|
|
829
|
+
});
|
|
830
|
+
if (!res.ok) {
|
|
831
|
+
const errText = await res.text().catch(() => res.statusText);
|
|
832
|
+
return {
|
|
833
|
+
success: false,
|
|
834
|
+
error: `Intercom API failed: HTTP ${res.status} ${errText}`
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
return { success: true };
|
|
838
|
+
} catch (error) {
|
|
839
|
+
return {
|
|
840
|
+
success: false,
|
|
841
|
+
error: error instanceof Error ? error.message : String(error)
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
}
|
|
612
845
|
});
|
|
613
846
|
|
|
614
847
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -637,6 +870,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
637
870
|
import { getContext } from "hono/context-storage";
|
|
638
871
|
import { getCookie } from "hono/cookie";
|
|
639
872
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
873
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
640
874
|
function normalizeHeaders(input) {
|
|
641
875
|
const out = {};
|
|
642
876
|
if (!input) return out;
|
|
@@ -645,6 +879,11 @@ function normalizeHeaders(input) {
|
|
|
645
879
|
});
|
|
646
880
|
return out;
|
|
647
881
|
}
|
|
882
|
+
function extractInputUrl(input) {
|
|
883
|
+
if (typeof input === "string") return input;
|
|
884
|
+
if (input instanceof URL) return input.href;
|
|
885
|
+
return input.url;
|
|
886
|
+
}
|
|
648
887
|
function createSandboxProxyFetch(connectionId) {
|
|
649
888
|
return async (input, init) => {
|
|
650
889
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -654,10 +893,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
654
893
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
655
894
|
);
|
|
656
895
|
}
|
|
657
|
-
const originalUrl =
|
|
896
|
+
const originalUrl = extractInputUrl(input);
|
|
897
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
898
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
899
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
900
|
+
return fetch(sessionUrl, {
|
|
901
|
+
method: "POST",
|
|
902
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
903
|
+
});
|
|
904
|
+
}
|
|
658
905
|
const originalMethod = init?.method ?? "GET";
|
|
659
906
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
660
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
661
907
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
662
908
|
return fetch(proxyUrl, {
|
|
663
909
|
method: "POST",
|
|
@@ -683,10 +929,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
683
929
|
}
|
|
684
930
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
685
931
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
932
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
686
933
|
return async (input, init) => {
|
|
687
|
-
const originalUrl =
|
|
688
|
-
const originalMethod = init?.method ?? "GET";
|
|
689
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
934
|
+
const originalUrl = extractInputUrl(input);
|
|
690
935
|
const c = getContext();
|
|
691
936
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
692
937
|
if (!appSession) {
|
|
@@ -694,6 +939,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
694
939
|
"No authentication method available for connection proxy."
|
|
695
940
|
);
|
|
696
941
|
}
|
|
942
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
943
|
+
return fetch(sessionUrl, {
|
|
944
|
+
method: "POST",
|
|
945
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
const originalMethod = init?.method ?? "GET";
|
|
949
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
697
950
|
return fetch(proxyUrl, {
|
|
698
951
|
method: "POST",
|
|
699
952
|
headers: {
|