@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/freshdesk/parameters.ts
|
|
57
|
+
init_parameter_definition();
|
|
46
58
|
var parameters = {
|
|
47
59
|
domain: new ParameterDefinition({
|
|
48
60
|
slug: "domain",
|
|
@@ -284,6 +296,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
284
296
|
tools;
|
|
285
297
|
query;
|
|
286
298
|
checkConnection;
|
|
299
|
+
/**
|
|
300
|
+
* SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
|
|
301
|
+
* implement this expose a step-by-step exploration flow (database/schema/
|
|
302
|
+
* table/etc. discovery) that the dashboard backend drives via the
|
|
303
|
+
* `/connections/:connectionId/setup` endpoint. Implement by delegating to
|
|
304
|
+
* `runSetupFlow` from `setup-flow.ts`.
|
|
305
|
+
*/
|
|
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;
|
|
287
321
|
constructor(config) {
|
|
288
322
|
this.slug = config.slug;
|
|
289
323
|
this.authType = config.authType;
|
|
@@ -300,6 +334,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
300
334
|
this.tools = config.tools;
|
|
301
335
|
this.query = config.query;
|
|
302
336
|
this.checkConnection = config.checkConnection;
|
|
337
|
+
this.setup = config.setup;
|
|
338
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
303
339
|
}
|
|
304
340
|
get connectorKey() {
|
|
305
341
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -364,6 +400,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
364
400
|
}
|
|
365
401
|
};
|
|
366
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
|
+
|
|
367
448
|
// ../connectors/src/auth-types.ts
|
|
368
449
|
var AUTH_TYPES = {
|
|
369
450
|
OAUTH: "oauth",
|
|
@@ -400,10 +481,8 @@ var freshdeskOnboarding = new ConnectorOnboarding({
|
|
|
400
481
|
}
|
|
401
482
|
});
|
|
402
483
|
|
|
403
|
-
// ../connectors/src/connectors/freshdesk/
|
|
404
|
-
import { z } from "zod";
|
|
484
|
+
// ../connectors/src/connectors/freshdesk/utils.ts
|
|
405
485
|
var BASE_PATH_SEGMENT = "/api/v2";
|
|
406
|
-
var REQUEST_TIMEOUT_MS = 6e4;
|
|
407
486
|
function buildBaseUrl2(domain) {
|
|
408
487
|
const trimmed = domain.trim().replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
409
488
|
const subdomain = trimmed.split(".")[0];
|
|
@@ -412,6 +491,132 @@ function buildBaseUrl2(domain) {
|
|
|
412
491
|
function basicAuthHeader2(apiKey) {
|
|
413
492
|
return `Basic ${Buffer.from(`${apiKey}:X`).toString("base64")}`;
|
|
414
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
|
+
}
|
|
415
620
|
var inputSchema = z.object({
|
|
416
621
|
toolUseIntent: z.string().optional().describe(
|
|
417
622
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -485,8 +690,8 @@ Field codes (tickets):
|
|
|
485
690
|
try {
|
|
486
691
|
const apiKey = parameters.apiKey.getValue(connection2);
|
|
487
692
|
const domain = parameters.domain.getValue(connection2);
|
|
488
|
-
const baseUrl =
|
|
489
|
-
const normalizedPath = normalizeRequestPath(path2,
|
|
693
|
+
const baseUrl = buildBaseUrl3(domain);
|
|
694
|
+
const normalizedPath = normalizeRequestPath(path2, BASE_PATH_SEGMENT2);
|
|
490
695
|
const url = `${baseUrl}${normalizedPath}`;
|
|
491
696
|
const controller = new AbortController();
|
|
492
697
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
@@ -494,7 +699,7 @@ Field codes (tickets):
|
|
|
494
699
|
const response = await fetch(url, {
|
|
495
700
|
method,
|
|
496
701
|
headers: {
|
|
497
|
-
Authorization:
|
|
702
|
+
Authorization: basicAuthHeader3(apiKey),
|
|
498
703
|
"Content-Type": "application/json",
|
|
499
704
|
Accept: "application/json"
|
|
500
705
|
},
|
|
@@ -690,7 +895,46 @@ export default async function handler(c: Context) {
|
|
|
690
895
|
- \`status\`: 2=Open, 3=Pending, 4=Resolved, 5=Closed
|
|
691
896
|
- \`source\`: 1=Email, 2=Portal, 3=Phone, 7=Chat, 9=Feedback widget, 10=Outbound email`
|
|
692
897
|
},
|
|
693
|
-
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
|
+
}
|
|
694
938
|
});
|
|
695
939
|
|
|
696
940
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -719,6 +963,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
719
963
|
import { getContext } from "hono/context-storage";
|
|
720
964
|
import { getCookie } from "hono/cookie";
|
|
721
965
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
966
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
722
967
|
function normalizeHeaders(input) {
|
|
723
968
|
const out = {};
|
|
724
969
|
if (!input) return out;
|
|
@@ -727,6 +972,11 @@ function normalizeHeaders(input) {
|
|
|
727
972
|
});
|
|
728
973
|
return out;
|
|
729
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
|
+
}
|
|
730
980
|
function createSandboxProxyFetch(connectionId) {
|
|
731
981
|
return async (input, init) => {
|
|
732
982
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -736,10 +986,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
736
986
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
737
987
|
);
|
|
738
988
|
}
|
|
739
|
-
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
|
+
}
|
|
740
998
|
const originalMethod = init?.method ?? "GET";
|
|
741
999
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
742
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
743
1000
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
744
1001
|
return fetch(proxyUrl, {
|
|
745
1002
|
method: "POST",
|
|
@@ -765,10 +1022,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
765
1022
|
}
|
|
766
1023
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
767
1024
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1025
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
768
1026
|
return async (input, init) => {
|
|
769
|
-
const originalUrl =
|
|
770
|
-
const originalMethod = init?.method ?? "GET";
|
|
771
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1027
|
+
const originalUrl = extractInputUrl(input);
|
|
772
1028
|
const c = getContext();
|
|
773
1029
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
774
1030
|
if (!appSession) {
|
|
@@ -776,6 +1032,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
776
1032
|
"No authentication method available for connection proxy."
|
|
777
1033
|
);
|
|
778
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;
|
|
779
1043
|
return fetch(proxyUrl, {
|
|
780
1044
|
method: "POST",
|
|
781
1045
|
headers: {
|