@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/freshsales/parameters.ts
|
|
57
|
+
init_parameter_definition();
|
|
46
58
|
var parameters = {
|
|
47
59
|
bundleAlias: new ParameterDefinition({
|
|
48
60
|
slug: "bundle-alias",
|
|
@@ -299,6 +311,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
299
311
|
tools;
|
|
300
312
|
query;
|
|
301
313
|
checkConnection;
|
|
314
|
+
/**
|
|
315
|
+
* SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
|
|
316
|
+
* implement this expose a step-by-step exploration flow (database/schema/
|
|
317
|
+
* table/etc. discovery) that the dashboard backend drives via the
|
|
318
|
+
* `/connections/:connectionId/setup` endpoint. Implement by delegating to
|
|
319
|
+
* `runSetupFlow` from `setup-flow.ts`.
|
|
320
|
+
*/
|
|
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;
|
|
302
336
|
constructor(config) {
|
|
303
337
|
this.slug = config.slug;
|
|
304
338
|
this.authType = config.authType;
|
|
@@ -315,6 +349,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
315
349
|
this.tools = config.tools;
|
|
316
350
|
this.query = config.query;
|
|
317
351
|
this.checkConnection = config.checkConnection;
|
|
352
|
+
this.setup = config.setup;
|
|
353
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
318
354
|
}
|
|
319
355
|
get connectorKey() {
|
|
320
356
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -379,6 +415,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
379
415
|
}
|
|
380
416
|
};
|
|
381
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
|
+
|
|
382
463
|
// ../connectors/src/auth-types.ts
|
|
383
464
|
var AUTH_TYPES = {
|
|
384
465
|
OAUTH: "oauth",
|
|
@@ -415,15 +496,134 @@ var freshsalesOnboarding = new ConnectorOnboarding({
|
|
|
415
496
|
}
|
|
416
497
|
});
|
|
417
498
|
|
|
418
|
-
// ../connectors/src/connectors/freshsales/
|
|
419
|
-
import { z } from "zod";
|
|
499
|
+
// ../connectors/src/connectors/freshsales/utils.ts
|
|
420
500
|
var BASE_PATH_SEGMENT = "/crm/sales/api";
|
|
421
|
-
var REQUEST_TIMEOUT_MS = 6e4;
|
|
422
501
|
function buildBaseUrl2(bundleAlias) {
|
|
423
502
|
const trimmed = bundleAlias.trim().replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
424
503
|
const subdomain = trimmed.split(".")[0];
|
|
425
504
|
return `https://${subdomain}.myfreshworks.com${BASE_PATH_SEGMENT}`;
|
|
426
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
|
+
}
|
|
427
627
|
var inputSchema = z.object({
|
|
428
628
|
toolUseIntent: z.string().optional().describe(
|
|
429
629
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -499,8 +699,8 @@ Includes: most GET endpoints accept \`?include=\` with a comma-separated list (\
|
|
|
499
699
|
try {
|
|
500
700
|
const apiKey = parameters.apiKey.getValue(connection2);
|
|
501
701
|
const bundle = parameters.bundleAlias.getValue(connection2);
|
|
502
|
-
const baseUrl =
|
|
503
|
-
const normalizedPath = normalizeRequestPath(path2,
|
|
702
|
+
const baseUrl = buildBaseUrl3(bundle);
|
|
703
|
+
const normalizedPath = normalizeRequestPath(path2, BASE_PATH_SEGMENT2);
|
|
504
704
|
const url = `${baseUrl}${normalizedPath}`;
|
|
505
705
|
const controller = new AbortController();
|
|
506
706
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
@@ -715,7 +915,43 @@ export default async function handler(c: Context) {
|
|
|
715
915
|
- GET \`/selector/lifecycle_stages\` \u2014 \u30E9\u30A4\u30D5\u30B5\u30A4\u30AF\u30EB\u30B9\u30C6\u30FC\u30B8
|
|
716
916
|
- GET \`/selector/territories\` / \`/selector/business_types\` / \`/selector/industry_types\` / \`/selector/contact_statuses\` / \`/selector/sales_activity_types\``
|
|
717
917
|
},
|
|
718
|
-
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
|
+
}
|
|
719
955
|
});
|
|
720
956
|
|
|
721
957
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -744,6 +980,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
744
980
|
import { getContext } from "hono/context-storage";
|
|
745
981
|
import { getCookie } from "hono/cookie";
|
|
746
982
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
983
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
747
984
|
function normalizeHeaders(input) {
|
|
748
985
|
const out = {};
|
|
749
986
|
if (!input) return out;
|
|
@@ -752,6 +989,11 @@ function normalizeHeaders(input) {
|
|
|
752
989
|
});
|
|
753
990
|
return out;
|
|
754
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
|
+
}
|
|
755
997
|
function createSandboxProxyFetch(connectionId) {
|
|
756
998
|
return async (input, init) => {
|
|
757
999
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -761,10 +1003,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
761
1003
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
762
1004
|
);
|
|
763
1005
|
}
|
|
764
|
-
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
|
+
}
|
|
765
1015
|
const originalMethod = init?.method ?? "GET";
|
|
766
1016
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
767
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
768
1017
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
769
1018
|
return fetch(proxyUrl, {
|
|
770
1019
|
method: "POST",
|
|
@@ -790,10 +1039,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
790
1039
|
}
|
|
791
1040
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
792
1041
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1042
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
793
1043
|
return async (input, init) => {
|
|
794
|
-
const originalUrl =
|
|
795
|
-
const originalMethod = init?.method ?? "GET";
|
|
796
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1044
|
+
const originalUrl = extractInputUrl(input);
|
|
797
1045
|
const c = getContext();
|
|
798
1046
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
799
1047
|
if (!appSession) {
|
|
@@ -801,6 +1049,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
801
1049
|
"No authentication method available for connection proxy."
|
|
802
1050
|
);
|
|
803
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;
|
|
804
1060
|
return fetch(proxyUrl, {
|
|
805
1061
|
method: "POST",
|
|
806
1062
|
headers: {
|