@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/freshdesk/parameters.ts
|
|
57
|
+
init_parameter_definition();
|
|
46
58
|
var parameters = {
|
|
47
59
|
domain: new ParameterDefinition({
|
|
48
60
|
slug: "domain",
|
|
@@ -292,6 +304,20 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
292
304
|
* `runSetupFlow` from `setup-flow.ts`.
|
|
293
305
|
*/
|
|
294
306
|
setup;
|
|
307
|
+
/**
|
|
308
|
+
* Opt-out of the default "verify before save" behavior on connection
|
|
309
|
+
* creation. The backend invokes `checkConnection` synchronously while
|
|
310
|
+
* creating the connection and aborts (no row inserted) if it fails — this
|
|
311
|
+
* flag disables that for connectors where the check cannot succeed pre-save:
|
|
312
|
+
*
|
|
313
|
+
* - `squadbase-db` populates `connection-url` only after Neon provisioning
|
|
314
|
+
* - OAuth connectors require an OAuth-aware proxyFetch keyed by the
|
|
315
|
+
* connectionId, which doesn't exist until the row is saved
|
|
316
|
+
*
|
|
317
|
+
* Exceptions are the explicit position; new credential-input connectors get
|
|
318
|
+
* the default verify-on-create behavior without opt-in.
|
|
319
|
+
*/
|
|
320
|
+
skipConnectionCheckOnCreate;
|
|
295
321
|
constructor(config) {
|
|
296
322
|
this.slug = config.slug;
|
|
297
323
|
this.authType = config.authType;
|
|
@@ -309,6 +335,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
309
335
|
this.query = config.query;
|
|
310
336
|
this.checkConnection = config.checkConnection;
|
|
311
337
|
this.setup = config.setup;
|
|
338
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
312
339
|
}
|
|
313
340
|
get connectorKey() {
|
|
314
341
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -373,6 +400,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
373
400
|
}
|
|
374
401
|
};
|
|
375
402
|
|
|
403
|
+
// ../connectors/src/setup-flow.ts
|
|
404
|
+
async function runSetupFlow(flow, params, ctx, config) {
|
|
405
|
+
const runtime = {
|
|
406
|
+
params,
|
|
407
|
+
language: ctx.language,
|
|
408
|
+
config
|
|
409
|
+
};
|
|
410
|
+
let state = flow.initialState();
|
|
411
|
+
let answerIdx = 0;
|
|
412
|
+
for (const step of flow.steps) {
|
|
413
|
+
const ans = ctx.answers[answerIdx];
|
|
414
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
415
|
+
state = step.applyAnswer(state, ans.answer);
|
|
416
|
+
answerIdx += 1;
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
if (step.type === "text") {
|
|
420
|
+
return {
|
|
421
|
+
type: "nextQuestion",
|
|
422
|
+
questionSlug: step.slug,
|
|
423
|
+
question: step.question[ctx.language],
|
|
424
|
+
questionType: "text"
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
|
|
428
|
+
if (options.length === 0) {
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
return {
|
|
432
|
+
type: "nextQuestion",
|
|
433
|
+
questionSlug: step.slug,
|
|
434
|
+
question: step.question[ctx.language],
|
|
435
|
+
questionType: step.type,
|
|
436
|
+
options
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
440
|
+
return { type: "fulfilled", dataInvestigationResult };
|
|
441
|
+
}
|
|
442
|
+
async function resolveSetupSelection(params) {
|
|
443
|
+
const { selected, allSentinel, fetchAll, limit } = params;
|
|
444
|
+
const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
|
|
445
|
+
return resolved.slice(0, limit);
|
|
446
|
+
}
|
|
447
|
+
|
|
376
448
|
// ../connectors/src/auth-types.ts
|
|
377
449
|
var AUTH_TYPES = {
|
|
378
450
|
OAUTH: "oauth",
|
|
@@ -409,10 +481,8 @@ var freshdeskOnboarding = new ConnectorOnboarding({
|
|
|
409
481
|
}
|
|
410
482
|
});
|
|
411
483
|
|
|
412
|
-
// ../connectors/src/connectors/freshdesk/
|
|
413
|
-
import { z } from "zod";
|
|
484
|
+
// ../connectors/src/connectors/freshdesk/utils.ts
|
|
414
485
|
var BASE_PATH_SEGMENT = "/api/v2";
|
|
415
|
-
var REQUEST_TIMEOUT_MS = 6e4;
|
|
416
486
|
function buildBaseUrl2(domain) {
|
|
417
487
|
const trimmed = domain.trim().replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
418
488
|
const subdomain = trimmed.split(".")[0];
|
|
@@ -421,6 +491,132 @@ function buildBaseUrl2(domain) {
|
|
|
421
491
|
function basicAuthHeader2(apiKey) {
|
|
422
492
|
return `Basic ${Buffer.from(`${apiKey}:X`).toString("base64")}`;
|
|
423
493
|
}
|
|
494
|
+
async function apiFetch(params, path2, init) {
|
|
495
|
+
const apiKey = params[parameters.apiKey.slug];
|
|
496
|
+
const domain = params[parameters.domain.slug];
|
|
497
|
+
if (!apiKey || !domain) {
|
|
498
|
+
throw new Error(
|
|
499
|
+
"freshdesk: missing required parameter(s) (api-key, domain)"
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
const baseUrl = buildBaseUrl2(domain);
|
|
503
|
+
const url = `${baseUrl}${path2.startsWith("/") ? "" : "/"}${path2}`;
|
|
504
|
+
const headers = new Headers(init?.headers);
|
|
505
|
+
headers.set("Authorization", basicAuthHeader2(apiKey));
|
|
506
|
+
headers.set("Accept", "application/json");
|
|
507
|
+
return fetch(url, { ...init, headers });
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// ../connectors/src/connectors/freshdesk/setup-flow.ts
|
|
511
|
+
var FRESHDESK_SETUP_MAX_ENTITIES = 5;
|
|
512
|
+
var FRESHDESK_ENTITIES = [
|
|
513
|
+
{
|
|
514
|
+
value: "tickets",
|
|
515
|
+
label: "Tickets",
|
|
516
|
+
countPath: "/search/tickets?query=%22status%3A%3E0%22",
|
|
517
|
+
countField: "total"
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
value: "contacts",
|
|
521
|
+
label: "Contacts",
|
|
522
|
+
countPath: "/contacts?per_page=1"
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
value: "companies",
|
|
526
|
+
label: "Companies",
|
|
527
|
+
countPath: "/companies?per_page=1"
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
value: "agents",
|
|
531
|
+
label: "Agents",
|
|
532
|
+
countPath: "/agents?per_page=1"
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
value: "groups",
|
|
536
|
+
label: "Groups",
|
|
537
|
+
countPath: "/groups?per_page=1"
|
|
538
|
+
}
|
|
539
|
+
];
|
|
540
|
+
async function fetchEntityCount(params, path2, countField) {
|
|
541
|
+
const res = await apiFetch(params, path2);
|
|
542
|
+
if (!res.ok) return null;
|
|
543
|
+
const data = await res.json();
|
|
544
|
+
if (Array.isArray(data)) return null;
|
|
545
|
+
if (countField && typeof data[countField] === "number") {
|
|
546
|
+
return data[countField];
|
|
547
|
+
}
|
|
548
|
+
return null;
|
|
549
|
+
}
|
|
550
|
+
var freshdeskSetupFlow = {
|
|
551
|
+
initialState: () => ({}),
|
|
552
|
+
steps: [
|
|
553
|
+
{
|
|
554
|
+
slug: "entities",
|
|
555
|
+
type: "multiSelect",
|
|
556
|
+
question: {
|
|
557
|
+
ja: "\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3067\u6982\u89B3\u3057\u305F\u3044Freshdesk\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
|
|
558
|
+
en: "Select the Freshdesk entities to include in setup (multi-select allowed)"
|
|
559
|
+
},
|
|
560
|
+
async fetchOptions(_state, _rt) {
|
|
561
|
+
return FRESHDESK_ENTITIES.map((e) => ({
|
|
562
|
+
value: e.value,
|
|
563
|
+
label: e.label
|
|
564
|
+
}));
|
|
565
|
+
},
|
|
566
|
+
applyAnswer: (state, answer) => ({ ...state, entities: answer })
|
|
567
|
+
}
|
|
568
|
+
],
|
|
569
|
+
async finalize(state, rt) {
|
|
570
|
+
if (!state.entities) {
|
|
571
|
+
throw new Error("Freshdesk setup: incomplete state on finalize");
|
|
572
|
+
}
|
|
573
|
+
const targetEntities = await resolveSetupSelection({
|
|
574
|
+
selected: state.entities,
|
|
575
|
+
allSentinel: "__ALL__",
|
|
576
|
+
fetchAll: async () => FRESHDESK_ENTITIES.map((e) => e.value),
|
|
577
|
+
limit: FRESHDESK_SETUP_MAX_ENTITIES
|
|
578
|
+
});
|
|
579
|
+
const entityByValue = new Map(FRESHDESK_ENTITIES.map((e) => [e.value, e]));
|
|
580
|
+
const sections = [
|
|
581
|
+
"## Freshdesk",
|
|
582
|
+
"",
|
|
583
|
+
"### Selected entities",
|
|
584
|
+
"",
|
|
585
|
+
"| Entity | Count |",
|
|
586
|
+
"|--------|-------|"
|
|
587
|
+
];
|
|
588
|
+
for (const value of targetEntities) {
|
|
589
|
+
const entity = entityByValue.get(value);
|
|
590
|
+
if (!entity) {
|
|
591
|
+
sections.push(`| ${value} | _unknown_ |`);
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
594
|
+
const count = await fetchEntityCount(
|
|
595
|
+
rt.params,
|
|
596
|
+
entity.countPath,
|
|
597
|
+
entity.countField
|
|
598
|
+
);
|
|
599
|
+
sections.push(
|
|
600
|
+
`| ${entity.label} (${entity.value}) | ${count == null ? "-" : count} |`
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
sections.push("");
|
|
604
|
+
return sections.join("\n");
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
// ../connectors/src/connectors/freshdesk/tools/request.ts
|
|
609
|
+
import { z } from "zod";
|
|
610
|
+
var BASE_PATH_SEGMENT2 = "/api/v2";
|
|
611
|
+
var REQUEST_TIMEOUT_MS = 6e4;
|
|
612
|
+
function buildBaseUrl3(domain) {
|
|
613
|
+
const trimmed = domain.trim().replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
614
|
+
const subdomain = trimmed.split(".")[0];
|
|
615
|
+
return `https://${subdomain}.freshdesk.com${BASE_PATH_SEGMENT2}`;
|
|
616
|
+
}
|
|
617
|
+
function basicAuthHeader3(apiKey) {
|
|
618
|
+
return `Basic ${Buffer.from(`${apiKey}:X`).toString("base64")}`;
|
|
619
|
+
}
|
|
424
620
|
var inputSchema = z.object({
|
|
425
621
|
toolUseIntent: z.string().optional().describe(
|
|
426
622
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -494,8 +690,8 @@ Field codes (tickets):
|
|
|
494
690
|
try {
|
|
495
691
|
const apiKey = parameters.apiKey.getValue(connection2);
|
|
496
692
|
const domain = parameters.domain.getValue(connection2);
|
|
497
|
-
const baseUrl =
|
|
498
|
-
const normalizedPath = normalizeRequestPath(path2,
|
|
693
|
+
const baseUrl = buildBaseUrl3(domain);
|
|
694
|
+
const normalizedPath = normalizeRequestPath(path2, BASE_PATH_SEGMENT2);
|
|
499
695
|
const url = `${baseUrl}${normalizedPath}`;
|
|
500
696
|
const controller = new AbortController();
|
|
501
697
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
@@ -503,7 +699,7 @@ Field codes (tickets):
|
|
|
503
699
|
const response = await fetch(url, {
|
|
504
700
|
method,
|
|
505
701
|
headers: {
|
|
506
|
-
Authorization:
|
|
702
|
+
Authorization: basicAuthHeader3(apiKey),
|
|
507
703
|
"Content-Type": "application/json",
|
|
508
704
|
Accept: "application/json"
|
|
509
705
|
},
|
|
@@ -699,7 +895,46 @@ export default async function handler(c: Context) {
|
|
|
699
895
|
- \`status\`: 2=Open, 3=Pending, 4=Resolved, 5=Closed
|
|
700
896
|
- \`source\`: 1=Email, 2=Portal, 3=Phone, 7=Chat, 9=Feedback widget, 10=Outbound email`
|
|
701
897
|
},
|
|
702
|
-
tools
|
|
898
|
+
tools,
|
|
899
|
+
setup: (params, ctx, config) => runSetupFlow(freshdeskSetupFlow, params, ctx, config),
|
|
900
|
+
async checkConnection(params, _config) {
|
|
901
|
+
const domain = params[parameters.domain.slug];
|
|
902
|
+
const apiKey = params[parameters.apiKey.slug];
|
|
903
|
+
if (!domain || !apiKey) {
|
|
904
|
+
return {
|
|
905
|
+
success: false,
|
|
906
|
+
error: `Missing required parameter(s): ${parameters.domain.slug}, ${parameters.apiKey.slug}`
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
try {
|
|
910
|
+
const credentials = Buffer.from(`${apiKey}:X`, "utf-8").toString(
|
|
911
|
+
"base64"
|
|
912
|
+
);
|
|
913
|
+
const res = await fetch(
|
|
914
|
+
`https://${domain}.freshdesk.com/api/v2/agents/me`,
|
|
915
|
+
{
|
|
916
|
+
method: "GET",
|
|
917
|
+
headers: {
|
|
918
|
+
Authorization: `Basic ${credentials}`,
|
|
919
|
+
Accept: "application/json"
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
);
|
|
923
|
+
if (!res.ok) {
|
|
924
|
+
const errText = await res.text().catch(() => res.statusText);
|
|
925
|
+
return {
|
|
926
|
+
success: false,
|
|
927
|
+
error: `Freshdesk API failed: HTTP ${res.status} ${errText}`
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
return { success: true };
|
|
931
|
+
} catch (error) {
|
|
932
|
+
return {
|
|
933
|
+
success: false,
|
|
934
|
+
error: error instanceof Error ? error.message : String(error)
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
}
|
|
703
938
|
});
|
|
704
939
|
|
|
705
940
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -728,6 +963,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
728
963
|
import { getContext } from "hono/context-storage";
|
|
729
964
|
import { getCookie } from "hono/cookie";
|
|
730
965
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
966
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
731
967
|
function normalizeHeaders(input) {
|
|
732
968
|
const out = {};
|
|
733
969
|
if (!input) return out;
|
|
@@ -736,6 +972,11 @@ function normalizeHeaders(input) {
|
|
|
736
972
|
});
|
|
737
973
|
return out;
|
|
738
974
|
}
|
|
975
|
+
function extractInputUrl(input) {
|
|
976
|
+
if (typeof input === "string") return input;
|
|
977
|
+
if (input instanceof URL) return input.href;
|
|
978
|
+
return input.url;
|
|
979
|
+
}
|
|
739
980
|
function createSandboxProxyFetch(connectionId) {
|
|
740
981
|
return async (input, init) => {
|
|
741
982
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -745,10 +986,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
745
986
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
746
987
|
);
|
|
747
988
|
}
|
|
748
|
-
const originalUrl =
|
|
989
|
+
const originalUrl = extractInputUrl(input);
|
|
990
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
991
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
992
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
993
|
+
return fetch(sessionUrl, {
|
|
994
|
+
method: "POST",
|
|
995
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
996
|
+
});
|
|
997
|
+
}
|
|
749
998
|
const originalMethod = init?.method ?? "GET";
|
|
750
999
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
751
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
752
1000
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
753
1001
|
return fetch(proxyUrl, {
|
|
754
1002
|
method: "POST",
|
|
@@ -774,10 +1022,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
774
1022
|
}
|
|
775
1023
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
776
1024
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1025
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
777
1026
|
return async (input, init) => {
|
|
778
|
-
const originalUrl =
|
|
779
|
-
const originalMethod = init?.method ?? "GET";
|
|
780
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1027
|
+
const originalUrl = extractInputUrl(input);
|
|
781
1028
|
const c = getContext();
|
|
782
1029
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
783
1030
|
if (!appSession) {
|
|
@@ -785,6 +1032,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
785
1032
|
"No authentication method available for connection proxy."
|
|
786
1033
|
);
|
|
787
1034
|
}
|
|
1035
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
1036
|
+
return fetch(sessionUrl, {
|
|
1037
|
+
method: "POST",
|
|
1038
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
const originalMethod = init?.method ?? "GET";
|
|
1042
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
788
1043
|
return fetch(proxyUrl, {
|
|
789
1044
|
method: "POST",
|
|
790
1045
|
headers: {
|