@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,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/backlog/parameters.ts
|
|
57
|
+
init_parameter_definition();
|
|
46
58
|
var parameters = {
|
|
47
59
|
spaceUrl: new ParameterDefinition({
|
|
48
60
|
slug: "space-url",
|
|
@@ -159,6 +171,20 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
159
171
|
* `runSetupFlow` from `setup-flow.ts`.
|
|
160
172
|
*/
|
|
161
173
|
setup;
|
|
174
|
+
/**
|
|
175
|
+
* Opt-out of the default "verify before save" behavior on connection
|
|
176
|
+
* creation. The backend invokes `checkConnection` synchronously while
|
|
177
|
+
* creating the connection and aborts (no row inserted) if it fails — this
|
|
178
|
+
* flag disables that for connectors where the check cannot succeed pre-save:
|
|
179
|
+
*
|
|
180
|
+
* - `squadbase-db` populates `connection-url` only after Neon provisioning
|
|
181
|
+
* - OAuth connectors require an OAuth-aware proxyFetch keyed by the
|
|
182
|
+
* connectionId, which doesn't exist until the row is saved
|
|
183
|
+
*
|
|
184
|
+
* Exceptions are the explicit position; new credential-input connectors get
|
|
185
|
+
* the default verify-on-create behavior without opt-in.
|
|
186
|
+
*/
|
|
187
|
+
skipConnectionCheckOnCreate;
|
|
162
188
|
constructor(config) {
|
|
163
189
|
this.slug = config.slug;
|
|
164
190
|
this.authType = config.authType;
|
|
@@ -176,6 +202,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
176
202
|
this.query = config.query;
|
|
177
203
|
this.checkConnection = config.checkConnection;
|
|
178
204
|
this.setup = config.setup;
|
|
205
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
179
206
|
}
|
|
180
207
|
get connectorKey() {
|
|
181
208
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -240,6 +267,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
240
267
|
}
|
|
241
268
|
};
|
|
242
269
|
|
|
270
|
+
// ../connectors/src/setup-flow.ts
|
|
271
|
+
async function runSetupFlow(flow, params, ctx, config) {
|
|
272
|
+
const runtime = {
|
|
273
|
+
params,
|
|
274
|
+
language: ctx.language,
|
|
275
|
+
config
|
|
276
|
+
};
|
|
277
|
+
let state = flow.initialState();
|
|
278
|
+
let answerIdx = 0;
|
|
279
|
+
for (const step of flow.steps) {
|
|
280
|
+
const ans = ctx.answers[answerIdx];
|
|
281
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
282
|
+
state = step.applyAnswer(state, ans.answer);
|
|
283
|
+
answerIdx += 1;
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
if (step.type === "text") {
|
|
287
|
+
return {
|
|
288
|
+
type: "nextQuestion",
|
|
289
|
+
questionSlug: step.slug,
|
|
290
|
+
question: step.question[ctx.language],
|
|
291
|
+
questionType: "text"
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
|
|
295
|
+
if (options.length === 0) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
type: "nextQuestion",
|
|
300
|
+
questionSlug: step.slug,
|
|
301
|
+
question: step.question[ctx.language],
|
|
302
|
+
questionType: step.type,
|
|
303
|
+
options
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
307
|
+
return { type: "fulfilled", dataInvestigationResult };
|
|
308
|
+
}
|
|
309
|
+
async function resolveSetupSelection(params) {
|
|
310
|
+
const { selected, allSentinel, fetchAll, limit } = params;
|
|
311
|
+
const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
|
|
312
|
+
return resolved.slice(0, limit);
|
|
313
|
+
}
|
|
314
|
+
|
|
243
315
|
// ../connectors/src/auth-types.ts
|
|
244
316
|
var AUTH_TYPES = {
|
|
245
317
|
OAUTH: "oauth",
|
|
@@ -264,6 +336,114 @@ var backlogOnboarding = new ConnectorOnboarding({
|
|
|
264
336
|
}
|
|
265
337
|
});
|
|
266
338
|
|
|
339
|
+
// ../connectors/src/connectors/backlog/utils.ts
|
|
340
|
+
async function apiFetch(params, path2, init) {
|
|
341
|
+
const spaceUrl = params[parameters.spaceUrl.slug];
|
|
342
|
+
const apiKey = params[parameters.apiKey.slug];
|
|
343
|
+
if (!spaceUrl) {
|
|
344
|
+
throw new Error("backlog: missing required parameter: space-url");
|
|
345
|
+
}
|
|
346
|
+
if (!apiKey) {
|
|
347
|
+
throw new Error("backlog: missing required parameter: api-key");
|
|
348
|
+
}
|
|
349
|
+
const trimmedPath = path2.replace(/^\/+/, "");
|
|
350
|
+
const separator = trimmedPath.includes("?") ? "&" : "?";
|
|
351
|
+
const url = `${spaceUrl.replace(/\/+$/, "")}/api/v2/${trimmedPath}${separator}apiKey=${encodeURIComponent(apiKey)}`;
|
|
352
|
+
const headers = new Headers(init?.headers);
|
|
353
|
+
if (!headers.has("Accept")) headers.set("Accept", "application/json");
|
|
354
|
+
return fetch(url, { ...init, headers });
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// ../connectors/src/connectors/backlog/setup-flow.ts
|
|
358
|
+
var ALL_PROJECTS = "__ALL_PROJECTS__";
|
|
359
|
+
var BACKLOG_SETUP_MAX_PROJECTS = 20;
|
|
360
|
+
async function listProjects(params) {
|
|
361
|
+
const res = await apiFetch(params, "projects?archived=false");
|
|
362
|
+
if (!res.ok) {
|
|
363
|
+
const body = await res.text().catch(() => res.statusText);
|
|
364
|
+
throw new Error(`backlog: listProjects failed (${res.status}): ${body}`);
|
|
365
|
+
}
|
|
366
|
+
return await res.json();
|
|
367
|
+
}
|
|
368
|
+
async function listIssueTypes(params, projectIdOrKey) {
|
|
369
|
+
const res = await apiFetch(
|
|
370
|
+
params,
|
|
371
|
+
`projects/${encodeURIComponent(projectIdOrKey)}/issueTypes`
|
|
372
|
+
);
|
|
373
|
+
if (!res.ok) return [];
|
|
374
|
+
return await res.json();
|
|
375
|
+
}
|
|
376
|
+
async function listStatuses(params, projectIdOrKey) {
|
|
377
|
+
const res = await apiFetch(
|
|
378
|
+
params,
|
|
379
|
+
`projects/${encodeURIComponent(projectIdOrKey)}/statuses`
|
|
380
|
+
);
|
|
381
|
+
if (!res.ok) return [];
|
|
382
|
+
return await res.json();
|
|
383
|
+
}
|
|
384
|
+
var backlogSetupFlow = {
|
|
385
|
+
initialState: () => ({}),
|
|
386
|
+
steps: [
|
|
387
|
+
{
|
|
388
|
+
slug: "projects",
|
|
389
|
+
type: "multiSelect",
|
|
390
|
+
question: {
|
|
391
|
+
ja: "\u5BFE\u8C61\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
|
|
392
|
+
en: "Select target projects (multi-select allowed)"
|
|
393
|
+
},
|
|
394
|
+
async fetchOptions(_state, rt) {
|
|
395
|
+
const projects = await listProjects(rt.params);
|
|
396
|
+
const projectOptions = projects.filter((p) => p.id != null && p.name).map((p) => ({
|
|
397
|
+
value: String(p.id),
|
|
398
|
+
label: `${p.name} (${p.projectKey})`
|
|
399
|
+
}));
|
|
400
|
+
return [
|
|
401
|
+
{
|
|
402
|
+
value: ALL_PROJECTS,
|
|
403
|
+
label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8" : "All projects"
|
|
404
|
+
},
|
|
405
|
+
...projectOptions
|
|
406
|
+
];
|
|
407
|
+
},
|
|
408
|
+
applyAnswer: (state, answer) => ({ ...state, projects: answer })
|
|
409
|
+
}
|
|
410
|
+
],
|
|
411
|
+
async finalize(state, rt) {
|
|
412
|
+
if (!state.projects) {
|
|
413
|
+
throw new Error("Backlog setup: incomplete state on finalize");
|
|
414
|
+
}
|
|
415
|
+
const allProjects = await listProjects(rt.params);
|
|
416
|
+
const projectById = new Map(
|
|
417
|
+
allProjects.map((p) => [String(p.id), p])
|
|
418
|
+
);
|
|
419
|
+
const targetIds = await resolveSetupSelection({
|
|
420
|
+
selected: state.projects,
|
|
421
|
+
allSentinel: ALL_PROJECTS,
|
|
422
|
+
fetchAll: async () => allProjects.map((p) => String(p.id)).filter((id) => id),
|
|
423
|
+
limit: BACKLOG_SETUP_MAX_PROJECTS
|
|
424
|
+
});
|
|
425
|
+
const sections = ["## Backlog", ""];
|
|
426
|
+
for (const id of targetIds) {
|
|
427
|
+
const project = projectById.get(id);
|
|
428
|
+
if (!project) {
|
|
429
|
+
sections.push(`### Project: ${id}`, "", "_Not found._", "");
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
sections.push(`### Project: ${project.name} (${project.projectKey})`, "");
|
|
433
|
+
const [issueTypes, statuses] = await Promise.all([
|
|
434
|
+
listIssueTypes(rt.params, id),
|
|
435
|
+
listStatuses(rt.params, id)
|
|
436
|
+
]);
|
|
437
|
+
sections.push(`- Issue types (${issueTypes.length}):`);
|
|
438
|
+
for (const t of issueTypes) sections.push(` - ${t.name}`);
|
|
439
|
+
sections.push(`- Statuses (${statuses.length}):`);
|
|
440
|
+
for (const s of statuses) sections.push(` - ${s.name}`);
|
|
441
|
+
sections.push("");
|
|
442
|
+
}
|
|
443
|
+
return sections.join("\n");
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
|
|
267
447
|
// ../connectors/src/connectors/backlog/tools/request.ts
|
|
268
448
|
import { z } from "zod";
|
|
269
449
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
@@ -499,7 +679,43 @@ await backlog.request("/api/v2/issues", {
|
|
|
499
679
|
- sort: "created", "updated", "issueType", "category", "priority" \u7B49
|
|
500
680
|
- order: "asc" \u307E\u305F\u306F "desc"`
|
|
501
681
|
},
|
|
502
|
-
tools
|
|
682
|
+
tools,
|
|
683
|
+
setup: (params, ctx, config) => runSetupFlow(backlogSetupFlow, params, ctx, config),
|
|
684
|
+
async checkConnection(params, _config) {
|
|
685
|
+
try {
|
|
686
|
+
const spaceUrl = params[parameters.spaceUrl.slug];
|
|
687
|
+
const apiKey = params[parameters.apiKey.slug];
|
|
688
|
+
if (!spaceUrl || !apiKey) {
|
|
689
|
+
return {
|
|
690
|
+
success: false,
|
|
691
|
+
error: "Missing required parameters: space-url and api-key"
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
const host = spaceUrl.replace(/\/+$/, "");
|
|
695
|
+
const res = await fetch(
|
|
696
|
+
`${host}/api/v2/users/myself?apiKey=${encodeURIComponent(apiKey)}`,
|
|
697
|
+
{
|
|
698
|
+
method: "GET",
|
|
699
|
+
headers: {
|
|
700
|
+
Accept: "application/json"
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
);
|
|
704
|
+
if (!res.ok) {
|
|
705
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
706
|
+
return {
|
|
707
|
+
success: false,
|
|
708
|
+
error: `Backlog API failed: HTTP ${res.status} ${errorText}`
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
return { success: true };
|
|
712
|
+
} catch (error) {
|
|
713
|
+
return {
|
|
714
|
+
success: false,
|
|
715
|
+
error: error instanceof Error ? error.message : String(error)
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
}
|
|
503
719
|
});
|
|
504
720
|
|
|
505
721
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -528,6 +744,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
528
744
|
import { getContext } from "hono/context-storage";
|
|
529
745
|
import { getCookie } from "hono/cookie";
|
|
530
746
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
747
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
531
748
|
function normalizeHeaders(input) {
|
|
532
749
|
const out = {};
|
|
533
750
|
if (!input) return out;
|
|
@@ -536,6 +753,11 @@ function normalizeHeaders(input) {
|
|
|
536
753
|
});
|
|
537
754
|
return out;
|
|
538
755
|
}
|
|
756
|
+
function extractInputUrl(input) {
|
|
757
|
+
if (typeof input === "string") return input;
|
|
758
|
+
if (input instanceof URL) return input.href;
|
|
759
|
+
return input.url;
|
|
760
|
+
}
|
|
539
761
|
function createSandboxProxyFetch(connectionId) {
|
|
540
762
|
return async (input, init) => {
|
|
541
763
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -545,10 +767,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
545
767
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
546
768
|
);
|
|
547
769
|
}
|
|
548
|
-
const originalUrl =
|
|
770
|
+
const originalUrl = extractInputUrl(input);
|
|
771
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
772
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
773
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
774
|
+
return fetch(sessionUrl, {
|
|
775
|
+
method: "POST",
|
|
776
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
777
|
+
});
|
|
778
|
+
}
|
|
549
779
|
const originalMethod = init?.method ?? "GET";
|
|
550
780
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
551
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
552
781
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
553
782
|
return fetch(proxyUrl, {
|
|
554
783
|
method: "POST",
|
|
@@ -574,10 +803,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
574
803
|
}
|
|
575
804
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
576
805
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
806
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
577
807
|
return async (input, init) => {
|
|
578
|
-
const originalUrl =
|
|
579
|
-
const originalMethod = init?.method ?? "GET";
|
|
580
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
808
|
+
const originalUrl = extractInputUrl(input);
|
|
581
809
|
const c = getContext();
|
|
582
810
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
583
811
|
if (!appSession) {
|
|
@@ -585,6 +813,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
585
813
|
"No authentication method available for connection proxy."
|
|
586
814
|
);
|
|
587
815
|
}
|
|
816
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
817
|
+
return fetch(sessionUrl, {
|
|
818
|
+
method: "POST",
|
|
819
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
const originalMethod = init?.method ?? "GET";
|
|
823
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
588
824
|
return fetch(proxyUrl, {
|
|
589
825
|
method: "POST",
|
|
590
826
|
headers: {
|