@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,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",
|
|
@@ -151,6 +163,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
151
163
|
tools;
|
|
152
164
|
query;
|
|
153
165
|
checkConnection;
|
|
166
|
+
/**
|
|
167
|
+
* SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
|
|
168
|
+
* implement this expose a step-by-step exploration flow (database/schema/
|
|
169
|
+
* table/etc. discovery) that the dashboard backend drives via the
|
|
170
|
+
* `/connections/:connectionId/setup` endpoint. Implement by delegating to
|
|
171
|
+
* `runSetupFlow` from `setup-flow.ts`.
|
|
172
|
+
*/
|
|
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;
|
|
154
188
|
constructor(config) {
|
|
155
189
|
this.slug = config.slug;
|
|
156
190
|
this.authType = config.authType;
|
|
@@ -167,6 +201,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
167
201
|
this.tools = config.tools;
|
|
168
202
|
this.query = config.query;
|
|
169
203
|
this.checkConnection = config.checkConnection;
|
|
204
|
+
this.setup = config.setup;
|
|
205
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
170
206
|
}
|
|
171
207
|
get connectorKey() {
|
|
172
208
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -231,6 +267,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
231
267
|
}
|
|
232
268
|
};
|
|
233
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
|
+
|
|
234
315
|
// ../connectors/src/auth-types.ts
|
|
235
316
|
var AUTH_TYPES = {
|
|
236
317
|
OAUTH: "oauth",
|
|
@@ -255,6 +336,114 @@ var backlogOnboarding = new ConnectorOnboarding({
|
|
|
255
336
|
}
|
|
256
337
|
});
|
|
257
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
|
+
|
|
258
447
|
// ../connectors/src/connectors/backlog/tools/request.ts
|
|
259
448
|
import { z } from "zod";
|
|
260
449
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
@@ -490,7 +679,43 @@ await backlog.request("/api/v2/issues", {
|
|
|
490
679
|
- sort: "created", "updated", "issueType", "category", "priority" \u7B49
|
|
491
680
|
- order: "asc" \u307E\u305F\u306F "desc"`
|
|
492
681
|
},
|
|
493
|
-
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
|
+
}
|
|
494
719
|
});
|
|
495
720
|
|
|
496
721
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -519,6 +744,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
519
744
|
import { getContext } from "hono/context-storage";
|
|
520
745
|
import { getCookie } from "hono/cookie";
|
|
521
746
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
747
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
522
748
|
function normalizeHeaders(input) {
|
|
523
749
|
const out = {};
|
|
524
750
|
if (!input) return out;
|
|
@@ -527,6 +753,11 @@ function normalizeHeaders(input) {
|
|
|
527
753
|
});
|
|
528
754
|
return out;
|
|
529
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
|
+
}
|
|
530
761
|
function createSandboxProxyFetch(connectionId) {
|
|
531
762
|
return async (input, init) => {
|
|
532
763
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -536,10 +767,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
536
767
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
537
768
|
);
|
|
538
769
|
}
|
|
539
|
-
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
|
+
}
|
|
540
779
|
const originalMethod = init?.method ?? "GET";
|
|
541
780
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
542
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
543
781
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
544
782
|
return fetch(proxyUrl, {
|
|
545
783
|
method: "POST",
|
|
@@ -565,10 +803,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
565
803
|
}
|
|
566
804
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
567
805
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
806
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
568
807
|
return async (input, init) => {
|
|
569
|
-
const originalUrl =
|
|
570
|
-
const originalMethod = init?.method ?? "GET";
|
|
571
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
808
|
+
const originalUrl = extractInputUrl(input);
|
|
572
809
|
const c = getContext();
|
|
573
810
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
574
811
|
if (!appSession) {
|
|
@@ -576,6 +813,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
576
813
|
"No authentication method available for connection proxy."
|
|
577
814
|
);
|
|
578
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;
|
|
579
824
|
return fetch(proxyUrl, {
|
|
580
825
|
method: "POST",
|
|
581
826
|
headers: {
|