@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/clickup/parameters.ts
|
|
57
|
+
init_parameter_definition();
|
|
46
58
|
var parameters = {
|
|
47
59
|
apiToken: new ParameterDefinition({
|
|
48
60
|
slug: "api-token",
|
|
@@ -295,6 +307,20 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
295
307
|
* `runSetupFlow` from `setup-flow.ts`.
|
|
296
308
|
*/
|
|
297
309
|
setup;
|
|
310
|
+
/**
|
|
311
|
+
* Opt-out of the default "verify before save" behavior on connection
|
|
312
|
+
* creation. The backend invokes `checkConnection` synchronously while
|
|
313
|
+
* creating the connection and aborts (no row inserted) if it fails — this
|
|
314
|
+
* flag disables that for connectors where the check cannot succeed pre-save:
|
|
315
|
+
*
|
|
316
|
+
* - `squadbase-db` populates `connection-url` only after Neon provisioning
|
|
317
|
+
* - OAuth connectors require an OAuth-aware proxyFetch keyed by the
|
|
318
|
+
* connectionId, which doesn't exist until the row is saved
|
|
319
|
+
*
|
|
320
|
+
* Exceptions are the explicit position; new credential-input connectors get
|
|
321
|
+
* the default verify-on-create behavior without opt-in.
|
|
322
|
+
*/
|
|
323
|
+
skipConnectionCheckOnCreate;
|
|
298
324
|
constructor(config) {
|
|
299
325
|
this.slug = config.slug;
|
|
300
326
|
this.authType = config.authType;
|
|
@@ -312,6 +338,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
312
338
|
this.query = config.query;
|
|
313
339
|
this.checkConnection = config.checkConnection;
|
|
314
340
|
this.setup = config.setup;
|
|
341
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
315
342
|
}
|
|
316
343
|
get connectorKey() {
|
|
317
344
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -376,6 +403,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
376
403
|
}
|
|
377
404
|
};
|
|
378
405
|
|
|
406
|
+
// ../connectors/src/setup-flow.ts
|
|
407
|
+
async function runSetupFlow(flow, params, ctx, config) {
|
|
408
|
+
const runtime = {
|
|
409
|
+
params,
|
|
410
|
+
language: ctx.language,
|
|
411
|
+
config
|
|
412
|
+
};
|
|
413
|
+
let state = flow.initialState();
|
|
414
|
+
let answerIdx = 0;
|
|
415
|
+
for (const step of flow.steps) {
|
|
416
|
+
const ans = ctx.answers[answerIdx];
|
|
417
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
418
|
+
state = step.applyAnswer(state, ans.answer);
|
|
419
|
+
answerIdx += 1;
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
if (step.type === "text") {
|
|
423
|
+
return {
|
|
424
|
+
type: "nextQuestion",
|
|
425
|
+
questionSlug: step.slug,
|
|
426
|
+
question: step.question[ctx.language],
|
|
427
|
+
questionType: "text"
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
|
|
431
|
+
if (options.length === 0) {
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
return {
|
|
435
|
+
type: "nextQuestion",
|
|
436
|
+
questionSlug: step.slug,
|
|
437
|
+
question: step.question[ctx.language],
|
|
438
|
+
questionType: step.type,
|
|
439
|
+
options
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
443
|
+
return { type: "fulfilled", dataInvestigationResult };
|
|
444
|
+
}
|
|
445
|
+
async function resolveSetupSelection(params) {
|
|
446
|
+
const { selected, allSentinel, fetchAll, limit } = params;
|
|
447
|
+
const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
|
|
448
|
+
return resolved.slice(0, limit);
|
|
449
|
+
}
|
|
450
|
+
|
|
379
451
|
// ../connectors/src/auth-types.ts
|
|
380
452
|
var AUTH_TYPES = {
|
|
381
453
|
OAUTH: "oauth",
|
|
@@ -412,11 +484,142 @@ var clickupOnboarding = new ConnectorOnboarding({
|
|
|
412
484
|
}
|
|
413
485
|
});
|
|
414
486
|
|
|
487
|
+
// ../connectors/src/connectors/clickup/utils.ts
|
|
488
|
+
var BASE_URL2 = "https://api.clickup.com/api/v2";
|
|
489
|
+
async function apiFetch(params, path2, init) {
|
|
490
|
+
const token = params[parameters.apiToken.slug];
|
|
491
|
+
if (!token) {
|
|
492
|
+
throw new Error("clickup: missing required parameter: api-token");
|
|
493
|
+
}
|
|
494
|
+
const url = `${BASE_URL2}${path2.startsWith("/") ? "" : "/"}${path2}`;
|
|
495
|
+
const headers = new Headers(init?.headers);
|
|
496
|
+
headers.set("Authorization", token);
|
|
497
|
+
if (!headers.has("Accept")) headers.set("Accept", "application/json");
|
|
498
|
+
return fetch(url, { ...init, headers });
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// ../connectors/src/connectors/clickup/setup-flow.ts
|
|
502
|
+
var ALL_SPACES = "__ALL_SPACES__";
|
|
503
|
+
var CLICKUP_SETUP_MAX_SPACES = 10;
|
|
504
|
+
async function listTeams(params) {
|
|
505
|
+
const res = await apiFetch(params, "/team");
|
|
506
|
+
if (!res.ok) {
|
|
507
|
+
const body = await res.text().catch(() => res.statusText);
|
|
508
|
+
throw new Error(`clickup: listTeams failed (${res.status}): ${body}`);
|
|
509
|
+
}
|
|
510
|
+
const data = await res.json();
|
|
511
|
+
return data.teams ?? [];
|
|
512
|
+
}
|
|
513
|
+
async function listSpaces(params, teamId) {
|
|
514
|
+
const res = await apiFetch(
|
|
515
|
+
params,
|
|
516
|
+
`/team/${encodeURIComponent(teamId)}/space?archived=false`
|
|
517
|
+
);
|
|
518
|
+
if (!res.ok) {
|
|
519
|
+
const body = await res.text().catch(() => res.statusText);
|
|
520
|
+
throw new Error(`clickup: listSpaces failed (${res.status}): ${body}`);
|
|
521
|
+
}
|
|
522
|
+
const data = await res.json();
|
|
523
|
+
return data.spaces ?? [];
|
|
524
|
+
}
|
|
525
|
+
async function listFolders(params, spaceId) {
|
|
526
|
+
const res = await apiFetch(
|
|
527
|
+
params,
|
|
528
|
+
`/space/${encodeURIComponent(spaceId)}/folder?archived=false`
|
|
529
|
+
);
|
|
530
|
+
if (!res.ok) return [];
|
|
531
|
+
const data = await res.json();
|
|
532
|
+
return data.folders ?? [];
|
|
533
|
+
}
|
|
534
|
+
async function listFolderlessLists(params, spaceId) {
|
|
535
|
+
const res = await apiFetch(
|
|
536
|
+
params,
|
|
537
|
+
`/space/${encodeURIComponent(spaceId)}/list?archived=false`
|
|
538
|
+
);
|
|
539
|
+
if (!res.ok) return [];
|
|
540
|
+
const data = await res.json();
|
|
541
|
+
return data.lists ?? [];
|
|
542
|
+
}
|
|
543
|
+
var clickupSetupFlow = {
|
|
544
|
+
initialState: () => ({}),
|
|
545
|
+
steps: [
|
|
546
|
+
{
|
|
547
|
+
slug: "workspace",
|
|
548
|
+
type: "select",
|
|
549
|
+
question: {
|
|
550
|
+
ja: "\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u306B\u4F7F\u3046\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044",
|
|
551
|
+
en: "Select the workspace to use for setup"
|
|
552
|
+
},
|
|
553
|
+
async fetchOptions(_state, rt) {
|
|
554
|
+
const teams = await listTeams(rt.params);
|
|
555
|
+
return teams.filter((t) => t.id && t.name).map((t) => ({ value: t.id, label: t.name }));
|
|
556
|
+
},
|
|
557
|
+
applyAnswer: (state, answer) => ({ ...state, workspace: answer[0] })
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
slug: "spaces",
|
|
561
|
+
type: "multiSelect",
|
|
562
|
+
question: {
|
|
563
|
+
ja: "\u5BFE\u8C61\u306E\u30B9\u30DA\u30FC\u30B9\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
|
|
564
|
+
en: "Select target spaces (multi-select allowed)"
|
|
565
|
+
},
|
|
566
|
+
async fetchOptions(state, rt) {
|
|
567
|
+
if (!state.workspace) return [];
|
|
568
|
+
const spaces = await listSpaces(rt.params, state.workspace);
|
|
569
|
+
const spaceOptions = spaces.filter((s) => s.id && s.name).map((s) => ({ value: s.id, label: s.name }));
|
|
570
|
+
return [
|
|
571
|
+
{
|
|
572
|
+
value: ALL_SPACES,
|
|
573
|
+
label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u30B9\u30DA\u30FC\u30B9" : "All spaces"
|
|
574
|
+
},
|
|
575
|
+
...spaceOptions
|
|
576
|
+
];
|
|
577
|
+
},
|
|
578
|
+
applyAnswer: (state, answer) => ({ ...state, spaces: answer })
|
|
579
|
+
}
|
|
580
|
+
],
|
|
581
|
+
async finalize(state, rt) {
|
|
582
|
+
if (!state.workspace || !state.spaces) {
|
|
583
|
+
throw new Error("ClickUp setup: incomplete state on finalize");
|
|
584
|
+
}
|
|
585
|
+
const teamId = state.workspace;
|
|
586
|
+
const allSpaces = await listSpaces(rt.params, teamId);
|
|
587
|
+
const spaceById = new Map(allSpaces.map((s) => [s.id, s]));
|
|
588
|
+
const targetSpaceIds = await resolveSetupSelection({
|
|
589
|
+
selected: state.spaces,
|
|
590
|
+
allSentinel: ALL_SPACES,
|
|
591
|
+
fetchAll: async () => allSpaces.map((s) => s.id).filter((id) => id),
|
|
592
|
+
limit: CLICKUP_SETUP_MAX_SPACES
|
|
593
|
+
});
|
|
594
|
+
const sections = [
|
|
595
|
+
"## ClickUp",
|
|
596
|
+
"",
|
|
597
|
+
`### Workspace: ${teamId}`,
|
|
598
|
+
""
|
|
599
|
+
];
|
|
600
|
+
for (const spaceId of targetSpaceIds) {
|
|
601
|
+
const space = spaceById.get(spaceId);
|
|
602
|
+
const spaceName = space?.name ?? spaceId;
|
|
603
|
+
sections.push(`#### Space: ${spaceName}`, "");
|
|
604
|
+
const [folders, folderlessLists] = await Promise.all([
|
|
605
|
+
listFolders(rt.params, spaceId),
|
|
606
|
+
listFolderlessLists(rt.params, spaceId)
|
|
607
|
+
]);
|
|
608
|
+
sections.push(`- Folders (${folders.length}):`);
|
|
609
|
+
for (const f of folders) sections.push(` - ${f.name}`);
|
|
610
|
+
sections.push(`- Folderless lists (${folderlessLists.length}):`);
|
|
611
|
+
for (const l of folderlessLists) sections.push(` - ${l.name}`);
|
|
612
|
+
sections.push("");
|
|
613
|
+
}
|
|
614
|
+
return sections.join("\n");
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
|
|
415
618
|
// ../connectors/src/connectors/clickup/tools/request.ts
|
|
416
619
|
import { z } from "zod";
|
|
417
620
|
var BASE_HOST = "https://api.clickup.com";
|
|
418
621
|
var BASE_PATH_SEGMENT = "/api/v2";
|
|
419
|
-
var
|
|
622
|
+
var BASE_URL3 = `${BASE_HOST}${BASE_PATH_SEGMENT}`;
|
|
420
623
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
421
624
|
var inputSchema = z.object({
|
|
422
625
|
toolUseIntent: z.string().optional().describe(
|
|
@@ -489,7 +692,7 @@ Pagination: ClickUp uses zero-indexed \`page\` query parameter on list endpoints
|
|
|
489
692
|
try {
|
|
490
693
|
const token = parameters.apiToken.getValue(connection2);
|
|
491
694
|
const normalizedPath = normalizeRequestPath(path2, BASE_PATH_SEGMENT);
|
|
492
|
-
const url = `${
|
|
695
|
+
const url = `${BASE_URL3}${normalizedPath}`;
|
|
493
696
|
const controller = new AbortController();
|
|
494
697
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
495
698
|
try {
|
|
@@ -707,7 +910,39 @@ export default async function handler(c: Context) {
|
|
|
707
910
|
- GET \`/team/{team_id}/time_entries?start_date=...&end_date=...\` \u2014 \u6642\u9593\u8A18\u9332\u4E00\u89A7\uFF08Unix \u30DF\u30EA\u79D2\u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\uFF09
|
|
708
911
|
- POST \`/team/{team_id}/time_entries\` \u2014 \u6642\u9593\u8A18\u9332\u306E\u4F5C\u6210`
|
|
709
912
|
},
|
|
710
|
-
tools
|
|
913
|
+
tools,
|
|
914
|
+
setup: (params, ctx, config) => runSetupFlow(clickupSetupFlow, params, ctx, config),
|
|
915
|
+
async checkConnection(params, _config) {
|
|
916
|
+
try {
|
|
917
|
+
const apiToken = params[parameters.apiToken.slug];
|
|
918
|
+
if (!apiToken) {
|
|
919
|
+
return {
|
|
920
|
+
success: false,
|
|
921
|
+
error: "Missing required parameter: api-token"
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
const res = await fetch("https://api.clickup.com/api/v2/user", {
|
|
925
|
+
method: "GET",
|
|
926
|
+
headers: {
|
|
927
|
+
Authorization: apiToken,
|
|
928
|
+
Accept: "application/json"
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
if (!res.ok) {
|
|
932
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
933
|
+
return {
|
|
934
|
+
success: false,
|
|
935
|
+
error: `ClickUp API failed: HTTP ${res.status} ${errorText}`
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
return { success: true };
|
|
939
|
+
} catch (error) {
|
|
940
|
+
return {
|
|
941
|
+
success: false,
|
|
942
|
+
error: error instanceof Error ? error.message : String(error)
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
}
|
|
711
946
|
});
|
|
712
947
|
|
|
713
948
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -736,6 +971,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
736
971
|
import { getContext } from "hono/context-storage";
|
|
737
972
|
import { getCookie } from "hono/cookie";
|
|
738
973
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
974
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
739
975
|
function normalizeHeaders(input) {
|
|
740
976
|
const out = {};
|
|
741
977
|
if (!input) return out;
|
|
@@ -744,6 +980,11 @@ function normalizeHeaders(input) {
|
|
|
744
980
|
});
|
|
745
981
|
return out;
|
|
746
982
|
}
|
|
983
|
+
function extractInputUrl(input) {
|
|
984
|
+
if (typeof input === "string") return input;
|
|
985
|
+
if (input instanceof URL) return input.href;
|
|
986
|
+
return input.url;
|
|
987
|
+
}
|
|
747
988
|
function createSandboxProxyFetch(connectionId) {
|
|
748
989
|
return async (input, init) => {
|
|
749
990
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -753,10 +994,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
753
994
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
754
995
|
);
|
|
755
996
|
}
|
|
756
|
-
const originalUrl =
|
|
997
|
+
const originalUrl = extractInputUrl(input);
|
|
998
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
999
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
1000
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
1001
|
+
return fetch(sessionUrl, {
|
|
1002
|
+
method: "POST",
|
|
1003
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
757
1006
|
const originalMethod = init?.method ?? "GET";
|
|
758
1007
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
759
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
760
1008
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
761
1009
|
return fetch(proxyUrl, {
|
|
762
1010
|
method: "POST",
|
|
@@ -782,10 +1030,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
782
1030
|
}
|
|
783
1031
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
784
1032
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1033
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
785
1034
|
return async (input, init) => {
|
|
786
|
-
const originalUrl =
|
|
787
|
-
const originalMethod = init?.method ?? "GET";
|
|
788
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1035
|
+
const originalUrl = extractInputUrl(input);
|
|
789
1036
|
const c = getContext();
|
|
790
1037
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
791
1038
|
if (!appSession) {
|
|
@@ -793,6 +1040,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
793
1040
|
"No authentication method available for connection proxy."
|
|
794
1041
|
);
|
|
795
1042
|
}
|
|
1043
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
1044
|
+
return fetch(sessionUrl, {
|
|
1045
|
+
method: "POST",
|
|
1046
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
const originalMethod = init?.method ?? "GET";
|
|
1050
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
796
1051
|
return fetch(proxyUrl, {
|
|
797
1052
|
method: "POST",
|
|
798
1053
|
headers: {
|