@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/freshservice/parameters.ts
|
|
57
|
+
init_parameter_definition();
|
|
46
58
|
var parameters = {
|
|
47
59
|
domain: new ParameterDefinition({
|
|
48
60
|
slug: "domain",
|
|
@@ -262,6 +274,20 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
262
274
|
* `runSetupFlow` from `setup-flow.ts`.
|
|
263
275
|
*/
|
|
264
276
|
setup;
|
|
277
|
+
/**
|
|
278
|
+
* Opt-out of the default "verify before save" behavior on connection
|
|
279
|
+
* creation. The backend invokes `checkConnection` synchronously while
|
|
280
|
+
* creating the connection and aborts (no row inserted) if it fails — this
|
|
281
|
+
* flag disables that for connectors where the check cannot succeed pre-save:
|
|
282
|
+
*
|
|
283
|
+
* - `squadbase-db` populates `connection-url` only after Neon provisioning
|
|
284
|
+
* - OAuth connectors require an OAuth-aware proxyFetch keyed by the
|
|
285
|
+
* connectionId, which doesn't exist until the row is saved
|
|
286
|
+
*
|
|
287
|
+
* Exceptions are the explicit position; new credential-input connectors get
|
|
288
|
+
* the default verify-on-create behavior without opt-in.
|
|
289
|
+
*/
|
|
290
|
+
skipConnectionCheckOnCreate;
|
|
265
291
|
constructor(config) {
|
|
266
292
|
this.slug = config.slug;
|
|
267
293
|
this.authType = config.authType;
|
|
@@ -279,6 +305,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
279
305
|
this.query = config.query;
|
|
280
306
|
this.checkConnection = config.checkConnection;
|
|
281
307
|
this.setup = config.setup;
|
|
308
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
282
309
|
}
|
|
283
310
|
get connectorKey() {
|
|
284
311
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -343,6 +370,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
343
370
|
}
|
|
344
371
|
};
|
|
345
372
|
|
|
373
|
+
// ../connectors/src/setup-flow.ts
|
|
374
|
+
async function runSetupFlow(flow, params, ctx, config) {
|
|
375
|
+
const runtime = {
|
|
376
|
+
params,
|
|
377
|
+
language: ctx.language,
|
|
378
|
+
config
|
|
379
|
+
};
|
|
380
|
+
let state = flow.initialState();
|
|
381
|
+
let answerIdx = 0;
|
|
382
|
+
for (const step of flow.steps) {
|
|
383
|
+
const ans = ctx.answers[answerIdx];
|
|
384
|
+
if (ans && ans.questionSlug === step.slug) {
|
|
385
|
+
state = step.applyAnswer(state, ans.answer);
|
|
386
|
+
answerIdx += 1;
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
if (step.type === "text") {
|
|
390
|
+
return {
|
|
391
|
+
type: "nextQuestion",
|
|
392
|
+
questionSlug: step.slug,
|
|
393
|
+
question: step.question[ctx.language],
|
|
394
|
+
questionType: "text"
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
|
|
398
|
+
if (options.length === 0) {
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
return {
|
|
402
|
+
type: "nextQuestion",
|
|
403
|
+
questionSlug: step.slug,
|
|
404
|
+
question: step.question[ctx.language],
|
|
405
|
+
questionType: step.type,
|
|
406
|
+
options
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
const dataInvestigationResult = await flow.finalize(state, runtime);
|
|
410
|
+
return { type: "fulfilled", dataInvestigationResult };
|
|
411
|
+
}
|
|
412
|
+
async function resolveSetupSelection(params) {
|
|
413
|
+
const { selected, allSentinel, fetchAll, limit } = params;
|
|
414
|
+
const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
|
|
415
|
+
return resolved.slice(0, limit);
|
|
416
|
+
}
|
|
417
|
+
|
|
346
418
|
// ../connectors/src/auth-types.ts
|
|
347
419
|
var AUTH_TYPES = {
|
|
348
420
|
OAUTH: "oauth",
|
|
@@ -379,10 +451,8 @@ var freshserviceOnboarding = new ConnectorOnboarding({
|
|
|
379
451
|
}
|
|
380
452
|
});
|
|
381
453
|
|
|
382
|
-
// ../connectors/src/connectors/freshservice/
|
|
383
|
-
import { z } from "zod";
|
|
454
|
+
// ../connectors/src/connectors/freshservice/utils.ts
|
|
384
455
|
var BASE_PATH_SEGMENT = "/api/v2";
|
|
385
|
-
var REQUEST_TIMEOUT_MS = 6e4;
|
|
386
456
|
function buildBaseUrl2(domain) {
|
|
387
457
|
const trimmed = domain.trim().replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
388
458
|
const subdomain = trimmed.split(".")[0];
|
|
@@ -391,6 +461,151 @@ function buildBaseUrl2(domain) {
|
|
|
391
461
|
function basicAuthHeader2(apiKey) {
|
|
392
462
|
return `Basic ${Buffer.from(`${apiKey}:X`).toString("base64")}`;
|
|
393
463
|
}
|
|
464
|
+
async function apiFetch(params, path2, init) {
|
|
465
|
+
const apiKey = params[parameters.apiKey.slug];
|
|
466
|
+
const domain = params[parameters.domain.slug];
|
|
467
|
+
if (!apiKey || !domain) {
|
|
468
|
+
throw new Error(
|
|
469
|
+
"freshservice: missing required parameter(s) (api-key, domain)"
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
const baseUrl = buildBaseUrl2(domain);
|
|
473
|
+
const url = `${baseUrl}${path2.startsWith("/") ? "" : "/"}${path2}`;
|
|
474
|
+
const headers = new Headers(init?.headers);
|
|
475
|
+
headers.set("Authorization", basicAuthHeader2(apiKey));
|
|
476
|
+
headers.set("Accept", "application/json");
|
|
477
|
+
return fetch(url, { ...init, headers });
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// ../connectors/src/connectors/freshservice/setup-flow.ts
|
|
481
|
+
var FRESHSERVICE_SETUP_MAX_ENTITIES = 10;
|
|
482
|
+
var FRESHSERVICE_ENTITIES = [
|
|
483
|
+
{
|
|
484
|
+
value: "tickets",
|
|
485
|
+
label: "Tickets",
|
|
486
|
+
countPath: "/tickets?per_page=1"
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
value: "agents",
|
|
490
|
+
label: "Agents",
|
|
491
|
+
countPath: "/agents?per_page=1"
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
value: "requesters",
|
|
495
|
+
label: "Requesters",
|
|
496
|
+
countPath: "/requesters?per_page=1"
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
value: "groups",
|
|
500
|
+
label: "Groups",
|
|
501
|
+
countPath: "/groups?per_page=1"
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
value: "departments",
|
|
505
|
+
label: "Departments",
|
|
506
|
+
countPath: "/departments?per_page=1"
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
value: "assets",
|
|
510
|
+
label: "Assets",
|
|
511
|
+
countPath: "/assets?per_page=1"
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
value: "problems",
|
|
515
|
+
label: "Problems",
|
|
516
|
+
countPath: "/problems?per_page=1"
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
value: "changes",
|
|
520
|
+
label: "Changes",
|
|
521
|
+
countPath: "/changes?per_page=1"
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
value: "releases",
|
|
525
|
+
label: "Releases",
|
|
526
|
+
countPath: "/releases?per_page=1"
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
value: "service_catalog",
|
|
530
|
+
label: "Service catalog items",
|
|
531
|
+
countPath: "/service_catalog/items?per_page=1"
|
|
532
|
+
}
|
|
533
|
+
];
|
|
534
|
+
async function fetchEntityCount(params, path2) {
|
|
535
|
+
const res = await apiFetch(params, path2);
|
|
536
|
+
if (!res.ok) return null;
|
|
537
|
+
const data = await res.json();
|
|
538
|
+
if (typeof data["total"] === "number") return data["total"];
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
var freshserviceSetupFlow = {
|
|
542
|
+
initialState: () => ({}),
|
|
543
|
+
steps: [
|
|
544
|
+
{
|
|
545
|
+
slug: "entities",
|
|
546
|
+
type: "multiSelect",
|
|
547
|
+
question: {
|
|
548
|
+
ja: "\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3067\u6982\u89B3\u3057\u305F\u3044Freshservice\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
|
|
549
|
+
en: "Select the Freshservice entities to include in setup (multi-select allowed)"
|
|
550
|
+
},
|
|
551
|
+
async fetchOptions(_state, _rt) {
|
|
552
|
+
return FRESHSERVICE_ENTITIES.map((e) => ({
|
|
553
|
+
value: e.value,
|
|
554
|
+
label: e.label
|
|
555
|
+
}));
|
|
556
|
+
},
|
|
557
|
+
applyAnswer: (state, answer) => ({ ...state, entities: answer })
|
|
558
|
+
}
|
|
559
|
+
],
|
|
560
|
+
async finalize(state, rt) {
|
|
561
|
+
if (!state.entities) {
|
|
562
|
+
throw new Error("Freshservice setup: incomplete state on finalize");
|
|
563
|
+
}
|
|
564
|
+
const targetEntities = await resolveSetupSelection({
|
|
565
|
+
selected: state.entities,
|
|
566
|
+
allSentinel: "__ALL__",
|
|
567
|
+
fetchAll: async () => FRESHSERVICE_ENTITIES.map((e) => e.value),
|
|
568
|
+
limit: FRESHSERVICE_SETUP_MAX_ENTITIES
|
|
569
|
+
});
|
|
570
|
+
const entityByValue = new Map(
|
|
571
|
+
FRESHSERVICE_ENTITIES.map((e) => [e.value, e])
|
|
572
|
+
);
|
|
573
|
+
const sections = [
|
|
574
|
+
"## Freshservice",
|
|
575
|
+
"",
|
|
576
|
+
"### Selected entities",
|
|
577
|
+
"",
|
|
578
|
+
"| Entity | Count |",
|
|
579
|
+
"|--------|-------|"
|
|
580
|
+
];
|
|
581
|
+
for (const value of targetEntities) {
|
|
582
|
+
const entity = entityByValue.get(value);
|
|
583
|
+
if (!entity) {
|
|
584
|
+
sections.push(`| ${value} | _unknown_ |`);
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
const count = await fetchEntityCount(rt.params, entity.countPath);
|
|
588
|
+
sections.push(
|
|
589
|
+
`| ${entity.label} (${entity.value}) | ${count == null ? "-" : count} |`
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
sections.push("");
|
|
593
|
+
return sections.join("\n");
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
// ../connectors/src/connectors/freshservice/tools/request.ts
|
|
598
|
+
import { z } from "zod";
|
|
599
|
+
var BASE_PATH_SEGMENT2 = "/api/v2";
|
|
600
|
+
var REQUEST_TIMEOUT_MS = 6e4;
|
|
601
|
+
function buildBaseUrl3(domain) {
|
|
602
|
+
const trimmed = domain.trim().replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
603
|
+
const subdomain = trimmed.split(".")[0];
|
|
604
|
+
return `https://${subdomain}.freshservice.com${BASE_PATH_SEGMENT2}`;
|
|
605
|
+
}
|
|
606
|
+
function basicAuthHeader3(apiKey) {
|
|
607
|
+
return `Basic ${Buffer.from(`${apiKey}:X`).toString("base64")}`;
|
|
608
|
+
}
|
|
394
609
|
var inputSchema = z.object({
|
|
395
610
|
toolUseIntent: z.string().optional().describe(
|
|
396
611
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -464,8 +679,8 @@ Field codes:
|
|
|
464
679
|
try {
|
|
465
680
|
const apiKey = parameters.apiKey.getValue(connection2);
|
|
466
681
|
const domain = parameters.domain.getValue(connection2);
|
|
467
|
-
const baseUrl =
|
|
468
|
-
const normalizedPath = normalizeRequestPath(path2,
|
|
682
|
+
const baseUrl = buildBaseUrl3(domain);
|
|
683
|
+
const normalizedPath = normalizeRequestPath(path2, BASE_PATH_SEGMENT2);
|
|
469
684
|
const url = `${baseUrl}${normalizedPath}`;
|
|
470
685
|
const controller = new AbortController();
|
|
471
686
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
@@ -473,7 +688,7 @@ Field codes:
|
|
|
473
688
|
const response = await fetch(url, {
|
|
474
689
|
method,
|
|
475
690
|
headers: {
|
|
476
|
-
Authorization:
|
|
691
|
+
Authorization: basicAuthHeader3(apiKey),
|
|
477
692
|
"Content-Type": "application/json",
|
|
478
693
|
Accept: "application/json"
|
|
479
694
|
},
|
|
@@ -667,7 +882,46 @@ export default async function handler(c: Context) {
|
|
|
667
882
|
- \`status\`: 2=Open, 3=Pending, 4=Resolved, 5=Closed
|
|
668
883
|
- \`source\`: 1=Email, 2=Portal, 3=Phone, 4=Chat, 5=Feedback widget, 7=Yammer, 8=AwsCloudwatch, 9=Pagerduty, 10=Walkup, 11=Slack`
|
|
669
884
|
},
|
|
670
|
-
tools
|
|
885
|
+
tools,
|
|
886
|
+
setup: (params, ctx, config) => runSetupFlow(freshserviceSetupFlow, params, ctx, config),
|
|
887
|
+
async checkConnection(params, _config) {
|
|
888
|
+
const domain = params[parameters.domain.slug];
|
|
889
|
+
const apiKey = params[parameters.apiKey.slug];
|
|
890
|
+
if (!domain || !apiKey) {
|
|
891
|
+
return {
|
|
892
|
+
success: false,
|
|
893
|
+
error: `Missing required parameter(s): ${parameters.domain.slug}, ${parameters.apiKey.slug}`
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
try {
|
|
897
|
+
const credentials = Buffer.from(`${apiKey}:X`, "utf-8").toString(
|
|
898
|
+
"base64"
|
|
899
|
+
);
|
|
900
|
+
const res = await fetch(
|
|
901
|
+
`https://${domain}.freshservice.com/api/v2/agents/me`,
|
|
902
|
+
{
|
|
903
|
+
method: "GET",
|
|
904
|
+
headers: {
|
|
905
|
+
Authorization: `Basic ${credentials}`,
|
|
906
|
+
Accept: "application/json"
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
);
|
|
910
|
+
if (!res.ok) {
|
|
911
|
+
const errText = await res.text().catch(() => res.statusText);
|
|
912
|
+
return {
|
|
913
|
+
success: false,
|
|
914
|
+
error: `Freshservice API failed: HTTP ${res.status} ${errText}`
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
return { success: true };
|
|
918
|
+
} catch (error) {
|
|
919
|
+
return {
|
|
920
|
+
success: false,
|
|
921
|
+
error: error instanceof Error ? error.message : String(error)
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
}
|
|
671
925
|
});
|
|
672
926
|
|
|
673
927
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -696,6 +950,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
696
950
|
import { getContext } from "hono/context-storage";
|
|
697
951
|
import { getCookie } from "hono/cookie";
|
|
698
952
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
953
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
699
954
|
function normalizeHeaders(input) {
|
|
700
955
|
const out = {};
|
|
701
956
|
if (!input) return out;
|
|
@@ -704,6 +959,11 @@ function normalizeHeaders(input) {
|
|
|
704
959
|
});
|
|
705
960
|
return out;
|
|
706
961
|
}
|
|
962
|
+
function extractInputUrl(input) {
|
|
963
|
+
if (typeof input === "string") return input;
|
|
964
|
+
if (input instanceof URL) return input.href;
|
|
965
|
+
return input.url;
|
|
966
|
+
}
|
|
707
967
|
function createSandboxProxyFetch(connectionId) {
|
|
708
968
|
return async (input, init) => {
|
|
709
969
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -713,10 +973,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
713
973
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
714
974
|
);
|
|
715
975
|
}
|
|
716
|
-
const originalUrl =
|
|
976
|
+
const originalUrl = extractInputUrl(input);
|
|
977
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
978
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
979
|
+
const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
980
|
+
return fetch(sessionUrl, {
|
|
981
|
+
method: "POST",
|
|
982
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
983
|
+
});
|
|
984
|
+
}
|
|
717
985
|
const originalMethod = init?.method ?? "GET";
|
|
718
986
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
719
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
720
987
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
721
988
|
return fetch(proxyUrl, {
|
|
722
989
|
method: "POST",
|
|
@@ -742,10 +1009,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
742
1009
|
}
|
|
743
1010
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
744
1011
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1012
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
745
1013
|
return async (input, init) => {
|
|
746
|
-
const originalUrl =
|
|
747
|
-
const originalMethod = init?.method ?? "GET";
|
|
748
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1014
|
+
const originalUrl = extractInputUrl(input);
|
|
749
1015
|
const c = getContext();
|
|
750
1016
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
751
1017
|
if (!appSession) {
|
|
@@ -753,6 +1019,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
753
1019
|
"No authentication method available for connection proxy."
|
|
754
1020
|
);
|
|
755
1021
|
}
|
|
1022
|
+
if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
|
|
1023
|
+
return fetch(sessionUrl, {
|
|
1024
|
+
method: "POST",
|
|
1025
|
+
headers: { Authorization: `Bearer ${appSession}` }
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
const originalMethod = init?.method ?? "GET";
|
|
1029
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
756
1030
|
return fetch(proxyUrl, {
|
|
757
1031
|
method: "POST",
|
|
758
1032
|
headers: {
|