@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/freshservice/parameters.ts
|
|
57
|
+
init_parameter_definition();
|
|
46
58
|
var parameters = {
|
|
47
59
|
domain: new ParameterDefinition({
|
|
48
60
|
slug: "domain",
|
|
@@ -254,6 +266,28 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
254
266
|
tools;
|
|
255
267
|
query;
|
|
256
268
|
checkConnection;
|
|
269
|
+
/**
|
|
270
|
+
* SQPD-1212: Logic-based, rule-driven connection setup. Connectors that
|
|
271
|
+
* implement this expose a step-by-step exploration flow (database/schema/
|
|
272
|
+
* table/etc. discovery) that the dashboard backend drives via the
|
|
273
|
+
* `/connections/:connectionId/setup` endpoint. Implement by delegating to
|
|
274
|
+
* `runSetupFlow` from `setup-flow.ts`.
|
|
275
|
+
*/
|
|
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;
|
|
257
291
|
constructor(config) {
|
|
258
292
|
this.slug = config.slug;
|
|
259
293
|
this.authType = config.authType;
|
|
@@ -270,6 +304,8 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
270
304
|
this.tools = config.tools;
|
|
271
305
|
this.query = config.query;
|
|
272
306
|
this.checkConnection = config.checkConnection;
|
|
307
|
+
this.setup = config.setup;
|
|
308
|
+
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
273
309
|
}
|
|
274
310
|
get connectorKey() {
|
|
275
311
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -334,6 +370,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
334
370
|
}
|
|
335
371
|
};
|
|
336
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
|
+
|
|
337
418
|
// ../connectors/src/auth-types.ts
|
|
338
419
|
var AUTH_TYPES = {
|
|
339
420
|
OAUTH: "oauth",
|
|
@@ -370,10 +451,8 @@ var freshserviceOnboarding = new ConnectorOnboarding({
|
|
|
370
451
|
}
|
|
371
452
|
});
|
|
372
453
|
|
|
373
|
-
// ../connectors/src/connectors/freshservice/
|
|
374
|
-
import { z } from "zod";
|
|
454
|
+
// ../connectors/src/connectors/freshservice/utils.ts
|
|
375
455
|
var BASE_PATH_SEGMENT = "/api/v2";
|
|
376
|
-
var REQUEST_TIMEOUT_MS = 6e4;
|
|
377
456
|
function buildBaseUrl2(domain) {
|
|
378
457
|
const trimmed = domain.trim().replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
379
458
|
const subdomain = trimmed.split(".")[0];
|
|
@@ -382,6 +461,151 @@ function buildBaseUrl2(domain) {
|
|
|
382
461
|
function basicAuthHeader2(apiKey) {
|
|
383
462
|
return `Basic ${Buffer.from(`${apiKey}:X`).toString("base64")}`;
|
|
384
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
|
+
}
|
|
385
609
|
var inputSchema = z.object({
|
|
386
610
|
toolUseIntent: z.string().optional().describe(
|
|
387
611
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -455,8 +679,8 @@ Field codes:
|
|
|
455
679
|
try {
|
|
456
680
|
const apiKey = parameters.apiKey.getValue(connection2);
|
|
457
681
|
const domain = parameters.domain.getValue(connection2);
|
|
458
|
-
const baseUrl =
|
|
459
|
-
const normalizedPath = normalizeRequestPath(path2,
|
|
682
|
+
const baseUrl = buildBaseUrl3(domain);
|
|
683
|
+
const normalizedPath = normalizeRequestPath(path2, BASE_PATH_SEGMENT2);
|
|
460
684
|
const url = `${baseUrl}${normalizedPath}`;
|
|
461
685
|
const controller = new AbortController();
|
|
462
686
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
@@ -464,7 +688,7 @@ Field codes:
|
|
|
464
688
|
const response = await fetch(url, {
|
|
465
689
|
method,
|
|
466
690
|
headers: {
|
|
467
|
-
Authorization:
|
|
691
|
+
Authorization: basicAuthHeader3(apiKey),
|
|
468
692
|
"Content-Type": "application/json",
|
|
469
693
|
Accept: "application/json"
|
|
470
694
|
},
|
|
@@ -658,7 +882,46 @@ export default async function handler(c: Context) {
|
|
|
658
882
|
- \`status\`: 2=Open, 3=Pending, 4=Resolved, 5=Closed
|
|
659
883
|
- \`source\`: 1=Email, 2=Portal, 3=Phone, 4=Chat, 5=Feedback widget, 7=Yammer, 8=AwsCloudwatch, 9=Pagerduty, 10=Walkup, 11=Slack`
|
|
660
884
|
},
|
|
661
|
-
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
|
+
}
|
|
662
925
|
});
|
|
663
926
|
|
|
664
927
|
// src/connectors/create-connector-sdk.ts
|
|
@@ -687,6 +950,7 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
687
950
|
import { getContext } from "hono/context-storage";
|
|
688
951
|
import { getCookie } from "hono/cookie";
|
|
689
952
|
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
953
|
+
var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
|
|
690
954
|
function normalizeHeaders(input) {
|
|
691
955
|
const out = {};
|
|
692
956
|
if (!input) return out;
|
|
@@ -695,6 +959,11 @@ function normalizeHeaders(input) {
|
|
|
695
959
|
});
|
|
696
960
|
return out;
|
|
697
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
|
+
}
|
|
698
967
|
function createSandboxProxyFetch(connectionId) {
|
|
699
968
|
return async (input, init) => {
|
|
700
969
|
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
@@ -704,10 +973,17 @@ function createSandboxProxyFetch(connectionId) {
|
|
|
704
973
|
"Connection proxy is not configured. Please check your deployment settings."
|
|
705
974
|
);
|
|
706
975
|
}
|
|
707
|
-
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
|
+
}
|
|
708
985
|
const originalMethod = init?.method ?? "GET";
|
|
709
986
|
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
710
|
-
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
711
987
|
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
712
988
|
return fetch(proxyUrl, {
|
|
713
989
|
method: "POST",
|
|
@@ -733,10 +1009,9 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
733
1009
|
}
|
|
734
1010
|
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
735
1011
|
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
1012
|
+
const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
|
|
736
1013
|
return async (input, init) => {
|
|
737
|
-
const originalUrl =
|
|
738
|
-
const originalMethod = init?.method ?? "GET";
|
|
739
|
-
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
1014
|
+
const originalUrl = extractInputUrl(input);
|
|
740
1015
|
const c = getContext();
|
|
741
1016
|
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
742
1017
|
if (!appSession) {
|
|
@@ -744,6 +1019,14 @@ function createDeployedAppProxyFetch(connectionId) {
|
|
|
744
1019
|
"No authentication method available for connection proxy."
|
|
745
1020
|
);
|
|
746
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;
|
|
747
1030
|
return fetch(proxyUrl, {
|
|
748
1031
|
method: "POST",
|
|
749
1032
|
headers: {
|