@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/freshsales/parameters.ts
|
|
57
|
+
init_parameter_definition();
|
|
46
58
|
var parameters = {
|
|
47
59
|
bundleAlias: new ParameterDefinition({
|
|
48
60
|
slug: "bundle-alias",
|
|
@@ -307,6 +319,20 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
307
319
|
* `runSetupFlow` from `setup-flow.ts`.
|
|
308
320
|
*/
|
|
309
321
|
setup;
|
|
322
|
+
/**
|
|
323
|
+
* Opt-out of the default "verify before save" behavior on connection
|
|
324
|
+
* creation. The backend invokes `checkConnection` synchronously while
|
|
325
|
+
* creating the connection and aborts (no row inserted) if it fails — this
|
|
326
|
+
* flag disables that for connectors where the check cannot succeed pre-save:
|
|
327
|
+
*
|
|
328
|
+
* - `squadbase-db` populates `connection-url` only after Neon provisioning
|
|
329
|
+
* - OAuth connectors require an OAuth-aware proxyFetch keyed by the
|
|
330
|
+
* connectionId, which doesn't exist until the row is saved
|
|
331
|
+
*
|
|
332
|
+
* Exceptions are the explicit position; new credential-input connectors get
|
|
333
|
+
* the default verify-on-create behavior without opt-in.
|
|
334
|
+
*/
|
|
335
|
+
skipConnectionCheckOnCreate;
|
|
310
336
|
constructor(config) {
|
|
311
337
|
this.slug = config.slug;
|
|
312
338
|
this.authType = config.authType;
|
|
@@ -324,6 +350,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
324
350
|
this.query = config.query;
|
|
325
351
|
this.checkConnection = config.checkConnection;
|
|
326
352
|
this.setup = config.setup;
|
|
353
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
327
354
|
}
|
|
328
355
|
get connectorKey() {
|
|
329
356
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -388,6 +415,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
388
415
|
}
|
|
389
416
|
};
|
|
390
417
|
|
|
418
|
+
// ../connectors/src/setup-flow.ts
|
|
419
|
+
async function runSetupFlow(flow, params, ctx, config) {
|
|
420
|
+
const runtime = {
|
|
421
|
+
params,
|
|
422
|
+
language: ctx.language,
|
|
423
|
+
config
|
|
424
|
+
};
|
|
425
|
+
let state = flow.initialState();
|
|
426
|
+
let answerIdx = 0;
|
|
427
|
+
for (const step of flow.steps) {
|
|
428
|
+
const ans = ctx.answers[answerIdx];
|
|
429
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
430
|
+
state = step.applyAnswer(state, ans.answer);
|
|
431
|
+
answerIdx += 1;
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
if (step.type === "text") {
|
|
435
|
+
return {
|
|
436
|
+
type: "nextQuestion",
|
|
437
|
+
questionSlug: step.slug,
|
|
438
|
+
question: step.question[ctx.language],
|
|
439
|
+
questionType: "text"
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
|
|
443
|
+
if (options.length === 0) {
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
return {
|
|
447
|
+
type: "nextQuestion",
|
|
448
|
+
questionSlug: step.slug,
|
|
449
|
+
question: step.question[ctx.language],
|
|
450
|
+
questionType: step.type,
|
|
451
|
+
options
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
455
|
+
return { type: "fulfilled", dataInvestigationResult };
|
|
456
|
+
}
|
|
457
|
+
async function resolveSetupSelection(params) {
|
|
458
|
+
const { selected, allSentinel, fetchAll, limit } = params;
|
|
459
|
+
const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
|
|
460
|
+
return resolved.slice(0, limit);
|
|
461
|
+
}
|
|
462
|
+
|
|
391
463
|
// ../connectors/src/auth-types.ts
|
|
392
464
|
var AUTH_TYPES = {
|
|
393
465
|
OAUTH: "oauth",
|
|
@@ -424,15 +496,134 @@ var freshsalesOnboarding = new ConnectorOnboarding({
|
|
|
424
496
|
}
|
|
425
497
|
});
|
|
426
498
|
|
|
427
|
-
// ../connectors/src/connectors/freshsales/
|
|
428
|
-
import { z } from "zod";
|
|
499
|
+
// ../connectors/src/connectors/freshsales/utils.ts
|
|
429
500
|
var BASE_PATH_SEGMENT = "/crm/sales/api";
|
|
430
|
-
var REQUEST_TIMEOUT_MS = 6e4;
|
|
431
501
|
function buildBaseUrl2(bundleAlias) {
|
|
432
502
|
const trimmed = bundleAlias.trim().replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
433
503
|
const subdomain = trimmed.split(".")[0];
|
|
434
504
|
return `https://${subdomain}.myfreshworks.com${BASE_PATH_SEGMENT}`;
|
|
435
505
|
}
|
|
506
|
+
async function apiFetch(params, path2, init) {
|
|
507
|
+
const apiKey = params[parameters.apiKey.slug];
|
|
508
|
+
const bundle = params[parameters.bundleAlias.slug];
|
|
509
|
+
if (!apiKey || !bundle) {
|
|
510
|
+
throw new Error(
|
|
511
|
+
"freshsales: missing required parameter(s) (api-key, bundle-alias)"
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
const baseUrl = buildBaseUrl2(bundle);
|
|
515
|
+
const url = `${baseUrl}${path2.startsWith("/") ? "" : "/"}${path2}`;
|
|
516
|
+
const headers = new Headers(init?.headers);
|
|
517
|
+
headers.set("Authorization", `Token token=${apiKey}`);
|
|
518
|
+
headers.set("Accept", "application/json");
|
|
519
|
+
return fetch(url, { ...init, headers });
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// ../connectors/src/connectors/freshsales/setup-flow.ts
|
|
523
|
+
var FRESHSALES_SETUP_MAX_ENTITIES = 5;
|
|
524
|
+
var FRESHSALES_ENTITIES = [
|
|
525
|
+
{
|
|
526
|
+
value: "contacts",
|
|
527
|
+
label: "Contacts",
|
|
528
|
+
filtersPath: "/contacts/filters",
|
|
529
|
+
recordsPath: (id) => `/contacts/view/${id}?per_page=1`
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
value: "accounts",
|
|
533
|
+
label: "Sales accounts",
|
|
534
|
+
filtersPath: "/sales_accounts/filters",
|
|
535
|
+
recordsPath: (id) => `/sales_accounts/view/${id}?per_page=1`
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
value: "deals",
|
|
539
|
+
label: "Deals",
|
|
540
|
+
filtersPath: "/deals/filters",
|
|
541
|
+
recordsPath: (id) => `/deals/view/${id}?per_page=1`
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
value: "leads",
|
|
545
|
+
label: "Leads",
|
|
546
|
+
filtersPath: "/leads/filters",
|
|
547
|
+
recordsPath: (id) => `/leads/view/${id}?per_page=1`
|
|
548
|
+
}
|
|
549
|
+
];
|
|
550
|
+
async function fetchEntityCount(params, entry) {
|
|
551
|
+
const filtersRes = await apiFetch(params, entry.filtersPath);
|
|
552
|
+
if (!filtersRes.ok) return null;
|
|
553
|
+
const filtersData = await filtersRes.json();
|
|
554
|
+
const firstView = filtersData.filters?.[0]?.id;
|
|
555
|
+
if (firstView == null) return null;
|
|
556
|
+
const recordsRes = await apiFetch(
|
|
557
|
+
params,
|
|
558
|
+
entry.recordsPath(String(firstView))
|
|
559
|
+
);
|
|
560
|
+
if (!recordsRes.ok) return null;
|
|
561
|
+
const recordsData = await recordsRes.json();
|
|
562
|
+
return recordsData.meta?.total ?? null;
|
|
563
|
+
}
|
|
564
|
+
var freshsalesSetupFlow = {
|
|
565
|
+
initialState: () => ({}),
|
|
566
|
+
steps: [
|
|
567
|
+
{
|
|
568
|
+
slug: "entities",
|
|
569
|
+
type: "multiSelect",
|
|
570
|
+
question: {
|
|
571
|
+
ja: "\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3067\u6982\u89B3\u3057\u305F\u3044Freshsales\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
|
|
572
|
+
en: "Select the Freshsales entities to include in setup (multi-select allowed)"
|
|
573
|
+
},
|
|
574
|
+
async fetchOptions(_state, _rt) {
|
|
575
|
+
return FRESHSALES_ENTITIES.map((e) => ({
|
|
576
|
+
value: e.value,
|
|
577
|
+
label: e.label
|
|
578
|
+
}));
|
|
579
|
+
},
|
|
580
|
+
applyAnswer: (state, answer) => ({ ...state, entities: answer })
|
|
581
|
+
}
|
|
582
|
+
],
|
|
583
|
+
async finalize(state, rt) {
|
|
584
|
+
if (!state.entities) {
|
|
585
|
+
throw new Error("Freshsales setup: incomplete state on finalize");
|
|
586
|
+
}
|
|
587
|
+
const targetEntities = await resolveSetupSelection({
|
|
588
|
+
selected: state.entities,
|
|
589
|
+
allSentinel: "__ALL__",
|
|
590
|
+
fetchAll: async () => FRESHSALES_ENTITIES.map((e) => e.value),
|
|
591
|
+
limit: FRESHSALES_SETUP_MAX_ENTITIES
|
|
592
|
+
});
|
|
593
|
+
const entityByValue = new Map(FRESHSALES_ENTITIES.map((e) => [e.value, e]));
|
|
594
|
+
const sections = [
|
|
595
|
+
"## Freshsales",
|
|
596
|
+
"",
|
|
597
|
+
"### Selected entities",
|
|
598
|
+
"",
|
|
599
|
+
"| Entity | Count (default view) |",
|
|
600
|
+
"|--------|----------------------|"
|
|
601
|
+
];
|
|
602
|
+
for (const value of targetEntities) {
|
|
603
|
+
const entity = entityByValue.get(value);
|
|
604
|
+
if (!entity) {
|
|
605
|
+
sections.push(`| ${value} | _unknown_ |`);
|
|
606
|
+
continue;
|
|
607
|
+
}
|
|
608
|
+
const count = await fetchEntityCount(rt.params, entity);
|
|
609
|
+
sections.push(
|
|
610
|
+
`| ${entity.label} (${entity.value}) | ${count == null ? "-" : count} |`
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
sections.push("");
|
|
614
|
+
return sections.join("\n");
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
// ../connectors/src/connectors/freshsales/tools/request.ts
|
|
619
|
+
import { z } from "zod";
|
|
620
|
+
var BASE_PATH_SEGMENT2 = "/crm/sales/api";
|
|
621
|
+
var REQUEST_TIMEOUT_MS = 6e4;
|
|
622
|
+
function buildBaseUrl3(bundleAlias) {
|
|
623
|
+
const trimmed = bundleAlias.trim().replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
624
|
+
const subdomain = trimmed.split(".")[0];
|
|
625
|
+
return `https://${subdomain}.myfreshworks.com${BASE_PATH_SEGMENT2}`;
|
|
626
|
+
}
|
|
436
627
|
var inputSchema = z.object({
|
|
437
628
|
toolUseIntent: z.string().optional().describe(
|
|
438
629
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -508,8 +699,8 @@ Includes: most GET endpoints accept \`?include=\` with a comma-separated list (\
|
|
|
508
699
|
try {
|
|
509
700
|
const apiKey = parameters.apiKey.getValue(connection2);
|
|
510
701
|
const bundle = parameters.bundleAlias.getValue(connection2);
|
|
511
|
-
const baseUrl =
|
|
512
|
-
const normalizedPath = normalizeRequestPath(path2,
|
|
702
|
+
const baseUrl = buildBaseUrl3(bundle);
|
|
703
|
+
const normalizedPath = normalizeRequestPath(path2, BASE_PATH_SEGMENT2);
|
|
513
704
|
const url = `${baseUrl}${normalizedPath}`;
|
|
514
705
|
const controller = new AbortController();
|
|
515
706
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
@@ -724,7 +915,43 @@ export default async function handler(c: Context) {
|
|
|
724
915
|
- GET \`/selector/lifecycle_stages\` \u2014 \u30E9\u30A4\u30D5\u30B5\u30A4\u30AF\u30EB\u30B9\u30C6\u30FC\u30B8
|
|
725
916
|
- GET \`/selector/territories\` / \`/selector/business_types\` / \`/selector/industry_types\` / \`/selector/contact_statuses\` / \`/selector/sales_activity_types\``
|
|
726
917
|
},
|
|
727
|
-
tools
|
|
918
|
+
tools,
|
|
919
|
+
setup: (params, ctx, config) => runSetupFlow(freshsalesSetupFlow, params, ctx, config),
|
|
920
|
+
async checkConnection(params, _config) {
|
|
921
|
+
const bundleAlias = params[parameters.bundleAlias.slug];
|
|
922
|
+
const apiKey = params[parameters.apiKey.slug];
|
|
923
|
+
if (!bundleAlias || !apiKey) {
|
|
924
|
+
return {
|
|
925
|
+
success: false,
|
|
926
|
+
error: `Missing required parameter(s): ${parameters.bundleAlias.slug}, ${parameters.apiKey.slug}`
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
try {
|
|
930
|
+
const res = await fetch(
|
|
931
|
+
`https://${bundleAlias}.myfreshworks.com/crm/sales/api/selector/owners`,
|
|
932
|
+
{
|
|
933
|
+
method: "GET",
|
|
934
|
+
headers: {
|
|
935
|
+
Authorization: `Token token=${apiKey}`,
|
|
936
|
+
Accept: "application/json"
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
);
|
|
940
|
+
if (!res.ok) {
|
|
941
|
+
const errText = await res.text().catch(() => res.statusText);
|
|
942
|
+
return {
|
|
943
|
+
success: false,
|
|
944
|
+
error: `Freshsales API failed: HTTP ${res.status} ${errText}`
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
return { success: true };
|
|
948
|
+
} catch (error) {
|
|
949
|
+
return {
|
|
950
|
+
success: false,
|
|
951
|
+
error: error instanceof Error ? error.message : String(error)
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
}
|
|
728
955
|
});
|
|
729
956
|
|
|
730
957
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -753,6 +980,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
753
980
|
import { getContext } from "hono/context-storage";
|
|
754
981
|
import { getCookie } from "hono/cookie";
|
|
755
982
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
983
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
756
984
|
function normalizeHeaders(input) {
|
|
757
985
|
const out = {};
|
|
758
986
|
if (!input) return out;
|
|
@@ -761,6 +989,11 @@ function normalizeHeaders(input) {
|
|
|
761
989
|
});
|
|
762
990
|
return out;
|
|
763
991
|
}
|
|
992
|
+
function extractInputUrl(input) {
|
|
993
|
+
if (typeof input === "string") return input;
|
|
994
|
+
if (input instanceof URL) return input.href;
|
|
995
|
+
return input.url;
|
|
996
|
+
}
|
|
764
997
|
function createSandboxProxyFetch(connectionId) {
|
|
765
998
|
return async (input, init) => {
|
|
766
999
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -770,10 +1003,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
770
1003
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
771
1004
|
);
|
|
772
1005
|
}
|
|
773
|
-
const originalUrl =
|
|
1006
|
+
const originalUrl = extractInputUrl(input);
|
|
1007
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
1008
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
1009
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
1010
|
+
return fetch(sessionUrl, {
|
|
1011
|
+
method: "POST",
|
|
1012
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
774
1015
|
const originalMethod = init?.method ?? "GET";
|
|
775
1016
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
776
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
777
1017
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
778
1018
|
return fetch(proxyUrl, {
|
|
779
1019
|
method: "POST",
|
|
@@ -799,10 +1039,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
799
1039
|
}
|
|
800
1040
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
801
1041
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1042
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
802
1043
|
return async (input, init) => {
|
|
803
|
-
const originalUrl =
|
|
804
|
-
const originalMethod = init?.method ?? "GET";
|
|
805
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1044
|
+
const originalUrl = extractInputUrl(input);
|
|
806
1045
|
const c = getContext();
|
|
807
1046
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
808
1047
|
if (!appSession) {
|
|
@@ -810,6 +1049,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
810
1049
|
"No authentication method available for connection proxy."
|
|
811
1050
|
);
|
|
812
1051
|
}
|
|
1052
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
1053
|
+
return fetch(sessionUrl, {
|
|
1054
|
+
method: "POST",
|
|
1055
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
const originalMethod = init?.method ?? "GET";
|
|
1059
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
813
1060
|
return fetch(proxyUrl, {
|
|
814
1061
|
method: "POST",
|
|
815
1062
|
headers: {
|