@squadbase/vite-server 0.1.12-dev.a9ac647 → 0.1.17-dev.3b633bb
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 +14375 -1652
- package/dist/connectors/airtable-oauth.js +282 -46
- package/dist/connectors/airtable.js +319 -51
- package/dist/connectors/amplitude.js +322 -47
- package/dist/connectors/anthropic.js +135 -47
- package/dist/connectors/asana.js +327 -49
- package/dist/connectors/attio.js +302 -49
- package/dist/connectors/aws-billing.js +287 -46
- package/dist/connectors/azure-sql.js +421 -102
- package/dist/connectors/backlog-api-key.js +317 -47
- package/dist/connectors/clickup.js +338 -49
- package/dist/connectors/cosmosdb.js +305 -50
- package/dist/connectors/customerio.js +319 -47
- package/dist/connectors/dbt.js +340 -47
- package/dist/connectors/freshdesk.js +342 -53
- package/dist/connectors/freshsales.js +333 -52
- package/dist/connectors/freshservice.js +361 -53
- package/dist/connectors/gamma.js +327 -52
- package/dist/connectors/gemini.js +134 -47
- package/dist/connectors/github.js +386 -49
- package/dist/connectors/gmail-oauth.js +204 -7
- package/dist/connectors/gmail.js +350 -47
- package/dist/connectors/google-ads.js +288 -46
- package/dist/connectors/google-analytics-oauth.js +310 -46
- package/dist/connectors/google-analytics.js +547 -87
- package/dist/connectors/google-audit-log.js +438 -47
- package/dist/connectors/google-calendar-oauth.js +259 -46
- package/dist/connectors/google-calendar.js +359 -47
- package/dist/connectors/google-docs.js +220 -6
- package/dist/connectors/google-drive.js +262 -5
- package/dist/connectors/google-search-console-oauth.js +256 -46
- package/dist/connectors/google-sheets.js +272 -47
- package/dist/connectors/google-slides.js +205 -6
- package/dist/connectors/grafana.js +332 -49
- package/dist/connectors/hubspot-oauth.js +208 -5
- package/dist/connectors/hubspot.js +306 -49
- package/dist/connectors/influxdb.js +416 -51
- package/dist/connectors/intercom-oauth.js +210 -5
- package/dist/connectors/intercom.js +302 -49
- package/dist/connectors/jdbc.js +762 -110
- package/dist/connectors/jira-api-key.js +326 -47
- package/dist/connectors/kintone-api-token.js +281 -47
- package/dist/connectors/kintone.js +328 -47
- package/dist/connectors/linear.js +330 -49
- package/dist/connectors/linkedin-ads.js +268 -50
- package/dist/connectors/mailchimp-oauth.js +268 -46
- package/dist/connectors/mailchimp.js +320 -49
- package/dist/connectors/meta-ads-oauth.js +273 -48
- package/dist/connectors/meta-ads.js +285 -50
- package/dist/connectors/mixpanel.js +338 -47
- package/dist/connectors/monday.js +360 -49
- package/dist/connectors/mongodb.js +319 -57
- package/dist/connectors/notion-oauth.js +231 -5
- package/dist/connectors/notion.js +323 -51
- package/dist/connectors/openai.js +134 -47
- package/dist/connectors/oracle.js +454 -103
- package/dist/connectors/outlook-oauth.js +204 -5
- package/dist/connectors/powerbi-oauth.js +498 -5
- package/dist/connectors/salesforce.js +384 -49
- package/dist/connectors/semrush.js +609 -49
- package/dist/connectors/sentry.js +289 -50
- package/dist/connectors/shopify-oauth.js +187 -5
- package/dist/connectors/shopify.js +357 -47
- package/dist/connectors/sqlserver.js +415 -102
- package/dist/connectors/stripe-api-key.js +269 -46
- package/dist/connectors/stripe-oauth.js +202 -5
- package/dist/connectors/supabase.js +303 -48
- package/dist/connectors/tableau.js +536 -163
- package/dist/connectors/tiktok-ads.js +279 -48
- package/dist/connectors/wix-store.js +320 -49
- package/dist/connectors/zendesk-oauth.js +239 -5
- package/dist/connectors/zendesk.js +358 -47
- package/dist/index.d.ts +149 -1
- package/dist/index.js +15057 -2117
- package/dist/main.js +15005 -2073
- package/dist/vite-plugin.js +14752 -2019
- 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,76 @@ 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
|
+
const pendingParameterUpdates = [];
|
|
413
|
+
for (const step of flow.steps) {
|
|
414
|
+
const ans = ctx.answers[answerIdx];
|
|
415
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
416
|
+
state = step.applyAnswer(state, ans.answer);
|
|
417
|
+
if (step.toParameterUpdates) {
|
|
418
|
+
pendingParameterUpdates.push(...step.toParameterUpdates(state));
|
|
419
|
+
}
|
|
420
|
+
answerIdx += 1;
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
|
|
424
|
+
if (step.type === "text") {
|
|
425
|
+
if (step.fetchOptions) {
|
|
426
|
+
const options2 = await step.fetchOptions(state, runtime);
|
|
427
|
+
if (options2.length === 0) {
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return {
|
|
432
|
+
type: "nextQuestion",
|
|
433
|
+
questionSlug: step.slug,
|
|
434
|
+
question: step.question[ctx.language],
|
|
435
|
+
questionType: "text",
|
|
436
|
+
allowFreeText: resolvedAllowFreeText,
|
|
437
|
+
...pendingParameterUpdates.length > 0 && {
|
|
438
|
+
parameterUpdates: pendingParameterUpdates
|
|
439
|
+
}
|
|
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
|
+
allowFreeText: resolvedAllowFreeText,
|
|
453
|
+
...pendingParameterUpdates.length > 0 && {
|
|
454
|
+
parameterUpdates: pendingParameterUpdates
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
459
|
+
return {
|
|
460
|
+
type: "fulfilled",
|
|
461
|
+
dataInvestigationResult,
|
|
462
|
+
...pendingParameterUpdates.length > 0 && {
|
|
463
|
+
parameterUpdates: pendingParameterUpdates
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
async function resolveSetupSelection(params) {
|
|
468
|
+
const { selected, allSentinel, fetchAll, limit } = params;
|
|
469
|
+
const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
|
|
470
|
+
return resolved.slice(0, limit);
|
|
471
|
+
}
|
|
472
|
+
|
|
367
473
|
// ../connectors/src/auth-types.ts
|
|
368
474
|
var AUTH_TYPES = {
|
|
369
475
|
OAUTH: "oauth",
|
|
@@ -400,10 +506,8 @@ var freshdeskOnboarding = new ConnectorOnboarding({
|
|
|
400
506
|
}
|
|
401
507
|
});
|
|
402
508
|
|
|
403
|
-
// ../connectors/src/connectors/freshdesk/
|
|
404
|
-
import { z } from "zod";
|
|
509
|
+
// ../connectors/src/connectors/freshdesk/utils.ts
|
|
405
510
|
var BASE_PATH_SEGMENT = "/api/v2";
|
|
406
|
-
var REQUEST_TIMEOUT_MS = 6e4;
|
|
407
511
|
function buildBaseUrl2(domain) {
|
|
408
512
|
const trimmed = domain.trim().replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
409
513
|
const subdomain = trimmed.split(".")[0];
|
|
@@ -412,6 +516,132 @@ function buildBaseUrl2(domain) {
|
|
|
412
516
|
function basicAuthHeader2(apiKey) {
|
|
413
517
|
return `Basic ${Buffer.from(`${apiKey}:X`).toString("base64")}`;
|
|
414
518
|
}
|
|
519
|
+
async function apiFetch(params, path2, init) {
|
|
520
|
+
const apiKey = params[parameters.apiKey.slug];
|
|
521
|
+
const domain = params[parameters.domain.slug];
|
|
522
|
+
if (!apiKey || !domain) {
|
|
523
|
+
throw new Error(
|
|
524
|
+
"freshdesk: missing required parameter(s) (api-key, domain)"
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
const baseUrl = buildBaseUrl2(domain);
|
|
528
|
+
const url = `${baseUrl}${path2.startsWith("/") ? "" : "/"}${path2}`;
|
|
529
|
+
const headers = new Headers(init?.headers);
|
|
530
|
+
headers.set("Authorization", basicAuthHeader2(apiKey));
|
|
531
|
+
headers.set("Accept", "application/json");
|
|
532
|
+
return fetch(url, { ...init, headers });
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// ../connectors/src/connectors/freshdesk/setup-flow.ts
|
|
536
|
+
var FRESHDESK_SETUP_MAX_ENTITIES = 5;
|
|
537
|
+
var FRESHDESK_ENTITIES = [
|
|
538
|
+
{
|
|
539
|
+
value: "tickets",
|
|
540
|
+
label: "Tickets",
|
|
541
|
+
countPath: "/search/tickets?query=%22status%3A%3E0%22",
|
|
542
|
+
countField: "total"
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
value: "contacts",
|
|
546
|
+
label: "Contacts",
|
|
547
|
+
countPath: "/contacts?per_page=1"
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
value: "companies",
|
|
551
|
+
label: "Companies",
|
|
552
|
+
countPath: "/companies?per_page=1"
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
value: "agents",
|
|
556
|
+
label: "Agents",
|
|
557
|
+
countPath: "/agents?per_page=1"
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
value: "groups",
|
|
561
|
+
label: "Groups",
|
|
562
|
+
countPath: "/groups?per_page=1"
|
|
563
|
+
}
|
|
564
|
+
];
|
|
565
|
+
async function fetchEntityCount(params, path2, countField) {
|
|
566
|
+
const res = await apiFetch(params, path2);
|
|
567
|
+
if (!res.ok) return null;
|
|
568
|
+
const data = await res.json();
|
|
569
|
+
if (Array.isArray(data)) return null;
|
|
570
|
+
if (countField && typeof data[countField] === "number") {
|
|
571
|
+
return data[countField];
|
|
572
|
+
}
|
|
573
|
+
return null;
|
|
574
|
+
}
|
|
575
|
+
var freshdeskSetupFlow = {
|
|
576
|
+
initialState: () => ({}),
|
|
577
|
+
steps: [
|
|
578
|
+
{
|
|
579
|
+
slug: "entities",
|
|
580
|
+
type: "multiSelect",
|
|
581
|
+
question: {
|
|
582
|
+
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",
|
|
583
|
+
en: "Select the Freshdesk entities to include in setup (multi-select allowed)"
|
|
584
|
+
},
|
|
585
|
+
async fetchOptions(_state, _rt) {
|
|
586
|
+
return FRESHDESK_ENTITIES.map((e) => ({
|
|
587
|
+
value: e.value,
|
|
588
|
+
label: e.label
|
|
589
|
+
}));
|
|
590
|
+
},
|
|
591
|
+
applyAnswer: (state, answer) => ({ ...state, entities: answer })
|
|
592
|
+
}
|
|
593
|
+
],
|
|
594
|
+
async finalize(state, rt) {
|
|
595
|
+
if (!state.entities) {
|
|
596
|
+
throw new Error("Freshdesk setup: incomplete state on finalize");
|
|
597
|
+
}
|
|
598
|
+
const targetEntities = await resolveSetupSelection({
|
|
599
|
+
selected: state.entities,
|
|
600
|
+
allSentinel: "__ALL__",
|
|
601
|
+
fetchAll: async () => FRESHDESK_ENTITIES.map((e) => e.value),
|
|
602
|
+
limit: FRESHDESK_SETUP_MAX_ENTITIES
|
|
603
|
+
});
|
|
604
|
+
const entityByValue = new Map(FRESHDESK_ENTITIES.map((e) => [e.value, e]));
|
|
605
|
+
const sections = [
|
|
606
|
+
"## Freshdesk",
|
|
607
|
+
"",
|
|
608
|
+
"### Selected entities",
|
|
609
|
+
"",
|
|
610
|
+
"| Entity | Count |",
|
|
611
|
+
"|--------|-------|"
|
|
612
|
+
];
|
|
613
|
+
for (const value of targetEntities) {
|
|
614
|
+
const entity = entityByValue.get(value);
|
|
615
|
+
if (!entity) {
|
|
616
|
+
sections.push(`| ${value} | _unknown_ |`);
|
|
617
|
+
continue;
|
|
618
|
+
}
|
|
619
|
+
const count = await fetchEntityCount(
|
|
620
|
+
rt.params,
|
|
621
|
+
entity.countPath,
|
|
622
|
+
entity.countField
|
|
623
|
+
);
|
|
624
|
+
sections.push(
|
|
625
|
+
`| ${entity.label} (${entity.value}) | ${count == null ? "-" : count} |`
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
sections.push("");
|
|
629
|
+
return sections.join("\n");
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
// ../connectors/src/connectors/freshdesk/tools/request.ts
|
|
634
|
+
import { z } from "zod";
|
|
635
|
+
var BASE_PATH_SEGMENT2 = "/api/v2";
|
|
636
|
+
var REQUEST_TIMEOUT_MS = 6e4;
|
|
637
|
+
function buildBaseUrl3(domain) {
|
|
638
|
+
const trimmed = domain.trim().replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
639
|
+
const subdomain = trimmed.split(".")[0];
|
|
640
|
+
return `https://${subdomain}.freshdesk.com${BASE_PATH_SEGMENT2}`;
|
|
641
|
+
}
|
|
642
|
+
function basicAuthHeader3(apiKey) {
|
|
643
|
+
return `Basic ${Buffer.from(`${apiKey}:X`).toString("base64")}`;
|
|
644
|
+
}
|
|
415
645
|
var inputSchema = z.object({
|
|
416
646
|
toolUseIntent: z.string().optional().describe(
|
|
417
647
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -485,8 +715,8 @@ Field codes (tickets):
|
|
|
485
715
|
try {
|
|
486
716
|
const apiKey = parameters.apiKey.getValue(connection2);
|
|
487
717
|
const domain = parameters.domain.getValue(connection2);
|
|
488
|
-
const baseUrl =
|
|
489
|
-
const normalizedPath = normalizeRequestPath(path2,
|
|
718
|
+
const baseUrl = buildBaseUrl3(domain);
|
|
719
|
+
const normalizedPath = normalizeRequestPath(path2, BASE_PATH_SEGMENT2);
|
|
490
720
|
const url = `${baseUrl}${normalizedPath}`;
|
|
491
721
|
const controller = new AbortController();
|
|
492
722
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
@@ -494,7 +724,7 @@ Field codes (tickets):
|
|
|
494
724
|
const response = await fetch(url, {
|
|
495
725
|
method,
|
|
496
726
|
headers: {
|
|
497
|
-
Authorization:
|
|
727
|
+
Authorization: basicAuthHeader3(apiKey),
|
|
498
728
|
"Content-Type": "application/json",
|
|
499
729
|
Accept: "application/json"
|
|
500
730
|
},
|
|
@@ -690,7 +920,46 @@ export default async function handler(c: Context) {
|
|
|
690
920
|
- \`status\`: 2=Open, 3=Pending, 4=Resolved, 5=Closed
|
|
691
921
|
- \`source\`: 1=Email, 2=Portal, 3=Phone, 7=Chat, 9=Feedback widget, 10=Outbound email`
|
|
692
922
|
},
|
|
693
|
-
tools
|
|
923
|
+
tools,
|
|
924
|
+
setup: (params, ctx, config) => runSetupFlow(freshdeskSetupFlow, params, ctx, config),
|
|
925
|
+
async checkConnection(params, _config) {
|
|
926
|
+
const domain = params[parameters.domain.slug];
|
|
927
|
+
const apiKey = params[parameters.apiKey.slug];
|
|
928
|
+
if (!domain || !apiKey) {
|
|
929
|
+
return {
|
|
930
|
+
success: false,
|
|
931
|
+
error: `Missing required parameter(s): ${parameters.domain.slug}, ${parameters.apiKey.slug}`
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
try {
|
|
935
|
+
const credentials = Buffer.from(`${apiKey}:X`, "utf-8").toString(
|
|
936
|
+
"base64"
|
|
937
|
+
);
|
|
938
|
+
const res = await fetch(
|
|
939
|
+
`https://${domain}.freshdesk.com/api/v2/agents/me`,
|
|
940
|
+
{
|
|
941
|
+
method: "GET",
|
|
942
|
+
headers: {
|
|
943
|
+
Authorization: `Basic ${credentials}`,
|
|
944
|
+
Accept: "application/json"
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
);
|
|
948
|
+
if (!res.ok) {
|
|
949
|
+
const errText = await res.text().catch(() => res.statusText);
|
|
950
|
+
return {
|
|
951
|
+
success: false,
|
|
952
|
+
error: `Freshdesk API failed: HTTP ${res.status} ${errText}`
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
return { success: true };
|
|
956
|
+
} catch (error) {
|
|
957
|
+
return {
|
|
958
|
+
success: false,
|
|
959
|
+
error: error instanceof Error ? error.message : String(error)
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
}
|
|
694
963
|
});
|
|
695
964
|
|
|
696
965
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -719,6 +988,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
719
988
|
import { getContext } from "hono/context-storage";
|
|
720
989
|
import { getCookie } from "hono/cookie";
|
|
721
990
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
991
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
722
992
|
function normalizeHeaders(input) {
|
|
723
993
|
const out = {};
|
|
724
994
|
if (!input) return out;
|
|
@@ -727,6 +997,11 @@ function normalizeHeaders(input) {
|
|
|
727
997
|
});
|
|
728
998
|
return out;
|
|
729
999
|
}
|
|
1000
|
+
function extractInputUrl(input) {
|
|
1001
|
+
if (typeof input === "string") return input;
|
|
1002
|
+
if (input instanceof URL) return input.href;
|
|
1003
|
+
return input.url;
|
|
1004
|
+
}
|
|
730
1005
|
function createSandboxProxyFetch(connectionId) {
|
|
731
1006
|
return async (input, init) => {
|
|
732
1007
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -736,10 +1011,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
736
1011
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
737
1012
|
);
|
|
738
1013
|
}
|
|
739
|
-
const originalUrl =
|
|
1014
|
+
const originalUrl = extractInputUrl(input);
|
|
1015
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
1016
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
1017
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
1018
|
+
return fetch(sessionUrl, {
|
|
1019
|
+
method: "POST",
|
|
1020
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
740
1023
|
const originalMethod = init?.method ?? "GET";
|
|
741
1024
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
742
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
743
1025
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
744
1026
|
return fetch(proxyUrl, {
|
|
745
1027
|
method: "POST",
|
|
@@ -765,10 +1047,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
765
1047
|
}
|
|
766
1048
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
767
1049
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1050
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
768
1051
|
return async (input, init) => {
|
|
769
|
-
const originalUrl =
|
|
770
|
-
const originalMethod = init?.method ?? "GET";
|
|
771
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1052
|
+
const originalUrl = extractInputUrl(input);
|
|
772
1053
|
const c = getContext();
|
|
773
1054
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
774
1055
|
if (!appSession) {
|
|
@@ -776,6 +1057,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
776
1057
|
"No authentication method available for connection proxy."
|
|
777
1058
|
);
|
|
778
1059
|
}
|
|
1060
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
1061
|
+
return fetch(sessionUrl, {
|
|
1062
|
+
method: "POST",
|
|
1063
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
const originalMethod = init?.method ?? "GET";
|
|
1067
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
779
1068
|
return fetch(proxyUrl, {
|
|
780
1069
|
method: "POST",
|
|
781
1070
|
headers: {
|