@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/clickup/parameters.ts
|
|
57
|
+
init_parameter_definition();
|
|
46
58
|
var parameters = {
|
|
47
59
|
apiToken: new ParameterDefinition({
|
|
48
60
|
slug: "api-token",
|
|
@@ -287,6 +299,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
287
299
|
tools;
|
|
288
300
|
query;
|
|
289
301
|
checkConnection;
|
|
302
|
+
/**
|
|
303
|
+
* SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
|
|
304
|
+
* implement this expose a step-by-step exploration flow (database/schema/
|
|
305
|
+
* table/etc. discovery) that the dashboard backend drives via the
|
|
306
|
+
* `/connections/:connectionId/setup` endpoint. Implement by delegating to
|
|
307
|
+
* `runSetupFlow` from `setup-flow.ts`.
|
|
308
|
+
*/
|
|
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;
|
|
290
324
|
constructor(config) {
|
|
291
325
|
this.slug = config.slug;
|
|
292
326
|
this.authType = config.authType;
|
|
@@ -303,6 +337,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
303
337
|
this.tools = config.tools;
|
|
304
338
|
this.query = config.query;
|
|
305
339
|
this.checkConnection = config.checkConnection;
|
|
340
|
+
this.setup = config.setup;
|
|
341
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
306
342
|
}
|
|
307
343
|
get connectorKey() {
|
|
308
344
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -367,6 +403,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
367
403
|
}
|
|
368
404
|
};
|
|
369
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
|
+
|
|
370
451
|
// ../connectors/src/auth-types.ts
|
|
371
452
|
var AUTH_TYPES = {
|
|
372
453
|
OAUTH: "oauth",
|
|
@@ -403,11 +484,142 @@ var clickupOnboarding = new ConnectorOnboarding({
|
|
|
403
484
|
}
|
|
404
485
|
});
|
|
405
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
|
+
|
|
406
618
|
// ../connectors/src/connectors/clickup/tools/request.ts
|
|
407
619
|
import { z } from "zod";
|
|
408
620
|
var BASE_HOST = "https://api.clickup.com";
|
|
409
621
|
var BASE_PATH_SEGMENT = "/api/v2";
|
|
410
|
-
var
|
|
622
|
+
var BASE_URL3 = `${BASE_HOST}${BASE_PATH_SEGMENT}`;
|
|
411
623
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
412
624
|
var inputSchema = z.object({
|
|
413
625
|
toolUseIntent: z.string().optional().describe(
|
|
@@ -480,7 +692,7 @@ Pagination: ClickUp uses zero-indexed \`page\` query parameter on list endpoints
|
|
|
480
692
|
try {
|
|
481
693
|
const token = parameters.apiToken.getValue(connection2);
|
|
482
694
|
const normalizedPath = normalizeRequestPath(path2, BASE_PATH_SEGMENT);
|
|
483
|
-
const url = `${
|
|
695
|
+
const url = `${BASE_URL3}${normalizedPath}`;
|
|
484
696
|
const controller = new AbortController();
|
|
485
697
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
486
698
|
try {
|
|
@@ -698,7 +910,39 @@ export default async function handler(c: Context) {
|
|
|
698
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
|
|
699
911
|
- POST \`/team/{team_id}/time_entries\` \u2014 \u6642\u9593\u8A18\u9332\u306E\u4F5C\u6210`
|
|
700
912
|
},
|
|
701
|
-
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
|
+
}
|
|
702
946
|
});
|
|
703
947
|
|
|
704
948
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -727,6 +971,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
727
971
|
import { getContext } from "hono/context-storage";
|
|
728
972
|
import { getCookie } from "hono/cookie";
|
|
729
973
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
974
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
730
975
|
function normalizeHeaders(input) {
|
|
731
976
|
const out = {};
|
|
732
977
|
if (!input) return out;
|
|
@@ -735,6 +980,11 @@ function normalizeHeaders(input) {
|
|
|
735
980
|
});
|
|
736
981
|
return out;
|
|
737
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
|
+
}
|
|
738
988
|
function createSandboxProxyFetch(connectionId) {
|
|
739
989
|
return async (input, init) => {
|
|
740
990
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -744,10 +994,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
744
994
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
745
995
|
);
|
|
746
996
|
}
|
|
747
|
-
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
|
+
}
|
|
748
1006
|
const originalMethod = init?.method ?? "GET";
|
|
749
1007
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
750
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
751
1008
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
752
1009
|
return fetch(proxyUrl, {
|
|
753
1010
|
method: "POST",
|
|
@@ -773,10 +1030,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
773
1030
|
}
|
|
774
1031
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
775
1032
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1033
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
776
1034
|
return async (input, init) => {
|
|
777
|
-
const originalUrl =
|
|
778
|
-
const originalMethod = init?.method ?? "GET";
|
|
779
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1035
|
+
const originalUrl = extractInputUrl(input);
|
|
780
1036
|
const c = getContext();
|
|
781
1037
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
782
1038
|
if (!appSession) {
|
|
@@ -784,6 +1040,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
784
1040
|
"No authentication method available for connection proxy."
|
|
785
1041
|
);
|
|
786
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;
|
|
787
1051
|
return fetch(proxyUrl, {
|
|
788
1052
|
method: "POST",
|
|
789
1053
|
headers: {
|